header image
What I don’t miss about Java
July 26th, 2010 under Devel, rengolin, Software. [ Comments: 5 ]

Disclaimer: This is not a rant

I spent my last year working with Java, and it was not at all bad. But while Java has its moments and shines, I always felt a bit out of place when using it. In fact, when I moved back to C++, contrary to when I moved to Java, I felt that I actually wasn’t missing much…

Last year, while writing in Java at work, I felt compelled more often than usual to write C++ programs at home. Even simple programs, that would do better with scripting languages, they all came in C++.

Recently, working full time with C++, I noticed I’m doing very little home development and definitely not doing any Java. So, what did I miss about C++ that I don’t miss about Java?

Expressiveness: While functional languages are much more expressive than C++, there are few languages less expressive than Java. Java encourages child-like programming like forcing to call everything by methods not operators. By not having explicit pointers, operator overload and other dangerous things from C++, you end up repeating yourself quite a lot and it’s very hard to understand the logic afterwards, when all you have is bloatware.

While Java designers tried to avoid pointers and operators, they couldn’t. We still have null references (throwing null pointer exceptions) and the fake operators (like toString(), hash(), compare()) that can easily be overridden to change the expected behaviour pretty much the same way as C++ operators, but in the “method” notation.

In the end, you can do some bad things, but not all. So, they took away dangers by taking away functionality, without a proper redesign of C++.

Abuse of Object Orientation: While in Ruby, everything is an object, in Java, almost everything can be. Every class derive from Object silently, but base types do not. So you have the basic objects (Integer et al) which get automatically converted into basic types in subtle ways it’s hard to predict and has a huge performance impact (see auto-boxing).

Not just performance, but the language design is, again, incomplete.

Most OO programmers (mainly Java ones) complain a lot about Perl OO. They say Perl (or Python for that matter) has no proper OO, since everything is a hash and there is no concept of protection.

While Java objects and members are strongly typed, and you have the concept of protection, it’s way too easy to transform Java OO into Perl OO with reflection.

Of course, with C++ you can cast things to void pointers, mess up in the memory and so on, but getting objects by name, removing the private protection in a safe way is simply wrong. It’s like giving loaded guns to children and telling them where the lock is.

Abuse of Design Patterns: Java developers are encourage to use design patterns, to the point of stupidity. The first thing I learnt from design patterns is that their misuse is actually an anti-pattern.

Properties are important when the requirements change too often, not when they’re static. Factories are used when the objects created may differ or be customized, not for never-changing one-object construction. Still, most libraries (all?) will have Factories, Properties and so on, just for the sake of Design Patterns Compliance ™.

Fact, one of the strengths of Java development is that every one is encouraged to do things the same way. No Larry Wall style, all factory workers, doing their share in the big picture. While this is good for big, quick projects on companies with high turn-over (like consultancy companies), it’s horrible for start-ups or more creative development.

Half-implemented features: Well, templates is an issue. There is no template mechanism in Java. With the so-called Generics (like cheap version of meds), there is no type safety at all, it’s just syntax sugar for lists of Objects.

That generates a lot of misunderstandings and bad code being generated when the syntax is obviously correct, that is, if the types were actually being checked.

Again, incomplete design for the sake of backward compatibility with old codes and VMs.

Performance: Running in a JVM is already a bad start for performance, but a good compiler and a well done JIT environment can take most of it away by intelligently removing unused code, re-optimizing most used code during run-time and using profiling results to change branch-prediction code.

While the JVM does some of it, it also introduces several problems that take away the advantage and put it back on the back of the class. Auto-boxing and generics create a lot of useless casts, that can be a huge performance hit. Very few Java programmers really care about it and the compiler doesn’t do a good job in reducing that impact or even warning the programmer.

I often see Java developer scorn at performance issues. The phrase used most is “a programmer shouldn’t care about memory footprint or performance, only about business logic”. That, together with the fact that almost all universities now are teaching Java in undergraduate courses, kinda frightens me a bit.

Strong dependency on IDEs: Borland made quite a lot of money out of C++ IDEs in the 90’s, but most C++ programmers I know still use VIM or Emacs. On the other hand, every Java programmer I know use Eclipse, IntelliJ or something of the sort.

This is not just ease of use (code completion, syntax colouring, hints, navigation), it’s all about speeding up the development process by taking away boiler-plate code generation and refactoring.

IDEs are capable of writing complete pieces of code, refactor and re-write things (even behind your back). The programmers don’t care about it, the code becomes bloated, unintelligible and forgotten. Not to mention the desire of IDEs and people following IDE-style to use certain patterns for everything, like using Properties where simple structures would suffice. (see above, Abuse of Design-Patterns).

False Guarantees: The big selling point of Java, besides cheap cross-platform development, is it’s apparent safety and ease of use. But it isn’t in so many levels…

The abuses and problems related above are only part of the story. The garbage collector is another…

Some good garbage collection routines can help the initial development of programs, and they do take away the job of the lazy programmers to manage their own memory, but the Java garbage collection became a beast, with incomprehensible command-line options, undefined behaviour and total lack of control over it. You’re rendered hostage to its desires.

Not to mention the complete memory management that won’t cope with dynamic memory allocation. I mean, if you want to make memory management easy for programmers (as they went to all that trouble for a garbage collection), you could have gone a bit further and actually figured out the available memory and used it politely.

