Effort and ease of reading
Thursday, March 31st, 2005Anyway, on to the point I am trying to make: programmming Python is a breeze, you can use any simple editor (preferrably with auto-indent) and happily code away. You can get serious stuff done this way, perhaps you’d need some way to handle multiple files in a nice way, but most graphical editors can do that.
Boy, is this different when you want to do serious programming in Java. You need to type lots more and need to make more of an effort before you can do interesting stuff.
All the typing you have to do to get things done, is inversely correlated to the ease of reading code. If you read Python, it doesn’t take very long to see what it means. This is partly because it is strict in using indentation as part of the syntax, but also because of the terseness of your commands.
This is very well illustrated in an example that Tim Bray mentioned in his blog. There he points at a website of a 16 year old kid from Norway who explained an amazing new idea to do Continuations on the Web (webpage seems to have been pushed offline, here’s the Google Cache version).
Imagine that that idea would be implemented in Java. Then it would a) be a lot more code and b) it would take more typing from him to explain what it does and c) it would take more energy for the reader to understand all this. Now I’m not saying that the fact that it is in Ruby makes it easy, but it sure makes it easier to read and understand.
And especially point c above makes you wonder why we’re bothering with Java anyway. Isn’t the whole idea about programming languages to make the computer do work for you?
Bit of background for this rant
Since about a year ago, I’ve been learning Python. But because I was developping stuff with webservices, I thought it might be nicer and easier to do in Java, also because the rest of the group here is developping in Java as well.
Learning Java all over again was interesting (last time I did anything with Java was in 1996 - 1997). Java 5.0 has interesting new stuff like generic programming, a foreach loop and introspection. Basically just stuff that every other programming language has, but Java has to make some effort to make it all work because of backward compatibility. I don’t mind this at all, it’s understandable and very commendable that they try to keep this much compatibility with the old versions.
Perhaps it’s my Python background, but lists are essential tools and making a list in Java is really really annoying. It’s better in Java 5.0, where you can do generic programming and write a generic list class, but my beloved Powerbook has 10.3.8 on it and there’s no Java 5.0 for it. We’ll just have to wait till Tiger comes along…
Another thing that bothers me about Java is that you need a good IDE for it if you want to reach the speed of development like with Python. Eclipse comes a long way (in fact there are plugins to use it for Python as well) and really helps with writing common things (accessors, constructors, etc). But the amount of typing you have to do is huge, especially compared to Python.