June 28, 2002
The case for static types

The case for static types at developerWorks is an interesting counterpoint to Cameron Laird and Kathryn Soraiz's article.

I'm beginning to think that the thing that I dislike most about Java is not the static typing. I think it is mainly down to the fact that you cannot override the built-in operators ('+', '-' and so forth).

This, combined with the fact that the common data structures (Vectors, Hashtables and so on) are not built-ins, but come as part of the standard library. It seems to me that 80% plus of my code involves these data structures. Due to the fact that every operation requires an explicit method call, the code is very verbose. They don't call Java 'Object Oriented COBOL' for nothing!

In Python (You knew I was going to get on to Python, didn't you!) you can override operators, and high level data strictures are built-in. So you can iterate through any sequence with a simple:

for item in sequence:

Lists and files are both sequences, so both can be iterated with this syntax. And because you can override operators, you can make sequences of your own simply by overriding a couple of methods, and then process them with this syntax. Beautiful.

Posted to Java by Simon Brunning at June 28, 2002 11:50 AM
Post a comment

Email Address:



Remember info?