The Language Series : Java
Java! The language I once loved so passionately that I saw other languages as being inferior. Now, I rarely use it – the last time was while writing an Android app early last year.
My Java Story
I had been learning C++ and finding OOP quite difficult. When the new academic session began, I had to take my a programming language course in Java and I had no compunction whatsoever dropping my half-baked C++ for Java. I soon grew to like Java; in fact to me, it was the best language ever – and that’s not surprising given my level of developer expertise back then.
Not surprisingly, I had to relegate Java for PHP – well, circumstances dictated this and I had to make it my second-choice – however that’s the PHP story.
Java – the good
- Java is everywhere: here, there, beyond and yonder. Windows, Linux, Mobile devices, Servers, devices etc.
- Lots of libraries – GUIs, Threading, Databases, Numerical computation, engines etc.
- The Java Virtual Machine protects you from serious damage; moreover it can execute bytecode produced by a lot of languages e.g. Scala (better Java), Groovy, Clojure (Lisp dialect).
- Grammar is similar to the C/C++ family.
- JIT compilers are quite efficient now and Java code compares favourably with C/C++.
- Auto garbage collection, Memory management and Interfaces are cool; some believe these features spoil programmers.
- Huge industry support.
Java – the bad
- Verbose; it lacks expressiveness – a gazillion lines are needed to do simple stuff.
- The == operator works differently on primitives and objects.
- Some serious issues with the Date classes.
- UI interfaces (well, the ones I know and have used) don’t look too good.
- Issues with numbers – floating point issues, huge integers; libraries exist though.
- No way to return multiple values from a method; maybe an object or array? This affects C too.
- The JVM doesn’t support tail-call optimization for recursive operations.
Java – the in-between
- Java’s is not purely OOP; it’s more of a mix.
- Does not support first-class functions; yeah, I know Java is OOP but what about C# which has this? OOP is no silver bullet; other approaches work better at times.
- Reflection – can be a double-edged sword.
Writing Code in Java
Cool; you’ll most probably end up writing bad code Well, initially; (I did too)
Over time, you’ll learn the culture of the language, how to use stuff and how to produce real awesome software. (Hopefully)
Check out this article for some weirdness
Good for beginners?
I think lots of people start out with Java or make the switch at some point. It probably is the first attempt at OOP for lots of people. It is weak in interactivity (it’s a compiled language) and this can hinder rapid prototyping prevalent during learning.
However, Java has some strong points – increased programmer productivity and code portability – it’s worth a try.
The language has somewhat come to represent OOP even though it is not a pure OOP language. It has lots of libraries, is fairly easy to use and has huge industry support.