Friday, August 20, 2004

Why Java isn't cool : triggered by "Great Hackers"

Paul Graham's Great Hackers essay has really touched a lot of people's nerves. The wires are choked with people giving their point of view -

[stolen shamelessly from Erik's LinkBlog]
And of course, no one puts it quite like him whether you agree with him or not .

Yet again, though, I have had to stop and think - what is it about Java that makes people brand it as the most un-cool language on earth? I have had friends look at me like I was a poor sod for "having to" develop in Java. So, let me list all the reasons I can think why people consider Java un-cool.

Java has considerably fewer surprises and prefers not to add complexity to the language for rarely used features thereby resulting in a language where you cannot really make your friends go ga-ga at amazingly brief programming constructs. You need to write something substantial [like Gosling's Huckster] for them be to impressed with your programming abilities and not your language knowledge. This is probably the biggest reason Java is un-cool. It's too easy (although programming or software development remains as tough as ever).
Java was always touted as the language that the "average" IT programmer can use. It's such a language-for-the-masses that yet again, it fails the "geek" test. And if you use Java, so do you.

Java has been considered slow for ages. The earlier allegations (1995) were true. However, with the recent advancements in the JVMs from Sun and IBM, Java runs pretty close to C/C++. Check this benchmark. Contrary to this, there are other benchmarks that prove that Java is slower. All considered, it would be fair to say that Java cannot be considered "slow" anymore, yet its stuck with the label. How cool is to be the jock with the second fastest race-car in the block?

Swing disasters continue to give Java a bad name. Swing is a brilliant, although hard to learn, API. But the vast majority of Swing applications are so bad that they give Swing and therefore Java a bad name.

Java is a strongly typed language therefore you have to tell the compiler exactly what you intend to use. And if you make a mistake in the way you use it, the compiler has the guts to tell you that you were wrong. Too much chaperoning?

Java has a vast library that is available to all Java developers without any ambiguity. Thus, if you wrote yet another Map you would not be considered a data structures guru by Java programmers but a guy who hasn't heard of java.util.*.

Java did not have a good IDE that compared with MS Visual Studio. I think this one was true. I am not so sure it is any more with IntelliJ. The absence of good tools probably pushed away a lot of good programmers.

Java is popular. Anything that is popular has lost its elite status and therefore is not cool.

Java is an application programming platform. You cannot do cool things like device drivers and games, etc (until recently - but Java gaming is coming in a big way).

On a different note take a look at these two projects - I like the direction they are heading in.

13 comments:

Sachin said...

I was an ardent vim user for the longest time. However, the current breed of Java IDEs have so many Java oriented features that they allow one to be much much more productive using them. But there are some tasks that vim is just so vastly superior for, not to mention the fact that it wouldn't bog your system down.

Don't you think that vim is quite an amazing bundle of contradictions? At some level, the commands are quite un-intuitive and require a steep learning curve. Once you master them though, the application of the Composite pattern is so visible in the UI. You can club commands together and the way you expect it to work is the way it always works again and again. Matching that expectation is probably the best usability you can achieve, isnt it?

Sachin said...

Firstly, I really liked verbat's comments from a material and presentation point of view. Thanks.

I learnt of a few new things which I will go and explore. I would like to talk about a couple of things mentioned in the comment though.

> You don't need to add complexity to make a language nicer.
I completely agree. However, the fact remains that a lot of languages add a lot of syntactic sugar, and features that need reams of explanation while the users of such features are probably fewer and the increase in readability or non-verbosity (especially in the presence of good tools) much lesser than what is touted.

Java is a more verbose language. Brevity of expression was never a language design requirement (AFAIK).

>Java is a strongly typed language
I don't know about Nice. I'll try and find out. Thanks for pointing it out.

>Java has a vast library
Hmmmm...well, I was thinking of C users more than Python, etc. I haven't used Jakarata's Commons Collection but if the intro is anything to go by, it doesn't look like a replacement but more like a very neat augmentation to the facilities in the Java Collections.

>Java did not have a good IDE
This point is aimed more towards Windows developers who used C/C++ and found Java an irritating language because of the lack of tools support. For the earlier Unix programmers, shifting to Java would probably not have caused their tool set to change. If you are addicted to IntelliJ or Eclipse and are to change to a newer language without a similar IDE, you wouldn't be too thrilled about the drop in productivity.

>Java is an application programming platform
But it is one. The language, of course, doesn't restrict you from writing anything, but the platform is predominantly viewed as an application programming platform.

Anonymous said...

Here's what went through my mind reading the article:

1. "prefers not to add complexity to the language for rarely used features".

So adding integers to a vector and retrieving them is rare (yes, I do know about autoboxing and generics in the next version)? Example:
Vector v = new Vector();
v.addElement(new Integer(42));
...
System.out.println("Value: " + ((Integer)v.elementAt(0)).intValue());

That my friend is the main reason why I think Java is un-cool, it's too verbose. I don't know what easy means to you, but I don't consider it easy to quickly express my thoughts and ideas in Java, and that's the main reason I need a programming language.

---

2. "with the recent advancements in the JVMs from Sun and IBM, Java runs pretty close to C/C++".

And then you link to a benchmark which compares the numerical performance of Java. Integers in Java are *not* objects, so they will not involve any dynamic dispatch, memory allocation (thus garbage collection) a.s.o. (which is really what sets Java apart from e.g. C, other than the byte code of course).

So even though your Ackerman is almost as fast as pure C, it still takes minutes to start up Tomcat, my browser still freezes when I need to use my (Java powered) web bank applet, and Eclipse is still too slow for my taste on a 733 MHz G4.

---

3. "Swing is a brilliant, although hard to learn".

I really do not agree that Swing is brilliant, and I doubt I'm alone with this opinion. Anyway, wasn't Java just too easy? Isn't the GUI framework a quite essential part of Java if you want to write applications?

---

4. "Java is a strongly typed [...] Too much chaperoning?"

Take the initial example I gave, here I need to cast the result from the vector to an integer object, so in case the object in the vector wasn't an integer, I would get a run-time exception. So what happened to compile-time type checking? Java really takes the worst from both worlds (of dynamic and static typing) and add further disadvantages to this.

And as two other comments have pointed out, there are better solutions to the problem Java tries to solve.

---

5. "Java has a vast library [...] you would not be considered a data structures guru"

Most of the cool languages are cool because they have a vast library, so this point makes no sense. I would also argue that when it comes to data structures, Java's vast library of data structures (and algorithms?) is rather primitive in use compared to the Standard C++ Library.

---

6. "Java did not have a good IDE"

As with a previous point, neither do most of the cool languages. And Java has had good IDEs for years now.

---

7. "Java is popular"

This statement also makes little sense. How can something be un-cool and popular? Or cool and unpopular?

And please remember, we are talking about a toolset to get the job done, not popular culture, so I doubt anyone would change programming language, just because it became popular.

Also, it seems that you are really comparing Java to ANSI-C, I do not think ANSI-C is cool these days! ;)

---

8. "You cannot do cool things like device drivers and games"

Can you do that in any of the cool languages?

---

I think your article would have been more interesting if you instead tried to highlight why Java ought to be among the cool languages!

--
Allan Odgaard
http://macromates.com/

Anonymous said...

From: Jeremy Geelan, Editor-in-Chief, SYS-CON.com
To: Sachin Hejip

Sachin, would you have any objection to our republishing a rdacted version of this blog at http://sys-con.com/java? We'd add your name as the byline obviously, and would need to add a brief bio.

We try and do this from time to time, to increase the number of reads that an intriguing posting like this might receivein the wider Java community.

Most recent example:
http://sys-con.com/story/?storyid=46010&DE=1
Java 5.0 - Tiger: A Classic printf Snippet from the Past
(2000+ reads)

Let me know yes? Thank u sir! :)

