5 Things to Love About Java
With the increased popularity of numerous light-weight, multi-purpose languages such as PHP or Ruby on Rails, many can be forgiven for asking the question
“What’s the future of Java on the Web?”
Are we witnessing the last days of Java running anything other than high-end bespoke solutions?
Are its days numbered as a general purpose language that is used to run anything from an e-commerce site to an on-line banking application?
The ‘Write once, run anywhere’ ethos that embodied its early days now seems relatively unimportant and, in many ways, diluted with the advent of Android and the Dalvik VM.
So, why still use it? What is its relevance and what remain its strengths?
Below I give 5 very good reasons to still use Java to build your on-line applications.
1. Type safety
What is type-safety? Put simply, type safety is a programming language feature that prevents you from performing operations on items held in memory that could have undesirable or unexpected results. Why is this important? I won’t go into detailed academic discussion here, as this has been more than adequately covered by lots of people way more geeky than me. But suffice it to say knowing that an object or method call will do what you expect and not have disastrous results or expose your system to attack, can only be a good thing, right?
2. Stack Traces
Stack traces are things of beauty. Yeah, I know, that’s totally geeky. But, truly, they are. The ability to trace back line-by-line to exactly where your error occurred and debug is an ability I just don’t know how we could live without. How many times have you felt that internal welling of relief when you get hold of the production server logs and see a stack trace thrown at the same time as the random 500 error you keep getting on the front-end?
From the very first days of Java 1.0 this struck me as a complete revelation. A language with documentation features built in? Why didn’t anyone think of this before? Yes, you can add comments to any old programming language, but to have these comments built into a full set of HTML API documentation is amazing. Of course, the documentation is still only as good as the comments that produce them, but that’s been a daily battle with most teams that I’ve worked with…
4. Open Source APIs
Although not, technically, Open Source itself (excepting OpenJDK) the Java community has long been one of the most active open source communities. I honestly can’t think of a single significant library or API that I use now or have used regularly in the past that wasn’t OpenSource.
This ethos of solving problems collectively and contributing your work back to the community for free, is one that has and always will ensure the popularity of Java.
I have come across nervousness and a reticence (mostly in large corporate clients) to use open source APIs. I honestly believe this to be unfounded. Any popular Java API that you’re likely to have come across will have been contributed to, commented on and refined by a community which some estimates suggest number as many as 10 million. Compare this to the average size of team for a commercial product – 10-20 developers maybe? I know which I’d have more confidence in.
5. Exception handling
Exception handling in Java is a truly a powerful feature. The ability to separate your code logic from error handling seems obvious, but it’s not until you see it in action that you appreciate how useful a feature it is. Java has a sophisticated exception handling mechanism built-in and the distinction between checked and unchecked exceptions makes for not only more robust systems but also allows the programmer to signal intent of their design to anyone who uses their code.