Friday, 26 January 2001

Garfinkel on Java

Listening to:

Count Basie, April in Paris. This is a neat album, but the publishers have padded the original LP with material that is “previously unissued”. In this case all of the padding is different recordings of the same material that makes up the original. I’d much rather hear stuff that really was new. They could combine two LPs into one CD for example.

A lost comic:

Doonesbury. This is unashamedly a “topical” strip, which means that it features politics and scary stuff like that. The politicians are mocked, which is all they deserve, and there are also stories about things like starting up a .com company, and then crashing and burning. On the web, every strip is now in colour. One somewhat unusual feature of the strip is that every so often (maybe while the author has a holiday), the strips repeat some much earlier sequence for a short while (maybe just a week). For example, the genesis of myVulture.com sequence, which happened last year, happened again this month.

More annoying science writing. This piece is by Simson Garfinkel, whose stuff I usually enjoy reading. He’s writing all about Java, and decrying it as a bad language. He first attacks it by claiming that it is a language that is ugly, hard to read and that requires an inordinate amount of typing because of a variety of pedagogical restrictions imposed by Java’s creators. Of course, beauty is in the eye of the beholder, but note the additional swipe at it by associating it with (obviously useless) pedagogy. (See this technical report on how Java is in fact ill-suited for teaching.) Nor is it clear exactly what he means. I don’t think Java programs are particularly verbose compared to its most obvious rival, C++. But his writing makes it impossible to really assess his criticism because he's being so vague.

Next he talks about Java’s “first Big Lie” (that it can run as fast as C or C++). He says it’s clear that a well-written program in Java could never run as fast as a well-written program in C or C++. Of course, this ignores the important issue of which of Java or C/C++ helps programmers to produce their well-written programs faster, but let’s just assess his reasons for his claim. He says it’s because Java bytecode is interpreted, not compiled. This totally ignores two important developments since Java first appeared, and confuses a language’s implementation with its specification. Most JVMs these days use a technique called “Just-in-time” compilation that, shock, horror, produces compiled code when the bytecode is to be run. So, even if you stick with the JVM, you can achieve compiled-code speeds. Secondly, people are not required to compile Java to bytecode. In fact, they can compile directly to machine instructions. There's such a compiler available for free as part of the GCC project.

Garfinkel reckons that Java’s second Big Lie is that it isn’t really as portable as it claims, and that portability isn’t really that important, because, all the world’s a PC running Windows. (Check out the 10th C Programmer’s commandment.) Java is a lot more portable than C.

Finally, let me say that I am not a Java zealot. I dislike it for a variety of reasons, am not particularly impressed by object-orientation, and think that the C++ language (not just the implementation) is better in some ways (the presence of const and template, for example).

Comments