Tag Archives: Web frameworks

Why I choose Java

As programmers we have a bewildering amount of platforms and languages to choose from. Making such a choice is not always easy, yet it’s quite an important one. Many parts of your application can be refactored later, but language is not something you can (and should) change overnight.

So what are the viable options?

At first it matters to decide on what platform your app is going to run. For an iOS app it’s basicaly Objective-C, with C++ and pure C being options. For Android it’s Java, although with some Google flavors added.

For desktop apps there’s more choice. OS X is Objective-C again, Windows is mostly C#, while Linux favors C. On all those platforms, C++ is an option as well (combined with eg Qt) and surprisingly C# is an option too (via Mono). Java actually runs on the desktop too.

Serverside there’s quite some choice as well. Java is exceptionally strong here and C# is no baby either. C, Objective-C and C++ however are barely options here. There are some other choices here though, like Ruby and PHP.

Since my interest is primarily serverside, I focussed mainly on that area. After careful consideration I choose Java for my next project for the following reasons:

1. Java is on of the most popular programming languages in the world.

This becomes clear when looking at the Tiobe language index, jobs available on indeed.com or questions on stackoverflow. Java is often number one or very high ranked (on SO C# has more questions, but Java follows not far behind). This means there simply are a lot of resources available to the Java programmer. There are many books available, many conferences to go to, many articles to read and many jobs available. RoR may be a nice and influential framework, but Ruby simly doesn’t enjoy the popularity that Java does. Tiobe puts it in the 1% range, while Java sits in the 18% range.

2. Java is one of the fastest languages around.

The Debian language shootout consistently puts Java in the top tier of most performant languages. C and C++ do outperform it, but not by a very large margin. Dynamic languages like Ruby, PHP and Python perform much, much worse. On some benchmarks this is even 2 orders of magnitude worse.
For web applications it’s often the case that 90% of the time is spend in the database, so Java web applications are certainly not two orders of magnitude faster in general but it does allow web frameworks to do quite some extra work without any significant impact on performance.

3. Simple no-nonsense syntax.

Java has a simple syntax that’s relatively easy to learn. It’s in the C family, so Java knowledge easily transfers to a multitude of other languages. I actually liked C# a bit better here, but Java and C# are still relatively close and Java gets some syntax enhancements real soon (JDK 7, I love try-with-resources) and some more are on the way (JDK 8). The only thing I really disliked about the Java syntax is checked exceptions. It’s a personal thing maybe, but to me both the Ruby and Python syntax just look too weird. I tried them both but me and they just didn’t click.

4. Java is cross-platform

Java is available on many platforms and its binaries work everywhere with the exception of Android, which compiles binaries to another VM format (Dalvik). C# was mainly at a disadvantage here, as it’s very strongly tied to the MS platform. The language is available on Linux, but its ‘native’ library .NET certainly is not (at least not at a level suitable for production). C is actually available on much more platforms than Java, but binaries are completely not portable and even source code often contains many system specific things.

5. Java has an incredibly rich yet easy to use standard library.

The standard library of Java is incredibly rich. It contains many things for which most other languages need to resort to third party libraries. The C and C++ std libraries are both much smaller, and few non-trivial programs will be build using only this. I found here PHP to be at specific disadvantage, as its std library stroke me as being very sloppy and inconsistent. Objective-C and C# don’t really have std libraries, but have defacto ones (Cocoa resp. .NET).

Where Java really shines is in it’s std ‘extension’ library for the serverside: Java EE.

In its latest incarnation, Java EE 6, the power and simplicity this offers is amazing. It’s a full stack framework, meaning it covers most everything from the GUI to DB persistence and everything in between. The GUI is handled by a very ellegant component based web framework called JSF, which provides support for scopes and validation. Validation is handled via constraints that are placed on entity objects once and can be enforced by all layers of the application. Via special beans called EJB beans the framework handles transactions nearly completely transparently.

Especially the many blog postings written by Adam Bien made me see the power and simplicity of Java EE 6.

Well, that were my top 5 reasons for choosing Java. I wonder what your reasons are.

— John Waterwood

53 Comments

Filed under Java