When I next saw the master he was on a new health kick, gone was the pipe and the toffee tobbaco and in was the low fat food and exercise. He still managed to fix me with a rheumy eye though.

Grasshopper, it’s been a long time, many heads have passed under the surgeon’s knife since we last talked. What have you been doing, my young friend?

I swallowed hard and tried to look him in the eye.

I’ve been using Java, master.

Java? You’ve been using Java, eh? Have you learned nothing?He was not far from incandescent with rage, I had expected this.

I interjected – I need to earn a living, master, and Java pays the bills.

So? Grasshopper, my young friend, don’t you realise Java is the new ‘C’?

Master, master, it has no pointers. How can it be the new ‘C’?

Well, now, well now – remember how everything was a 16-bit integer?

Yes, master, then it became 32 and then 64 …

But still, an integer?

Yes, master.

In Java – everything is a String, immutable, heavy, can’t be extended. A string.

I tried to interrupt. Master – surely everything is an object?

Only sometimes, even then … what is XML? Long strings, what is a properties file – a bunch of strings – what do you spend all day doing? Throwing strings around – In your JSP’s and anything else – Strings. He shuddered. I have nightmares about them.

Master, what is wrong with strings?

They are not a type, but a class. They should have been a type, or everything should have been a class. When you write code you’d like to just use strings and not have to worry about the rules, the way you can use an integer or a float. It’s that, if I was designing a language from the ground up, I wouldn’t mess with such petty distinctions. AND, Grasshopper, AND strings are final, which means you can’t add to them, or you have to wrap them in another class of your own. They were afraid of security issues where people override certain methods and put in malicious code. They could have just made the standard methods final, but that would have been too easy.

He paused and drew breath, I wiped the spittle off my coat.

… and they’re immutable – so they consume loads of memory when you manipulate them and people don’t realise. The documentation says use the StringBuffer class, because it is mutable, but there are hardly any decent examples showing how to do this, and if you want to call a standard libarary function (or SAX or whatever you like) with StringBuffer – you need to call toString – which makes it all a bit pointless. And that lovely syntactic sugar using + to manipulate strings doesn’t work with StringBuffer – gah! Rubbish! Time-wasting rubbish.

Not to mention – he was flying now, eyes almost popping out of his head – why does Java have a char type and a string type. What nonsense is that? Why does it have any of the other types – the bytes, shorts and all that rubbish inherited from ‘C’? Why would you ever want a short integer? Running out of memory? On a modern machine with modern amounts of memory? They force you to learn all that irrelevant crap to get certified – I’ve only ever had use for ints and strings – maybe Java is slightly better, maybe it has two things to play with rather than one.

He started musing to himself. Singing ints and strings to the tune of Police and Thieves, although I’ve never seen either scare a nation with their guns and ammunition.

Java is also very low-level, that ancient crusty ‘C’ way of doing things, no sugar that can be efficiently compiled. You have to keep typing the same array walking constructs in again and again. There isn’t any syntatic sugar for things like lists and dictionaries and walking arrays of objects. Oh, yes, there are classes that support them, but no syntax. In a usable langage like python I can say something like

[mapping-expression for element in source-list if filter-expression]

This will give me a portion of a list depending upon the if statement. PHP has similar ideas (although not as condensed). Python will let me split lists, look at them from the end etc. etc. and it also has dictionaries and syntax for them as a base type. Java gives me 200 different implementations of the dictionary interface – why should I have to care? Blinkin’ computer scientists, too clever by half.

The fire was really glowing in his eyes now. I was beginning to worry about ever getting my coat dry again.

And I still hate {} to delimit blocks of code; if should have end if, loop should have end loop, there’s a whole class of stupid errors that can’t happen if you do this. Again, Python uses indentation to do this – so it’s clear what goes where.

To me this is a flaw with PHP, in that it has too much ‘C’ heritage but its way of doing class- and instance- variables is vastly superior to Java:

self::$var ; // This is a class variable
$this->var // This is an instance variable

To use a global in a function you have to declare it

global $var ;

In the method that you want to use it in. The syntax is a little clunky but at least you can tell these kinds of variable apart, a whole class of bugs never appears. And the object stuff in PHP and Python is optional, you don’t have to worry about it if you just want to write a quick script to get something done.

I sighed and said, would you like me to make some tea, master? It was going to be a long day.

More from the master