Until recently, I was a staunch believer in Java; of course, not without reasons. Here is a short list of things I found useful & convenient. Note that this list is as per my expectations as a naïve & novice programmer.
- Strong type system meant that I know what is in hand. This resulted in eliminating quite a lot of errors at compile time.
- No pointers. This was kind of a shock for me. I had always appreciated the ability to store links especially when it comes to data structures. Once I figured out the trick to live without pointers life was much easier. One more source of errors is eliminated from my code. No more debugging segfaults.
- Strong exception system let me anticipate errors and handle them gracefully.
- A rather well defined OOP. List all advantages of OOP here. Java did a little *cleanup* of C++. Confusions and those that hamper readability of code like operator overloading and multiple inheritance were removed.
- Other strong advantages. A great set of library, platform independence, strong IDE support (of course the above points played a major role here)…etc.
But as you approach “I know what I’m doing” these advantages would rather become sources of frustration. Code would be verbose than required; you feel strangled by the type system and exception system; you would find yourself having to learning a lot of best practises, industry standards, design patterns …etc. to overcome the inherent deficiencies of the language. There are two routes from here
- Religiously believe Java (also name x, y and z which are in the same domain as Java) as the best language out there and never realise that you are indeed at a disadvantage.
- Learn a more powerful language; a lisp preferably or a modern language like Scala, Erlang or Groovy.
I was introduced to Erlang and Clojure quite a long time ago. But I was in (i). This coupled with the inertia (a fancy term for laziness), resistance to change and the lack of a place to apply my learning meant that I never took that up. If you are in an established company it is highly likely that you could never introduce a new technology. This is definitely not a bad thing. Of course, every company runs for profit and they don’t want you to be a rather irreplaceable resource. This is where working in a startup became an advantage. The list of language and technologies used in my present company goes on and on: Java/J2EE (struts, spring, hibernate, freemarker, ognl, velocity), Groovy/Grails, Python and now the latest introduction Clojure (not to mention other front end technologies) and introducing a new useful technology fitting a particular problem domain was well accepted and was the general norm. Also, I was exposed to these brilliant and thought provoking articles by Paul Graham: Revenge of the Nerds & Succinctness is Power.
I decided to update my toolbox and started learning Clojure. Why Clojure? The reasons are pretty much covered here. My major strong point was that I felt functional programming and lisp are a totally new way of thinking but yet clojure makes them usable in your day to day life. After using clojure for well over 3 months I feel my decision was indeed wise. A direct impact of this is that my Java code is much more succinct and yet readable. The impact was not limited to Java; my entire style of thinking was altered (in a good way). It does help you if you understand the limitations and drawback of the tools/technologies that you use. Functional programming is indeed radical, fancy terms like TDD would be just a way of life. This is a direct advantage of the fact that every function is self-contained and the scope/environment is small and easy to setup. That’s just one example that I felt personally. I definitely feel more satisfied now. Take a look at an example from the book Programming Clojure:
Java code, from the Apache Commons
Compare this to Clojure code