Java is slow. And by slow I don't mean it's execution speed. I'm talking about development speed.

Java forces you to plan too much. Don't get me wrong, there's nothing inherently bad about planning. The problem is that innovation and planning don't always go hand-in-hand. When you're making yet another boring spreadsheet application that's been done a million times before, you can plan out exactly what needs to be done before writing code because you know exactly what you need However, when you're innovating you need to code as you go. Your ideas may just work, it might need some tweaking, or it may turn out to be horrible. The point is, you won't know until you start hacking away at the code.

Java is so verbose that in order to really work with it you need to plan ahead. You need to know what Objects you need to create, what methods and variables (private or public?) it should have, and how they need to interact with each other. Oh, and after all that you need to compile your code before seeing the result. As a simple demonstration of this, let's work with a JSON object in Java (using Gson), then in Python (using simplejson).

Let's use the following JSON object:

  'foo': {
    'bar': 10,
    'baz': 20
  'phrase': 'Hello World!',
  'myArray': [1, 2, 3, 4, 5]

Let's access some data in Java. Wait, first we need to create some Objects to deserialize the JSON string to.

class MyObj1 {
  private int bar;
  private int baz;
  MyObj1() {}

class MyObj2 {
  private MyObj1 foo;
  private String phrase;
  private int[] myArray;
  MyObj2() {}

Now we can deserialize the JSON string and get some properties from it.

String json = "{'foo': {'bar': 10, 'baz': 20}," +
      "'phrase': 'Hello World!'," +
    "'myArray': [1, 2, 3, 4, 5]}";
MyObj2 json = gson.fromJson(json, MyObj2 .class);

system.out.println(; //--> 10
system.out.println(json.phrase); //--> Hello World!
system.out.println(json.myArray[1]); //--> 2

Now let's try the same thing in Python.

import simplejson
json = simplejson.loads('{"foo": {"bar": 10,' +
    '"baz": 20}, "phrase": "Hello World!",' +
    '"myArray": [1, 2, 3, 4, 5]}')
print(json['foo']['bar']) #--> 10
print(json['phrase']) #-> Hello World!
print(json['myArray'][1]) #--> 2

By the way, the above python code is 100% executable using the interactive shell assuming simplejson is installed (easy_install simple-json). The Java code will need some main method with whatever else, I just didn't bother -- usually my IDE at work writes all the skeleton code for me.

So which do you think is simpler? If you knew you'll be dealing with a lot of JSON would you go with Python or Java? Another thing to keep in mind is that if I change the JSON string, the Python code would require virtually no effort, whereas the Java code will need class changes, recompiling, etc. Not to mention if I changed the array to something like ["I'm a string", 1234,  {"a": 1, "b": 2}, 3, 4, 5]. Sure you can do it in Java, but WHY? You can probably see why Java developers are forced into so many hour-long planning meetings. If you get the wrong the first time you really pay the price.

To be successful on the Web you need a platform that allows you to be innovative. Traditionally, software development involves a long period of planning before any code is written. You go through iterations of UML diagrams before typing a sinlge line of code. This just won't cut it on the Web.

Traditional software is like cartoon drawing. You usually start with some storyboard sketches of the overall story. This gives the artists a way to previsualize the motion graphic before starting on the real thing. Web applications, on the other hand, is more like a bunch of sketches that are never quite finished. That is, web applications are always evolving, and this evolution happens in smaller steps, and more frequently. You need a language that can allow you to take these smaller steps, and I don't believe Java is the right tool for this.

blog comments powered by Disqus