Thursday 18 September 2014

Why Java Ain't Bad

So this got horrendously delayed. Real Life™ caught up with me, among other things. The Internet has been worse than usual of late, which never helps things.

This is probably going to be a short one, I'll be saving game talk for next time.

Why ain't Java all that bad? Well, for that we have to start with "why does it have a bad reputation". The reasons for this are numerous, and several of them are well-founded.

1. Java was slow.

And it was - pre-1.4 and even worse prior to 1.2. We're currently on Java 1.7 (also known as Java 7), with Java 8 around the corner (admittedly, late).

However, it isn't that slow anymore. And, as usual, programming techniques factor into this. It's very easy to program something badly and blame the language (some would argue that's the main fault of PHP, *cough cough*. But I digress!).

2. Java was really slow.

Yes, we get it. However, to this day, this seems to be the number one argument against programming anything in Java. Which is odd, considering that the Android OS is built on Java, and more besides . . .

3. Java had no uses that can't be done better in something like C++.

Or more recently, C#. I'm finding it hard to have counterarguments against C# which in general seems to be a very nice language to work with.

Partially-correct. C++ can be blindingly fast if you optimise it well and get a dedicated C++ programmer to work on your project. However, this applies to anything. C++ in general is probably faster for low-level tech, like game engines or the like. Java, however, excels at web deployments due to the supported frameworks that pervade the web (Tomcat being a popular example).

4. Java was bad for graphics.

And so it was. But again, this isn't exactly the case anymore. The object-oriented approach of Java also lends itself well to designing graphical programs.

5. Java is closed-source so therefore it's bad!

Yeah, I've had this argument thrown at me before, and I'm still not sure what to make of it. Just leaving that there for posterity.

Basically, your mileage will ultimately vary. There are uses for Java, and there are uses for a lot of other programming languages out there. Even if Java was objectively better than C++ for developing a game engine (odds are it isn't, even if you call garbage collection manually to optimise your runtime performance) . . . you still have a team of engineers who're proficient in C++ and not necessarily Java (and while good programmers can adapt between languages, you still run that adaption cost during an ongoing project, or delay between two projects. Never ideal).

The point of this ramble is simply to say that Java isn't bad. Not anymore, and not for a long while. You can use it to make decent, complex applications. You can use it to power a suite of web services and the deployment is incredibly straightforward (I'd know, I've done it). You can make graphical applications, though your experience with 3D in Java may vary. Everything works as well as you program it to.

There is one exception, that I feel obliged to point out. Java's Swing library (the main UI library used for creating visual applications - javax.swing) is a moderate pain in the arse most of the time. The remainder of the time it's a collossal pain in the arse because as soon as you deviate one inch from the prescribed behaviour of the library, it gets really messy, really quick.

And that's not even counting the quirks and outstanding bugs that have never been fixed, some of which are simply because Oracle (the parent company) like having hissy fits at Microsoft. But then again, a lot of people have beef with MS (not me personally), so I shouldn't blame them for that.

Until next time!