|
Pollyanna posted:Cool. So why not write in another language like Scala, Jython or Clojure and have that run on the JVM instead? I work for a company that has taken the plunge and is attempting to do as much as possible in Scala, for this reason. I feel somewhat experienced to talk about this. The main reason most companies stick with plain Java is that it's well understood by a lot of people and there's a zillion native libraries for it. Yes, you can use almost all of these libraries from these other languages, but there are pain points (Scala does not suffer nulls gladly, so you need to be careful when interacting with regular java libs). Scala uses different types, and has tricks for getting around type erasure, all of which you will run into as a problem at some point or another. It's easier to hire people who know Java - it's been around forever and it's been the lingua franca of ENTERPRISE applications for years. If you need to hire 5 mediocre dudes quickly, Java is easy to find. But additionally, and more importantly, I would be lying if I said that it's pain-free to write Scala in practice. For one thing, if you have any mediocre programmers on your team they will quickly be lost and do terrible things. But worse, the toolchain support is sketchy at best - so far IntelliJ with the Scala plugin has been ok, but it's nowhere near as mature as native Java support. Compile times are much slower, too. I love Scala and think we made the right choice, but a more established, conservative company with a larger team will balk at these issues and I can't say I'd blame them.
|
# ? Oct 4, 2013 02:09 |
|
|
# ? Jun 1, 2024 19:36 |
|
Pollyanna posted:What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on. "Oh god it takes 6 or 7 lines of boilerplate code to print hello world, this is inefficient crap" I'm not a huge fan of Java, but having to define an entry point is not one of the problems I have.
|
# ? Oct 4, 2013 02:31 |
|
From a pedagogical standpoint, "public static void main" is being taught without understanding exactly what's going on. I don't think Java is a great language for learning on.
|
# ? Oct 4, 2013 02:52 |
|
Ithaqua posted:"Oh god it takes 6 or 7 lines of boilerplate code to print hello world, this is inefficient crap"
|
# ? Oct 4, 2013 02:55 |
|
Suspicious Dish posted:From a pedagogical standpoint, "public static void main" is being taught without understanding exactly what's going on. I don't think Java is a great language for learning on. It's weird because it's not like a main function is complicated, you can explain each part of why it's signature is like that to computer science students in less than a minute.
|
# ? Oct 4, 2013 03:12 |
|
Pollyanna posted:What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on. Go pick up Processing. It's Java for artists who don't need to learn how to program, and you're not forced to declare your "hello world" line in ~a class~.
|
# ? Oct 4, 2013 03:30 |
|
Pollyanna posted:What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on. Why don't you stick with matlab or something then.
|
# ? Oct 4, 2013 03:56 |
|
piratepilates posted:It's weird because it's not like a main function is complicated, you can explain each part of why it's signature is like that to computer science students in less than a minute. Just because you can blurt an explanation out in under minute doesn't mean fresh undergrads will understand wtf your're saying. This is true if it's not their first programming language, but that's not what Suspicious Dish is talking about.
|
# ? Oct 4, 2013 03:56 |
|
This is the thread we talk about lovely code still, right?code:
|
# ? Oct 4, 2013 05:42 |
|
Pollyanna posted:What in god's name is the reason for keeping this crap? Could it somehow not get any more efficient or something? Why does everything have to be a class?! All I want to do is print Hello World, come on. Errm, Have you ever tried a J2EE application, you dont have a main method there? or for an applet, all our servlets have @RequestMapping annotations and no sign of a main. Main is used when you are running an application command line or GUi and its that way so you know where the program starts, otherwise it could start running anywhere... Pascal now that was a strict language, you put the start of the program at the bottom and all subroutines if they called another had to be below the one they called.
|
# ? Oct 4, 2013 08:44 |
|
Pollyanna posted:What in god's name is the reason for keeping this crap? Come now, you have python background. How is: Python code:
|
# ? Oct 4, 2013 09:17 |
|
Although this is entertainingly dated, I'm not clear on why it counts as a coding horror...
|
# ? Oct 4, 2013 09:53 |
|
https://www.youtube.com/watch?v=rRbY3TMUcgQ
|
# ? Oct 4, 2013 10:25 |
|
NtotheTC posted:Come now, you have python background. How is: It's not mandatory, you only have to do that if you're doing weird stuff, like having a python script be both a library and the application executable. I prefer keeping those two concepts separate and as a consequence, never have to do it.
|
# ? Oct 4, 2013 12:58 |
|
Edison was a dick posted:It's not mandatory, you only have to do that if you're doing weird stuff, like having a python script be both a library and the application executable. I prefer keeping those two concepts separate and as a consequence, never have to do it. Maybe you don't, but it's prolific enough that it's shoved down the throats of most new python programmers at some stage, and isn't intuitive enough to prevent them having to go and specifically look up (or be told) what it does. Which is why it was odd to me that a python programmer would take exception to public static void main as being too hard to grasp and a reason why Java was a poor language for newcomers.
|
# ? Oct 4, 2013 13:06 |
|
Ephphatha posted:This is the thread we talk about lovely code still, right? Yup edit: I should still prolly bite the bullet and learn java anyway. Pollyanna fucked around with this message at 15:51 on Oct 4, 2013 |
# ? Oct 4, 2013 15:35 |
|
What's lovely about that? (other than the fields being public, which kinda defeats the purpose of having get/set methods) That's exactly how you're supposed to implement that in Java. And not to turn into a broken record espousing the superiority of .NET, but in C#, you can express the same thing with public int Foo {get; set;} You're not supposed to expose public fields. The reason is that the fields represent the internal state of your object. Letting anything go and mess with those willy-nilly is going to cause you problems down the line when you change your implementation. By giving a set of methods that allow you to retrieve/mutate the internal state of the object, you can change the internal implementation without introducing a breaking change in your code.
|
# ? Oct 4, 2013 15:54 |
|
It took me a moment to realise the first method wasn't actually ejactulate()
|
# ? Oct 4, 2013 15:56 |
|
Following the JavaBean standard isn't a horror. I've got some immutable beans in my current project, and just by following the standard they're able to be serialized by Jackson and JAXB automagically. It's awesome.
|
# ? Oct 4, 2013 15:59 |
|
I think the horror was referring to the not implemented setters
|
# ? Oct 4, 2013 16:05 |
|
E: I mean the nosering hipster Never mind found it. I was hoping it was an embarrassing Ruby webdev hipster stereotype, it wasn't. Workaday Wizard fucked around with this message at 16:15 on Oct 4, 2013 |
# ? Oct 4, 2013 16:05 |
|
Also if the horror is supposed to be the crushing verbosity of writing all that you can:
|
# ? Oct 4, 2013 16:07 |
carry on then posted:I think the horror was referring to the not implemented setters You mean setEntityContext method? I don't think that's supposed to be just a simple setter, but something related to the EJB framework stuff. (Is there a concise explanation of what EJB classes actually involve anywhere?)
|
|
# ? Oct 4, 2013 16:48 |
|
I guess if IDEs and such auto-write the private main int void immut { private main function { printf( 2 + 3) } } stuff for me it's not so bad. Still annoying to read, though. Maybe I'm too used to scripting languages.
|
# ? Oct 4, 2013 17:33 |
|
Ithaqua posted:You're not supposed to expose public fields. The reason is that the fields represent the internal state of your object. Letting anything go and mess with those willy-nilly is going to cause you problems down the line when you change your implementation. By giving a set of methods that allow you to retrieve/mutate the internal state of the object, you can change the internal implementation without introducing a breaking change in your code. I really don't understand this. It's the ultimate "let's plan for all software changes". This has saved me exactly one time, where I flipped a boolean notBroken; around to boolean broken; and was able to leave some basic compatibility getter/setters that I immediately deprecated, and then eventually removed, because people kept on using them wrong. Chances are that when you change the internals of an object, the API also changes, even if subtly. It really doesn't help that the language doesn't help you do this best practice, by having public fields as a built-in feature, but not getters/setters. If you need to go out of your way to apply a best practice, the language's design is lovely.
|
# ? Oct 4, 2013 17:36 |
|
Suspicious Dish posted:I really don't understand this. It's the ultimate "let's plan for all software changes". That's why .NET has had auto-implemented properties since 2005. It's a good practice, and it shouldn't be cumbersome to implement. At least in the .NET world, the recommendation is to only use private fields and public properties is also because changing a field to a property is a breaking change; any assembly dependent on the changed assembly would also have to be recompiled.
|
# ? Oct 4, 2013 17:44 |
|
NtotheTC posted:It took me a moment to realise the first method wasn't actually ejactulate() There's certainly an English horror there, ejbPassivate().
|
# ? Oct 4, 2013 18:14 |
|
Suspicious Dish posted:Chances are that when you change the internals of an object, the API also changes, even if subtly. Generating setters/getters is a couple of keystrokes in an IDE, but by all means you can use public fields too.
|
# ? Oct 4, 2013 18:23 |
|
I suspect that the valid argument for getters and setters is valid in the same way that the argument for the extra verbosity in a statically-typed langauge not being an important time sink. In other words, if they irritate you, don't use them with the understanding that in some sort of environments it will bite you in the rear end. There's probably vast swaths of programming environments where the irritant of having to deal with them is not out weighed by API changes breaking stuff. In other other words, use them if you need to, but understand that there's plenty of people who don't need to (and vice versa).
|
# ? Oct 4, 2013 18:34 |
|
Suspicious Dish posted:From a pedagogical standpoint, "public static void main" is being taught without understanding exactly what's going on. I don't think Java is a great language for learning on. I think this is crazy. Who doesn't remember glossing over the finer points of streams in c++ their first "cout << "hello world!"? You're still at the ground floor of learning this poo poo in the situation that'd be confusing or offputing. I think this idea that people have to understand everything down to the assembly and the physics of transistors is crazy (obviously being hyperbolic). You don't start kids out with number theory and formal logic, you start um with addition and subtraction. Sure, it may be "simpler" to teach someone a bash script or python where it just starts on the first line, read through the script like a document, but I really don't think just glossing over "hey, programs gotta start somewhere" is that detrimental to the pedagogy. If you're teaching someone who will NEVER try to program something again in their life, maybe. But I really don't see how they're gonna be confused or misled by "just accept for these first couple of weeks that 'public static void main' is a magical incantation"
|
# ? Oct 4, 2013 18:55 |
|
ManoliIsFat posted:I think this is crazy. Who doesn't remember glossing over the finer points of streams in c++ their first "cout << "hello world!"? You're still at the ground floor of learning this poo poo in the situation that'd be confusing or offputing. I think this idea that people have to understand everything down to the assembly and the physics of transistors is crazy (obviously being hyperbolic). You don't start kids out with number theory and formal logic, you start um with addition and subtraction. Sure, it may be "simpler" to teach someone a bash script or python where it just starts on the first line, read through the script like a document, but I really don't think just glossing over "hey, programs gotta start somewhere" is that detrimental to the pedagogy. On the other hand, streams are insane and terrible.
|
# ? Oct 4, 2013 19:13 |
|
code:
I replaced this entire mess with a HashSet...
|
# ? Oct 4, 2013 19:15 |
|
We've had some changes in the past we decided not to do because we didn't use getters and setters. The hilarious part was at some point when our codebase was a fraction of its current size someone actually REMOVED them.
|
# ? Oct 4, 2013 19:42 |
Freakus posted:We've had some changes in the past we decided not to do because we didn't use getters and setters. The hilarious part was at some point when our codebase was a fraction of its current size someone actually REMOVED them. This. Having controlled access to public data on objects seems like a bad tax when your project is small, but at some point you will end up hating yourself for not having done it. You might need to virtualize a field to be a calculation of something else, or fire off an event when something changes, or validate inputs, or a million other things. (And keep in mind that prototype systems tend to be promoted to production.)
|
|
# ? Oct 4, 2013 19:58 |
|
nielsm posted:(And keep in mind that prototype systems tend to be promoted to production.)
|
# ? Oct 4, 2013 20:02 |
|
nielsm posted:(And keep in mind that prototype systems ManoliIsFat posted:If you're teaching someone who will NEVER try to program something again in their life, maybe. But I really don't see how they're gonna be confused or misled by "just accept for these first couple of weeks that 'public static void main' is a magical incantation" I'm coming around to the view that starting with OOP right out of the gate is a bad way to teach introductory programming. Seems more straightforward to introduce "data" and "operations on data" before jumping right into why you would want to combine the two for ~*abstraction*~.
|
# ? Oct 4, 2013 20:49 |
Monkeyseesaw posted:I'm coming around to the view that starting with OOP right out of the gate is a bad way to teach introductory programming. Seems more straightforward to introduce "data" and "operations on data" before jumping right into why you would want to combine the two for ~*abstraction*~. That's exactly the same thing I experienced when I took a (rather low level) CS education to get some papers on my skills. It was Java all the way, and everyone was struggling with why you would even want objects. One actually came up with the idea "can't you just store everything in ArrayLists?" since those were easy data structures to understand. Yeah, you can and you're basically doing what programmers were doing 40 years ago then, but Java really also gets in your way when doing that. It's hard to understand how you design a good class, so you really need to have spent a lot of time working with simpler (to understand) data structures first.
|
|
# ? Oct 4, 2013 21:07 |
|
Monkeyseesaw posted:I'm coming around to the view that starting with OOP right out of the gate is a bad way to teach introductory programming. Seems more straightforward to introduce "data" and "operations on data" before jumping right into why you would want to combine the two for ~*abstraction*~.
|
# ? Oct 4, 2013 21:14 |
|
Taken from http://localhost.re/p/whmcs-527-vulnerability :code:
|
# ? Oct 4, 2013 22:23 |
|
|
# ? Jun 1, 2024 19:36 |
|
hazzlebarth posted:Taken from http://localhost.re/p/whmcs-527-vulnerability : When I was running a web host last yearish, WHMCS screwed me over pretty badly by allowing an attacker access to the loving root of the system (it needs the WHM information to be able to create accounts. WHM uses root details.) loving pain in the rear end. Really though it's a great system; it's too bad it's PHP.
|
# ? Oct 4, 2013 22:53 |