Join those with the fact that pointers and operators are still available, and you have a language that is not so much simpler than C++, with a huge price in performance and weirdness.

Undocumented APIs: Java claims to be platform independent, but has quite a few available (but undocumented) APIs to use platforms specific functionality (like signals). Still, Sun (now Oracle) reserves the right to change whenever they wish and there’s little you (or anyone) can do about it.

And that takes us to the final point:

Standards (or lack thereof): Sun did a nice job at many things (mostly hardware and OS), but they screwed up neatly when it came to support software. There is no standard, IBM and even Microsoft created their own JVM (which was better than Sun’s, btw) without any final definition about the standard API. During the Java 1.1 days, it was possible to be platform agnostic but VM specific in the same platform!

Conclusion: Java was meant to be an easy language, but it turns out that it’s deceitful enough to be just as bad as any other. And recent changes are making it worse.

Programmers are loosing the ability to understand how the machine works, how their languages behave and, more importantly, to know the implications of their actions.

Why spend time understanding the fiddlings some people had with Java if you can spend the same time understanding how the machines actually work and therefore be able to use any programming language you want?

Some argue that Java is the new Cobol and will disappear the same way… I tend to agree…

Prisoner of War
July 8th, 2010 under rengolin, Stories. [ Comments: none ]

Gorik was a methodical prisoner. Every morning, precisely at 6 o’clock, he’d wake up, wash his face and prepare for the morning food rations. After eating and tidying his bed, he’d go outside for the sun bath.

His schedule wasn’t particularly full, but he had some tasks he liked to do. Washing the court, preparing dinner, helping people in the library and most of all, teaching mathematics to the children. He was not a great mathematician, but among the prisoners, he was the most gifted.

Although his race was known to be violent, and many others tried to escape prison, he was a peaceful man. Not once he tried or even hinted to escape, nor he participated in the few mass escapes that happened since they’re all imprisoned. As with most prisoners of war, they weren’t criminals or had done anything more terrible than those that had imprisoned them, they just were unlucky enough to be on the loosing side of a major war.

Violent or not, their race was proud of what they achieved and were no more destructive than their enemies, nor they actually started the fight. But that doesn’t concern us now, the important matter now is that Gorik was not in his cell at 6 o’clock this morning to get his rations.

The janitor’s face had but one tear rolling down his cheek. The key in his hand opening a door that didn’t need opening. Pointless exercise but he continued, by force of habit, if nothing else. He was definitely not there.

Others were coming to see, but the sense of nothing was global. There wasn’t a single man, on either side, with his mouth closed. Some were dripping, what could be more tears, or saliva. It didn’t matter any more. He was not there at all.

No alarm was sound, no one ran. There was nothing to do. There were no broken doors, no knocked-down guards, no bribes paid (or no one said so), nor any camera caught anything convincing. He vanished.

Life continued in the prison. There was no one to help with the dinner today, or anyone to help the children in their assignments. It was not the same without him. Where did he go? And why now? There must have been something really serious to take him that sudden, and silently. He just left.

Two days later, when the janitor had the courage to enter his cell to clean it up, he noticed a letter on the bed. Nothing special, just a letter half-inserted back into the light brown envelope. The writing on the envelope was a bit wobbly, like children writing. It was addressed to him personally, and being only a letter, there was no point in not delivering it to him.

He was not there any more, and he left the letter in plain sight. That unofficially gives one the right to read it, I guess. Well, the janitor agreed, and opened the letter. It was from Gorik’s wife.

She was also a prisoner, but ever since the war was over, women and children got moved to a more decent accommodation, where the children could learn how much better was life on the other side and interact with the children on this side, and forget about their horrible and violent past.

The note said: “Dear Gorik, I’m not feeling well lately and Juma is a fine woman already. She’s left with a good boy and I’m afraid I’ll be alone for the rest of my days. I sincerely hope you are in better company than I am. Love, your wife.”

The next day, the prison manager went personally to the apartments she was living, and asking around learnt that nobody saw Gorik since the end of the war, but his wife had not showed up for a few days, also.

He took the note from his pocket, in which his secretary had written the block and apartment number. After a few minutes walking in circles, he managed to find the block and the correct door, which was half-open.

Knocked once. No answer. Twice. Nothing. The manager peered into the room by the two centimetres available, but all he could see was that the TV was on. Feeling a bit guilty for doing so, even for a prison manager, he opened the door a bit and found no one in the living room. A few steps inside, a door to the left. Empty bathroom. Another door to the right, empty room. Down the small corridor, there was a door, completely open and letting the sun, that was shining on the other side of the building, come through with all its might.

Barely visible among the flood of light, a pair of feet. No, actually, two pairs. Curiosity was not in the manager’s list of sins, but he could no longer wait. Sweating and his heart pumping, he crossed the room, just to find two people lying down on the bed. Calm as summer night.


Creative Commons License
We Support



National Autistic Society

Royal Society for the Prevention of Cruelty to Animals


End Software Patents

See Also

The information in this weblog is provided “AS IS” with no warranties, and confers no rights.

This weblog does not represent the thoughts, intentions, plans or strategies of our employers. It is solely our opinion.

Feel free to challenge and disagree, and do not take any of it personally. It is not intended to harm or offend.

We will easily back down on our strong opinions by presentation of facts and proofs, not beliefs or myths. Be sensible.

Recent Posts