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.
I share your views on this one.
I do have a question – do you think that Java is suitable for any kind of project and environment or there are specific areas in which it excels and specific kinds of applications where as a programmer you should stay clear of Java as the language of choice?
You seem to be defending the compromises in the language’s design rather than the language itself; you’re not saying it’s great but that there are great reasons why it’s not great.
Why doesn’t it need closures? Why wouldn’t dynamic typing be better?
Java /is/ a great language. It was the first language to persuade the world that a VM based runtime is a good idea. And HotSpot showed that a VM can potentially perform better than statically compiled native code. The security model was absolutely prescient. Inner classes are an elegant (conceptually if not syntactically) solution to a tricky problem. Immutable strings seemed daring but turned out to be a good thing. And garbage collection in a mainstream language! No more concerns about who owns what. The freedom from the need to track ownership is a far bigger win than “you don’t have to call free”.
But why not closures? Inner classes come close but they’re not quite the same, not quite as fleet of foot. Why in general shouldn’t Java support more functional idioms?
> 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.
Um, that’s still Cobol.
> Number of programmers using it.
If you count non-pros, that would go to either VB or JavaScript.
> Number of commercial projects using it.
If you are talking shrink-wrap, Java doesn’t even rate. If you are talking internal projects for companies, there is a lot of competition and no one really knows who is ‘winning’.
> Or non-commercial projects, for that matter.
What would probably be VBA/Excel.
Interesting analysis.
Java still sucks.
Your entire argument about primitive types being the “right choice” for performance reasons can be easily dismissed by looking at just about any real object-oriented language and at how the stack/heap problem that you are hinting at is dealt with.
And yes, this includes languages that are *decades* older than java. So yes, it was a design mistake. One example of many.
I could do a better job of defending your erroneous position than this horrible ill-discplined anti-think material.
Java’s “achievement” isn’t because of an amazing engineering foresight, it’s in spite of a lack of engineering foresight, thanks to SUN’s marketing. The JVM itself is horrible and the language, doubly so.
I agree Java had some great features, I was happy to say good bye to C++ after only a few days with Java. The really excellent GC system is probably the best feature of Java.
But just because a language has some good features and changed some people’s minds about what a programming language should be doesn’t mean that this language should should become the automatic choice for all future projects, or that even better languages shouldn’t be sought out.
Java is very verbose, many people I know use editors to help them generate code. This is not my idea of a the kind of practice a good programming language should engender. Code should be readable, expressive and concise, and Java code is just readable. Let’s look for something better.
Couldn’t have said it better myself.
Also, don’t forget the “erasure generics suck” complaint, which should be translated to mean “I want to break every piece of pre-generics code ever written”. I guess it’s just really easy for people to complain about design decisions they didn’t have to make.
> No language is better than another full stop. A language is better than another one only for a given purpose.
Well, what if:
Language A is better for most purposes than Language B?
Of course for a language to be good for most purposes, it needs to have a good standard library too, but still..
I think a language can be deemed better “in general” than another.
Pingback: nibble » Blog Archive
Hi,
I am slightly anti Java, but I don’t say that the language is bad. There are many things good about Java. But there are a couple of things that really ‘Get’ me. As for speed – I can’t agree that Java is fast. It *IS* slow, from experience. Even with HotSpot. It is not Java’s fault, it is part of the compromise (this was the price for platform independence). Its not bad, Java code can still be used commercially, you need a slightly faster machine, but the complexity is not affected, and HotSpot does work (I think its just called JIT compiler now). Swing based interfaces are good, but if I set a specific theme and colour (say, hight contrast mode) for my computer, it won’t work for Java. It is not usually a problem, but sometimes (very rarely), it is a problem. It is effectively duplicate code (you have interfaces implemented by the OS as well as Java Swing). Another annoying thing is gc. GC is good, no doubt. In fact, I love it (while writing software). But when I use a Java app, it hangs in the middle of something and I have to wait a few seconds to continue work. Like I’m typing in a Java editor, and suddenly it decides to do a gc. I can’t type, and I feel all pissed off. (this happened with Netbeans quite a few times, and I had to use vim / Notepad / edit.com for editing!!! I was in college, doing my project, and to Java’s standards, my RAM was not enough). The next thing, memory. Java programs turn out to be memory intensive.
But the bigger problem which I face – with Java, I feel a little isolated from the design of the code, and the interaction with the computer. It may not be bad, but since I learnt C/C++ earlier, where you have more control over the system, I feel that I’m being restrained. (Again, its not bad considering that you gain platform neutrality).
But to be fair to Java, some commercial C++ languages are also slow. There was this issue about valarry and vector being quite slow with .net’s compiler, even with optimizations. If you are taking this also into consideration, Java is very good. It works just as fast on an interpretor!!
So, I say that I have mixed feelings about java. It’s not bad, but it has its problem. And I use Java, and I will continue using it.
In java some features are good, exist good frameworks. But Java as Language: SUCKS! and it’s old. Sorry. (I say this because i worked on Pascal,C,C++, Java, Haskell, Perl, Python, PHP, Eiffel, Ruby)
Don’t be childish.. “Java sucks”, “C++ sucks”.
Different challenges require different tools, and Java is a wonderful platform-language symbiosis for a large set of problems. This has been proven in fact.
If you invent a way to use Python/.NET/C++ to achieve a better solution for the same problem than when using Java, you’re welcome to use Python/.NET/C++, and respect goes to you.
If you still say things like “Java sucks” or “C++ sucks”, then most probably it’s you who sucks in the end.
Hi,
first of all a reponse to Razee´s post:
@Razee
a lot of stuff is a matter of taste, like whether java is pretty or not. But speed is not a matter of opinion and your conclusions of java´s speed are based on wrong observations and misleading experiences.
You can not make conclusions on java´s performance exclusively by using java “products” such as a java based Editor. There are several reasons for that:
1) it may not be implemented efficiently
2) it may not be optimized well enough
3) the program is not executed with proper arguments, you can try increasing the heap space. Google for that to learn more
4) …
Also the case of Swing based GUIs is a special topic, because Swing was not designed to be high performance : only platform independent. Recent releases of the JVM are improving the speed, but the speed of native “non-platform independent” GUIs is faster.
Your argument that java needs a lot of memory is true. This cant be avoided right now.
and now a response for all
@ all
Personally, I´m really tired on repeating the same discussions over and over again. I could write a lot around this topic as well, but I´ll try to be as accurate as possible:
Innovation will never stop and you will reach a dead end if “you” stop moving forward. Of course you will still be able to solve practical problems with language X, but others will do much better.
Why aren´t you riding a horse instead of driving a car ? think about it.
Java of course is not a horse “yet”, but sooner you will see rockets raising in the sky, without a Java logo on them.
kind regards,
Andreas
I’ve been a Java developer for 10 years, have built a reasonably successful open source product for Java, have spoken for years at various Java conferences and even wrote a book.
In the past I’ve worked with other languages including C, Object Pascal (Delphi). I worked with C#/.NET for more than a year and I’m currently a full time Ruby developer. Recently I’ve dabbled with Groovy, too.
I have to say… Java does in fact suck. Here’s why:
Up to Java 1.4, the language was okay. Yes it was limited in its feature set, but it was consistent and fairly light. Aside from the language, Java has a pretty good standard library, the best virtual machine in the business (still does), and it has a vibrant open source community. It also had the best tools available. The Java language was rarely an impediment and I could get the job done.
Java 1.5 and the JCP changed all of that.
Generics suck. They’re horribly implemented and offer no type safety whatsoever. The errors occur away from where they’re made and the syntax is nothing short of insanity. C# 2.0 did a far better job of implementing Generics and with the new var keyword in C# 3.0, the syntax is less noisy. I do however have grown to live happily without type safety in Ruby and Groovy may be the best of both worlds with optional typing –because sometimes it’s useful for tools like object-relational mappers. To summarize, I don’t need generics, but if they’re to be added to my favourite language, then I’d at least like it to be done well…but Java 1.5 Generics suck.
Annotations are probably the worst thing I’ve seen implemented in Java 1.5, mostly because there was no excuse for them sucking so bad. At least with generics I could understand some level of backward compatibility needed to be maintained, but with annotations, it was such a new and fairly independent feature that I can’t imagine why it sucks so bad! The syntax for defining a new annotation is horrid. Annotations are a representation of state, similar to a struct, and yet they’re defined using an interface-like construct…an abuse of interfaces in a sense (yes I understand how they’re implemented behind the scenes –don’t care, it’s not an excuse). And even the “keyword” @interface is dumb. I once heard the excuse that they couldn’t add a new keyword, but how did enum get one then? OR at the very least, why not @annotation (or the elite @nnotation ;-). Beyond that, annotations suck for their lack of features, no extension, no multiple uses on a target without a collection (dumb!) and no named parameters. And the approach to defaults sucks too. Annotations suck. C# again blows away Java with its implementation of Attributes. Dear Sun, if you’re going to copy someone, at least do a good job of it.
Autoboxing is inconsistent and incomplete. ’nuff said.
Enum was well done but was the least helpful as I’ve been using typesafe enum patterns for years.
Meanwhile, where’s multi-line strings?
What about reflection on parameter names for tools and frameworks?!
What does the future hold? A new logo in Java 6. In Java 7, possibly inline XML (!) and the ugliest closure syntax ever conceived.
Dude… Java doesn’t suck because anything else is better. Java sucks because Java 1.4 was better. It has been made worse at the hands of a committee based design approach and implementations that were rushed to market to try to keep up with Microsoft (despite the 7 year head start Java had) and now they’re switching gears to match Ruby. It doesn’t work.
In the enterprise Java will ultimately lose to Microsoft .NET. On the web it will lose to Ruby, PHP and maybe even python.
Let’s at least hope the JVM survives as a platform for hosting better languages like JRuby, Groovy and Scala.
Don’t get me wrong, I’m just as disappointed as you. I wish Java was everything it could have been.
My $0.02
Clinton
wow, Razee Marikar’s comment shocked me. I think he should get some real job, maybe in java and buy a real computer. I know that java is “write once, run anywhere”, but as we see amiga version is slow.
Sorry for agressive responce, but its just like saying “those shoes sucks, because i gas out after 5 minutes”.
i could not agree more.
java was always “easy to read”.
(btw, that’s why every so much people feel be funded well enough to give a few ‘wise’ advices)
simplicity for reader is really important feature.
programmers spent much more time maintaining code than writing.
Michael, nicely said. People had that coming and I think you were spot on.
I like Java too. I get on with it, can write and read it. I never could do that with VB. I could say “VB sucks” right now, but that would be childish like some others posting here. You think that’s an intelligent response to what *is* an intelligent post.
The reality is I don’t like or understand VB. But that’s fine, because it’s successful and others do.
I don’t like the idea of that static import thing. That just dilutes what’s going on as far as I’m concerned… however I did think autoboxing was cool.
The anti-Java brigade is highly prevalent it would seem, normally completely uneducated opinions without real backup. That’s not to say people can’t have real criticisms of it. I’ve heard all sorts of trash over the past term about Java.
I agree with this post and your post about feature bloat in Java 100%. Do you know of any project that seeks to make a simplified version of Java, that gradually removes some of the complexities and avoids the imminent feature bloat? I would be very interested in participating in such a project . . . Scala is too much of a departure for me.
Java rocks!
It is easy to read and maintain, a lot of frameworks for every taste and need, great comunitiy, a lot of great books to learn language and frameworks, few great IDE’s…
As an experienced C++ programmer who moved to Java about 10 years ago, the only language feature I really miss is deterministic destructors. The ‘finally…’ clause has its place, but is a poor, inelegant substitute for destructors in a supposedly OO language.
C++ was an enjoyable technical challenge, but the simplicity of Java allows me to focus my attention more productively, on creative design rather than syntactical complexity.
However, I also agree that Java is becoming less simple, and more feature-bloated, to its considerable detriment. Backward compatibility is a millstone when it comes to implementing major new language features. Autoboxing looks cool, and is a reasonable attempt to fix the problem with primitives, but it has some nasty traps for the unwary. Generics are a nice addition in theory, but the chosen syntax, type erasure, and the lack of type defs make them ugly and less useful in practice. Annotations are wide-open to abuse and are already being abused, even, sadly, by Sun themselves. Closures sound attractive, but given the recent record on language ‘enhancements’, I have little confidence that they will be as elegant and flexible as they can be when designed into a language from the start.
Java seems to be trying too hard to be all things to all men, and desperately chasing C#, to no great advantage.
Having said all that, I’m rather fond of Java, but if you don’t like Java, or don’t feel it’s appropriate to the task at hand, use something else if you can. If you work commercially, you’ll find that individual preference and suitability to the task are often incidental to the choice of development language and tools…
To the dude who said most enterprises will use C# / .net instead, you don’t have a clue do you? Windows Server is not the OS du jour for enterprises..
So, maybe what we need is a way for C# to use Java libraries. This way, we can keep all our old code, and we can produce portable programs using a better language that already has a large body of users and significant corporate support.
Reply to pragmatist:
Yes, what I have written is my personal opinion. My point is that when there is a faster way to do things using lesser memory, and when you don’t require platform neutrality, why use Java? Some apps that I’ve seen, which are written in Java, ARE platform dependent. And, there is no intention to change it. Java is good for many things. Java Applets have made life easier for many. So have many applications that are written in Java. What I say is many of them could have been more efficient if written in other languages. I don’t agree that Java can be used for everything. Every problem has a set of languages in which it can be implemented efficiently. What I am saying is that for those apps where Java is not in the efficient list, Java should not be used.
And I agree that the speed of Swing is slow because it is not implemented at the OS level. But that is not the only reason. GTK also works on multiple platforms, but it is faster. Again, when you want to use the same application accross multiple platforms (without re compiling), GTK won’t work. But again, my question is when people write apps that work only in Windows (or only in Linux), why use Swing? Why not use SWT or AWT or C++ with GTK?
Reply to raveman.
Other than for using the Java application, I have NEVER felt that my computer is “unreal”. I’ve played GTA3 on my computer, and didn’t have a problem. I have run several webservers and a database server in parallel without feeling that the computer is slow. But load netbeans, and that’s it. And I have a real job in Java. Really.
Great article! Thanks for putting the development of java in the proper historical context. I agree about the compromises made in the choices of language features and that those choices clearly paid off.
I blame the “java sucks, my language is better” crowd for the feature bloat in java 7, for adding “so let’s jam all my favourite language features in java!”. Particularly since they missed a couple of items on my personal wishlist.
The other group to blame is the group that simply doesn’t like coding and can’t program (showing my age there – we used to call it “computer programming”, back in the 70s and 80s). I see their work all the time – everything is a third-party framework, or a macro for some processor, and what little code they do write is awful and betrays profound lack of knowledge of the java APIs.
In any case. The site I am at now is using Java 1.4.2 . As a working language, Java is a raging success. Anyone who denies it will find good company and a similar mental outlook among creationists.
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
Ad populum… didn’t you learned anything in logic course?