Recently, I wrote a blog post titled “Can Java be saved from death by feature bloat?“, that commented on some of the feature proposals for Java 7 (and some existing ones).
This post generated many comments. Some of them are so stupid, that I feel compelled to respond.
What I really want to get across with this is: I really like Java. It’s a great language, and most of the language zealots haven’t got a clue what they’re talking about.
In the last post, I was critical of some of Java’s features. This seem to have been interpreted by some as saying that Java is just bad. (Some of you didn’t interpret anything at all, and just took this as a chance to share your wisdom in succinct and witty statements such as “Java sucks”. The capacity for interpretation of argument there was obviously neither achieved nor required.)
Some comments were made on my blog site, and these are largely thoughtful and interesting observations. The post was, however, also discussed on reddit, and there some comments were… – how shall we put it? Let’s say, in terms of intellectual insight some of them were clearly flying under the radar. Some people don’t seem to have two brain cells to rub together.
I was, to be honest, quite dismayed to see some of the mindless drivel that passes for comment on reddit, and to become, by association, linked to these diatribes.
So, let’s get some things straight: The reason why I discuss (and criticise) Java, is because I care about Java. I like to write in that language, and I’d like to contribute to its evolution.
Too many people who don’t understand language design, who – I suspect – often know only a single language well, think they need to tell the world what’s right. Java did, in fact, get many more things right than most other languages of its time. Let’s look at some of the common statements. According to some of these comments, Java is a “design failure” because
- Java’s object model is wrong (Java should not have primitive types)
- Java should have closures
- dynamic typing is a lot better
- Java should have had genericity from the start
…and so on.
First of all: Java is one of the most successful languages ever by any metric you care to dream up. Number of lines code written in it. Number of programmers using it. Number of commercial projects using it. Or non-commercial projects, for that matter. Number of job offers. Number of universities teaching it. In all of these, Java would be in the top handful. THIS IS NOT A COINCIDENCE! It is just not the case that you alone know what’s going on and thousands of project managers and academics don’t. You may think that. If you do, you’re probably wrong.
Java is, in fact, quite a nice, clean implementation of object orientation. Many of you are whining about a “design failure” with the object system, because of primitive types? Get over it.
Even though I like uniform object systems as well (where every entity is an object), the fact is that Java’s compromise was – I am convinced – the right one to make at the time.
To appreciate that you need to be able to remember what the programming world was like when Java came out. When Java was published, one of the main criticisms was that it “is so slow that you cannot use it for anything that matters”. This was apparently because it ran on a VM.
The myth about Java being too slow is, in fact, so strongly perpetuated that even now I get people coming to my classes who don’t know anything about anything, but come out in the first class with “I don’t like Java – it’s too slow”. (When asked why they think that, they usually say something like “my brother told me”…)
And now people suddenly say “Why is not everything an object in Java”? (And they are probably the same people…)
The fact is that Java would have had a MUCH harder time being widely adopted commercially had it not made some of the compromises it has. Had it not made the compromise on the split type system (with primitive types and objects types) for efficiency’s sake, the hurdle might have been difficult to overcome.
A similar compromise is the choice of syntax. The important concepts (the object orientation model) is influenced by a set of languages (including, for example, Modula-3), but the syntax is based on C. That’s just horrible, from where I’m sitting, but I think it was necessary. Java was initially marketed as a “cleaned up C++” (which is essentially a lie, but a convenient lie). In fact, it differs so substantially from C++ in all concepts that really matter that the similarity is just skin deep. But it helped perpetuate the myth for a while that “if you know C++, you almost know Java”, and encouraged programmers to look at the language and switch.
See, there are basically two types of programming languages. There are research languages that introduce new features and experiment with them. They are usually not commercially successful, but advance programming language design as a discipline. And then there are consolidation languages that take and combine a selection of the best features and mould them into a single, coherent, commercially viable language. Java is such a language.
To do this, one has to make compromises. Getting a language widely adopted is very, very, very hard. I think the compromises made by the initial Java team were very clever and obviously paid off. Not often was a language such a clear step forward as Java was in 1995.
All language design is compromise. Everyone who has ever designed a language knows that. It is incredibly easy to pick a single feature and criticise it, but you are usually ignoring a whole stack of other forces and arguments that play into it as well.
That we discuss how to evolve a language has nothing to do with trying to imply that things were wrong at the time. To take a critical discussion of possible new language features and to turn it into a silly my-language-is-better-than-yours squabble is the most primitive, short-sighted reaction possible.
Every successful language has its strength. Denying that Java has its strong points is just silly. Arguing that one language is better than another is equally silly. No language is better than another full stop. A language is better than another one only for a given purpose. Passing value judgements without context is just saying “a screwdriver is better than a loaf of bread”. So?
It is easy to look back now in hindsight and say “but Scala/Python/Haskell/Squeak [insert your hobby horse here] does feature X so much better”. That might be true.
But language design with the goal of creating a widely useful commercial language is not about single features. It is about the compromises you have to make to successfully build up a whole ecosystem of technology and support, and that includes many more things. Java runs today on desktops, enterprise systems, web platforms, embedded systems – essentially unchanged. This is an achievement that shows an amazing engineering foresight and success that has not often been reached.
Anyone who doesn’t recognise this just doesn’t understand the last 20 years of programming language history.