Jeremy Geelan
jeremy@sys-con.com
http://www.sys-con.com

Siddhi said...

I think the number one reason that many people find Java irritating is the verbosity.

The example given in one of the previous posts about storing an integer in a collection is a good example. Why something like an int is not a first class object completely eludes me.

Another example is checked exception hell. How many times do we come across code that throws a huge number of checked exceptions ? I'm slowly moving into the camp that prefers Unchecked exceptions combined with better unit testing to uncover flaws.

On the whole, I do think that as long as you stick with Java, the whole irritation of Java is not obvious. Its only when you program for a suitable period of time in a language like Python (my favourite) do the issues in Java stand out. Thats not to say that Python (or Ruby or Haskell or whatever) is a perfect language, and after trying out both, if you still feel that you prefer Java, then thats great. However, I really do feel, that after trying out something like Python for an extended period of time, its hard to go back to Java (or at least that has been the case for me).

That said, I do not really agree with Paul Graham either. While I do have my preference for Python over Java, his claim that all great programmers hate Java is completely wrong. I know lots of really good Java programmers/hackers. In the end, its the programmer who matters, not the programming language, and a good programmer can manage in any language.

Anonymous said...

And I have found myself getting more and more fond of checked exceptions with time. In most cases, only code somewhat near the problem can fix it in a decent way, and thus exceptions do need to be handled or passed up. If you choose to defer to the caller, then the caller needs to know that they are on the hook for handling whatever problem you did not catch.

