I know it's fun to rag on Java, but this is a meaningless comparison. Java isn't a scripting language, and it wasn't ever intended to be one. It was never designed to solve quick little problems in a few lines, it was designed to deal with massive enterprise apps with complicated dependency trees over multiple architectures, and it does that job pretty damned well. Stop complaining that Java isn't Python/Ruby. It's like saying that x86 assembly is terrible because string concatenation takes so many loc.
Judging a language by standards it was never designed to meet is pointless. If you want to decide whether Java is a good language or not, see if it solves the problems it was designed to solve. I'd say it does. I may not like working in Java for small projects, but that doesn't make it a bad language.
> It was designed to deal with massive enterprise apps with complicated dependency trees over multiple architectures
Actually it was designed to run on washing machines, refocused to work for browser applets, and then refocused again to deal with massive enterprise apps. I'm not sure it was ever suited to any of those tasks -- it's merely has a good enough cross section of features. One only has to look over at what Microsoft has done with C# to see that Java could be significantly less verbose.
I thought the example was a little terse, he didn't even bother to include an XML configuration file for his IOC container, or a bunch of maven dreck to import a couple libraries. He also forgot to name the file correctly so it might not even compile. As well the batch file/shell script so it will actually execute and pass a bunch of arcane -XMemory flags to java.
I know it's fun to rag on Roman numerals, but they were never intended for totaling receipts. They were never designed for quick little sums, they were designed for engraving on massive long lasting objects like buildings and copyright notices on feature films, and they look pretty darned good there. Stop complaining that Roman numerals are not Arabic numerals. It's like saying counting on fingers is terrible because nobody has more than X them (That's 10 to you youngsters, or 0b1010 to you real smart alecks).
Judging a numeral by a standard it was never designed to meet is pointless. If you want to decide whether Roman numerals are a good number system or not, see if you can hammer them onto a building. I'd say you can. I may not like working with Roman numerals for grocery receipts, but that doesn't make them bad.
> They were never designed for quick little sums, they were designed for engraving on massive long lasting objects like buildings and copyright notices on feature films, and they look pretty darned good there. Stop complaining that Roman numerals are not Arabic numerals.
Actually, Roman numerals were designed for counting the men in your army, whereas Arabic numerals were designed for mathematics. Comparing the two isn't a good argument against redthrowaway's point at all, because both are better at the task they were designed for.
Are you saying that Roman numerals are better for counting than Arabic numerals? I suppose you don't mean count (I, II, III, IIII, V...), but show the number of men in the army. I don't see any advantage in using Roman numerals.
Lets say we divide infantry in XXX maniples of CXX men each, supposing they are complete and you haven't lost people yet in battle. How is that better than 30 maniples of 120 men?
Actually, roman numerals are easier to sum than arabics. To sum two roman numerals you just write all the digits together and collapse them as much as possible. There is no carrying over of digits and such.
Otoh, arabic numerals are a lot easier to multiply/divide. Before the wide adoption of arabic numerals all but the most educated couldn't perform simple multiplication/division.
Complain if you must, but there is a serious point involved. People get invested in technology and they start to adopt certain patterns of argument that stem more from their own investment than anything else. I tried to highlight the pattern using humor. Nothing personal intended.
In real life I do dislike java and try hard to avoid having to use it, precisely for the reasons highlighted in the OP. I do like Haskell, and many other things. Note: all the real Haskellers are nice and would never be as snarky as I was.
Well, at least the JVM was. Java the language was designed to lure C++ shops and not scare them too much. So in that respect, it was designed to be an enterprise class language.
It's perfectly reasonable to rag on it for this. What's not reasonable is that the code can be written in a much more compact way by not trying for an "applicative" style.
List even = new ArrayList();
for(int i : new Integer[]{1,2,3,4})
if (i%2==0) even.add(i);
Still larger than necessary, and this doesn't have all the necessary class cruft, but still much smaller.
Many of the other languages write this in functions that are first class citizens. The functions are ready to be used. In Java you would still need to put this inside another class to make it run and other classes would need to instantiate that class to run it.
This is admittedly better, note, tough, that I was trying to do it in the mindset of the other languages included (just having one explicit list and filtering out instead of in); however, as it was stated before, it's never good to try to write code in the idiomatic style of other languages if the end result is something not idiomatic at all, it's like trying to play the bach chaconne for violin in a tuba or <put better analogy here> : it can be done but it's just forcing it.
Where it all went wrong was when someone said Java is what the web should be developed with, we then got JSP, servlets and later Struts. Java web was brain dead on arrival and thankfully new style development trends are rectifying that evil. With JavaScript and Mobile apps taking over the UI from Java (as well as the other web frameworks for that matter), it becomes evident that Java when weighed in the balance is not that wanting, sure it does not do some things well and it can be a bit verbose, but as a back end language, I see no reason to abandon Java for purely technical merits. I do have concerns about Oracle's stewardship but that is another topic for another day.
However, since Java was not intended to be a scripting language, then it should never have monopolized the material of introductory programming classes like it did. I consider Java to be a very ungentle introduction to programming when compared with Python, Ruby or Scheme.
I agree, and my university is currently doing a 2-year A/B test where half the undergrads will get intro CS in Java, and the other half in Python. After the two years are up they'll see what group performs better in 3rd year classes. I think it's a great idea.
My 1st year profs were all fantastic, and the intro Java courses that I took did a fairly good job scaling from Hello World and FizzBang to a visual calculator processing pre-, in-, and post-fix arithmetic in a binary tree, so it wasn't too bad. Granted, first year was really easy and passed most students. Second year has, iirc, a 60% pass rate, and the program overall has a 40% pass rate. I'm not sure if that means it's rigorous or the profs are lousy, but I at least feel it means my degree is worth something when I graduate.
Emphasis added. Ensuring that students have a sound grounding in the basics and can then focus on the new material in later classes seems far more relevant to the goal of teaching computer science.
Universities focusing on throughput and employability is the problem, not the solution. It shouldn't be 4 more years of high school ...
That's true, and although I don't hate java or the technologies it has spawned (the JVM is a neat one, just look at it's finest offspring, clojure), trying to teach basic programming with it just seems bad. Maybe for an intermediate course on OOP, it does a good job if one wants to teach C++ or C afterwards; but as a first language, I have against it that it forces to spend too much time in syntax and inexplicable cruft (unless you're willing to explain the concept of class and static method the first day), and magic is never good for teaching if it's never explained. Just look at the classic SICP lectures: the syntax is done with in half an hour, then recursion and then higher order functions, and it doesn't feel like a brainfuck at all!
It actually happened to me, my first programming language in college was java and it made programming look really hard. I actually hated programming until the very end of my third year, when I learnt python in my first job. Ironically, later, when taking a compilers course -when I already knew how to program- I was quite happy with java+flex+cup, it felt powerful and fast.
Sorry to be pedantic, but wasn't Java designed initially for set-top boxes, when it was still called Oak, and was repeatedly re-purposed for running code in web pages (as applets) and then for enterprise-friendly server-side web apps (J2EE)?
> Java isn't a scripting language, and it wasn't ever intended to be one.
First class functions aren't a feature particular to scripting languages. Many compiled languages also have them, such as Haskell, Ocaml, Scala, F#, C#, D, Go, Forth, Common Lisp, and so on.
> It was never designed to solve quick little problems in a few lines
C# wasn't either, but it manages to be pretty expressive for what it is. I don't think you can argue Java's design precludes it from having basic things like first class functions, when (a) C# operates in the same market and already has them, and (b) Java 7 is going to be getting them.
This is not a meaningless comparison; it points out one of the main deficiencies of java: lack of first-class functions. The closest you can come is using anonymous inner classes, which is kind of kludgy.
Oh, this is just a tongue-in-cheek joke; java has really cool stuff, I actually code in java every morning and I really like the JVM and the JIT, without it, clojure, jruby and jython wouldn't exist, and jruby is way cooler than Cruby!
You're right, we can't be saying that a language sucks because it doesn't look cool in some coding styles. Is like trying to do fancy OOP in pure scheme or common lisp without the CLOS!
I know, and I both get and appreciate the joke. There are, however, a lot of people who think Java's (substantial) verbosity is a legitimate complaint against a language intended to do what it does. It's really neat to be able to accomplish something cool with list comprehension in Python, but when you're working on a massive codebase that might have 60 people working on the same code, it's nice to have the abstraction that Java was designed for, and the most basic syntax that a C-like language will allow.
There are, however, a lot of people who think Java's (substantial) verbosity is a legitimate complaint against a language intended to do what it does.
It is a legitimate complaint. Having to write loads of boilerplate makes the code more difficult to read and understand, and increases the surface area for bugs to sneak in. That's true for both one-off scripts and huge enterprisey systems.
Yep, in an environment like that the serious architecture java enforces is a good thing, especially with heterogenous groups of not-necessarily-hackers-but-good-coders.
I completely agree, though this is where I take issue with both the Java community and with managers and architects who have pushed for Java to be standard outside of the enterprise realm. I don't hate the language, I dislike the people who try to fit the square plug into the round hole. It's taking a lot of explaining to a lot of people at my workplace/university (a Java school naturally) that when developments teams are segregated into 1/2 person teams, have high turnover, and spread widely across an organization, using Java just doesn't make sense. It makes a lot more sense to use an easily approach scripting language such as Python or PHP in this case. But yet I had several Java evangelists literally screaming at me over our decision to go with PHP. In the end we won out, we built a solution that has run flawlessly (knock on wood) and the Java evangelists were moved to other departments.
Filtering a list of numbers by a criterion is not a standard. It's a simple task. The discussion does have relevance - it shows why Java programmers need to rely so heavily on cookie cutter libraries: writing something from scratch is a huge bear.
I routinely interview programmers of all kinds. Extremely few Java programmers ever make it because they simply don't know how to get simple (but non-mainstream) algorithmic tasks done.
Actually judging a language by standards it was never designed to meet is not pointless. I judge languages by how well they solve problems I need to solve. I don't care if it was intended to solve that problem.
Generally, typing extra stuff to make my code work isn't one of the problems I have.
x86 assembly IS terrible because string concat takes many loc. I use x86 assembly to solve problems where speed is paramount, string concatenation generally isn't one of those problems. Like lets say you need to reformat a little endian RGB pixel into a big endian RGB pixel, then that's something I'd use assembly for.
Java as a language is horrible language because the only problem it solves well is how to inflate a consulting bill, or how to waste developers time figuring out what exceptions a method throws. Only exception a method needs to throw is JavaOutTheDoor.
Solving a problem in java is like winning a race where your legs are hobbled, yes, it's an accomplishment, but wouldn't it have just been smarter to untie your legs? Java was invented in 1994 or something like that, and the scary part is it hasn't changed. Perhaps I should still code my C K&R style?
"Java as a language is horrible language because the only problem it solves well is how to inflate a consulting bill, or how to waste developers time figuring out what exceptions a method throws. Only exception a method needs to throw is JavaOutTheDoor."
You hover your mouse pointer over the method call and a pop-up window tells you what exceptions it can throw.
Better yet, right click the method call and tell it to insert the try and catch block(s) for you.
This is how professional Java developers work. It only takes a few seconds.
I find this sort of argument frustrating. "Java doesn't solve the problems I want to solve in the way I want to solve them, therefore Java is a horrible language and shouldn't be used by anyone." Fine, Java isn't the language for you; but other people have different problems or different ways to solving those problems and some of those people find Java to be a perfectly good language. Just because you don't like it doesn't mean everyone should hate it. To each his own.
> Java isn't a scripting language, and it wasn't ever intended to be one.
One of my beliefs is that we shouldn't think about "scripting languages" versus "compiled languages" and just think in terms of what would make for the ideal programming language, period. By that standard, Java is inferior to Python (to pick just one example) because it is so much more verbose and formal when accomplishing the same desired task.
Judging a language by standards it was never designed to meet is pointless. If you want to decide whether Java is a good language or not, see if it solves the problems it was designed to solve. I'd say it does. I may not like working in Java for small projects, but that doesn't make it a bad language.