Writer Christopher Smart, as he was losing his mind in 1762, wrote a lengthy poem called the “Jubilate Agno”, which includes a shorter piece enumerating the many diverse things he loved about his cat Geoffry. You can read it here: http://www.cs.rice.edu/~ssiyer/minstrels/poems/661.html
Thursday last, someone asked me what I liked about Java. I was surprised to hear my own answer, and, not feeling particularly satisfied with what I had said, I thought that I might spell out here some of the things I was thinking at the time, but did not say. What is my relation to this language that I use every day?
So with my apologies to Christopher Smart, to whose wonderful poem I here pay homage, I thought I would spell out some of the reasons I love Java, even in 2007, to clarify.
For I will consider my language Java.
For Java is open source. The code can be read and freely modified. This is obviously true of a remarkable number of languages.
For Java is not a vehicle for viruses. It is as safe as was advertised. However, the whole “portability” advertisement is really a bit of an exaggeration. By which I mean that the same bytecode does not always run exactly the same on different JREs (volatile keyword implementations stand out). No one would suggest that a J2EE application written to run in WebLogic that uses JAAS for authentication and authorization, and contains EJBs is portable to JBoss without not only recompilation but revision (and the revisions get more extensive depending on what you are doing in your code, and you may not even know what aspects of your code will behave differently, requiring regression testing). For example, the same Filter implementation dealing with HTTP Sessions is executed totally differently in Tomcat than on WebLogic. Depending on the work you’re doing in your filter, this could be very problematic, and is not something one would just expect.
For there shall be little likelihood of buffer overflow.
For Java is strongly typed. Even though I often spend a good deal of time taking care of strong typing, and love weakly typed languages too.
For Java allows for many ways to achieve the same or similar goals. This allows for creativity of expression, and a sense of beauty and mystery.
For Java has many libraries that make it easy to use, and it is easy to extend. If you don’t like the way Calendar are Date are implemented (silly ints), you can use Joda (http://joda-time.sourceforge.net/). You have your choice of numerous XML parsing methods.
For Java implements many design patterns. Borders and JTable components are Flyweights, the XML libraries use Factories and Composite, the Collections give us Singleton wrappers.
For Java sometimes takes its cues from the community. Developers loved Hibernate, they get on the committee and we get the Persistence API; developers loved XDoclet, they get on the committee and we get EJB 3 annotations.
For Java SE 6 contains the Compiler API, which opens the doors wider to generative programming, and the Scripting API, which is fantastic for J2EE developers like me.
For Java has checked exceptions, which are clearer than in C#, and more powerful that the lack of exception handling facilities in VB.
For in Java, whitespace is not meaningful.
For in Java, multithreading is built-in, not added on, and is relatively simple.
For Java is both compiled and interpreted.
For Java has anonymous inner classes, integers are always 32 bits, Unicode is supported, and automatic garbage collection is a really nice thing to have.
For Java stands on the shoulders of giants.
For in Java one can tweak any number of aspects of how your application is compiled and runs. I am thinking of heap allocation, gc hints, assertions, configurable security policies, custom classloaders, and so on.
For Java has always been network ready, and features JNLP/WebStart, Jini, JXTA, and JavaSpaces.
For JMS is a beautiful thing.
For Java code can match, remarkably closely, the real world that one is emulating in a program. This is largely a feature of OO, and not Java itself, but I think Java wants us to adhere to good OO principles more assertively than other OO languages. The “primitives aren’t objects” argument sort of went away with autoboxing. While one can certainly write an 800-line fully procedural program or method in Java, the Java programmer of any experience in that case will have an eerily present feeling that he’s doing it wrong.
For Java provides Generics, and although the type erasure constraint demanded by backward compatibility makes it less powerful than one might hope, it is lovely.
For the Java Virtual Machine is a deceptively simple application of one of the fundamental directives of computer science, that we can eventually bridge to anywhere with another layer of indirection.
For in Java, the keywords are few, and while it may be verbose, it is not verbose where it needn’t be. The Python phrase “def do_work(self):” is longer and tells us less than “void doWork(){“. The “def” is implicit in Java, as is the “self”.
For Java is not pompous or loud or rude or showy or full of itself or standoffish or intimidating, and the tools we have for it, like Eclipse and IntelliJ, are like loving friends.
For Java is faster than its reputation suggests.
For Java is free.
For Java has annotations, which appeals to the meta-person in me who watches.
For Java makes me happy, as it is fun to write, and its programs contain dramatic structure.
While there are any number of these items that are true of other languages, and while in Ruby on Rails you can put together a complete CRUD web app for your 172 table relational database in under 11 seconds, I love Java.
Comments