Scott

Siddhi said...

Well, amazon.com was done entirely in Perl, Zope (www.zope.org) is a good example of a huge application done entirely in python. Paul Graham's Yahoo Store was completely Lisp. The apps can be done, its just that many people cant get their head around the fact that these are 'script languages' and not 'real languages' like C or Java, when in fact they are as powerful as any of the real languages around.

Sometimes I feel that these essays by people like Paul Graham are a response to people who look down (unfairly IMHO) on so called script languages.

Siddhi said...

Ouch... sorry for the multiple posts. blogger was giving an out of memory error, so I ended up trying a few times and I'm not able to delete the duplicates for some reason. so sorry again.

Sachin said...

Jeremy posted it here on sys-con where it has received some interesting feedback.

Thanks Jeremy.

Sachin said...

My reply to the sys-con feedback...


Got to thank all of you for taking the time to read this. I want to reply to a couple of powerful arguments in some of the recent posts. I am replying to Devin's post but the reply applies to similar arguments.

>Did you bother to consult the people that actually consider Java to be un-cool, or did you think of all these reasons yourself?
Some are based on experiences and interactions with people - but truly do you think that it is not possible to come up with this list by reading various blogs on the topic. Some that didn't make it to the list - checked exceptions, brevity, frameworks.

>What languages (aside from Perl) add complexity for rarely used programming constructs?
I can think of C++ which has quite a few features which Java decided to take a step back from and not incorporate thereby leaving the language much easier. I can definitely identify with some other person who commented on here about this point.

Brevity was never supposed to be a Java language feature. Besides, brevity is probably overrated. Java is not that verbose a language nor that brief. Trying to achieve brevity in a language usually results in a very private syntax. A program written in Java can be understood quite easily by a Python programmer (with a grimace for the Java syntax but he can all the same :-) ). Can you say the same the other way around? The more the ways to do something, the more is the learning required for the language especially in a team when other people use syntax you aren't familiar with. What is often lost is that for commercial grade programming (read : large software projects involving huge teams perhaps geographically distributed) there are certain other tenets that are as important and Java seems to consider them however at the expense of the "coolness" factor.

>''Brilliant'' and ''hard to learn'' are nearly antonyms when used to describe an API.
I agree, it does seem paradoxical. Probably "powerful" might be more appropriate but I can hear more snickers ;-). I really do think Swing is extremely well designed. It is also a textbook example of OO Design. I can also critique it on several points. But thats not the point here. The point is that badly implemented Swing programs give Java, the platform, a bad name. I am sure you have seen IntelliJ and SmartCVS as examples of good Swing programs.

