OT: What's wrong with Java-the-language

Robert Fraser fraserofthenight at gmail.com
Sun Oct 21 13:43:40 PDT 2007


Julio César Carrascal Urquijo Wrote:

> Java-the-vm is a great implementation and I expect with anticipation a 
> lot of useful languages to evolve on top of it, but Java-the-language 
> isn't really a great example of language design.

I agree that C# is probably a better-designed language (to a rather small extent) than Java, but I think the reason is "hindsight is 20/20". C# aimed basically to be a better version of Java, since the paradigms and ideas work well for large corporate codebases, and to that extent it worked. I've done very little C# coding, but I do remember appreciating closures (it's a shame D doesn't have them), and I never shed a tear for checked exceptions.

I don't agree, however, that "Java-the-language isn't really a great example of language design." For a large codebase, Java is a extremely well-designed language (despite its couple quirks), which is why it has been so successful, and continues to be so successful.

I think a lot of people with C/C++ backgrounds look at Java and cite the numerous problems with it, many of which can be wrapped up into the statement "It takes me two pages of code in Java to do what I can in one in C++" or "the performance sucks". The latter of those issues is mostly a non-issue, since if you're running a company running a large server-side software platform with 300 developers or designing a new cellular phone you want everyone to easily deploy applications on, the software engineering benefits of Java far outweigh the slight additional hardware costs.

The first point (that coding in C/C++ is easier than in Java) is a more interesting one, but I think it stems from this implicit assumption that Java is just C++ with all the low-level, complex, and cool stuff ripped out. However, I think Java is more like Smalltalk with C/C++ syntax forced onto it. You _can_ write Java like you would C++ and end up with a total mess (look at Descent fro a Java port of the DMD front-end... you'll see what I mean), but at it core, Java is meant to be written in a more object-oriented style than even C++, and the "objects-for-everything" idea actually works. It's just something you need to subscribe to pretty completely; if you're complaining about having to type "new" all over the place or the lack of free functions, you are not one with the zen of OO programming.

Of course, I'm a huge Smalltalk fan, and only actually worked to any great extent (more than a few smaller projects) in Java and Perl (the latter of which has scarred me permanently), so I may be a bit biased. In fact, even when I look at D, I'm looking at it from the perspective of a highly OO programming style.



More information about the Digitalmars-d mailing list