>Any good programmer will appreciate compiler warnings and errors if they''re available.
Actually, interestingly you can really have too much of a good thing. The rather pedagogical error messages in Jikes come to mind. :-). But really, haven't we heard enough about Java's strong typing getting in the way of several "expressive" people? That's what I had in mind when I wrote this. Anyway, the arguments against this are endless. In my opinion, what I get out of strong typing is a much better compiler and much lesser bugs in code especiialy while developing and maintaining extremely large software projects. I agree with Joel on this --quote--Today, when you have a strongly typed language, a good type library (IDL, WSDL, Java reflection) documenting your classes, and an IDE that knows how to show you that type library as you code (i.e. Intellisense), it's even easier to use types than variants, so the trend is away from variant-bound scripting languages (VBScript, PHP, perl) towards typed code (C#, JSP).--quote-- Also check the discussion of this topic here where this comment appears --quote--I develope (a) very large (2.5MB of source code) PHP application(s). The lack of strong typing is a benefit to small programs but a hinderance to large programs...Type errors occur regularily in PHP programs; they are raised by function library calls. Performing an array_pop() operation on string will cause an error. All you know is that on line 254 in file x $var should be an array and not a string. Unfortunately, in a large program that is rarely good information.--quote--

>An elegant programming language can be used without a complicated IDE. What does the fact that there are so many different Java IDE''s tell you about Java?
Hmmm...I said good not complicated. The lack of an IDE for a language probably reflects on the lack of good tools. You can't tell me that other language communties cannot think of any innovations to put into their tool sets. I don't think the presence of quality tools tells anything about Java. My point was that, initially, the lack of tools put off several Windows C and C++ programmers who were used to the excellent tools offering from Microsoft.

>Java is widespread because of Sun marketing hype. Windows is popular too.
I am terrible - I like them both :-). Again, the point is that your neighbour and her sister are all programming in Java. You don't get any exclusivity points for programming in it too. Someone mentioned haskell. I don't know what it is but it does pique my interest.

>I believe you''ve missed the point entirely.
Maybe. And I like your points - very forceful. Thanks for your opinions.

Unfortunately, some others have not understood my point - but most have. The point I was making was to list the top reasons why Java will probably never be called a "cool" language. "Cool" is probably too common a term but it seems to fit the sentiment I was looking to describe.


Kameron Cole said :
First, programming, programmers, and programming languages are not cool - never have been, never will be. I think that point was missed...I wish the article had chosen words like "well-designed", "parsimonious", etc.

Agreed :-) Lets say the domain was the bunch of programmers who do consider programming languages cool, not the whole society in general. We would never cut it out there!


Personally, I quite like Java. I love the platform and I believe that Sun has done a very good job with it. It is far from perfect but it has delivered on several promises (biggest being WORA) especially at the time that it came out.

Siddhi said...

First one myth to debunk -

Mega Myth #1 - Java is more portable (write once run anywhere). Wrong!! Java is portable provided you have a JVM for the platform. Python is also equally portable provided you have the Python interpreter on the platform. Considering that most major platforms have both JVM's and Python interpreters, I would say that Python is as much of "write once run anywhere" as Java.

I've noticed that who mention portability, garbage collection, array bounds checking, no #ifdef problems, they are comparing Java against C/C++, while the point in question is compating Java against scripting languages. Python has all these features and more.

Now, these are the reasons why I prefer Python to Java -

Readability. Python syntax is much easier to read than Java.

Brevity. Python syntax is short and to the point. Java is verbosity times ten.

Adaptation to programming style. Want to do structured programming ? You can. Object oriented ? Sure. Need elements of functional programming ? Its there.

Example to illustrate the point -

list = [1 2 3 4 5] # create a list of 5 elements
hash["mykey"] = value # create a hash
listoflists = [[1 2] [3 4] [5 6]] # create a list of lists

# print all items in listoflists

for aList in listoflists:
for item in aList:
print item

Try creating lists like this and iterating through list of lists with Vectors and Iterators in Java and see how long and complicated it gets (Not to mention having to wrap int in Integer, and the huge number of casts to put stuff in and out of containers).

(Also see - http://www.ferg.org/projects/python_java_side-by-side.html)

Siddharta

Anonymous said...

So you say: If I have a python virtual machine for each platform I can create rich UIs, have industrial-strength security, can deploy to application servers, create web applications etc.?

Wow. I thought this would only be possible with Java.
Or do you mean Jython?

feedJoint said...

Top reasons why people think Java Debunked