Noel Rappin Writes Here

Languages I Use

Posted on August 31, 2006


Continuing in the getting to know you kind of vein, I thought I’d ground some of what I say by talking about the three programming languages that have made up the bulk of my professional and hobby work for the past five years or so – Java, Python, and Ruby.

Java: I’ve been programming Java since either just before or just after the 1.0 release… can’t quite remember at this point. I think I’ve covered most of the major Java libraries (although I’ve done very little EJB work). Basically, Java is the station wagon of programming languages. It’s not elegant or efficient, but it gets you where your going and you won’t offend anybody along the way.

Far and away the best feature of working in Java is the tool support, especially the IDE support. If you’re doing something in Java, odds are somebody has done it before and there’s an open source .jar file somewhere that will help. Plus, IntellJ IDEA makes working in Java almost as productive on a time-basis as working in a scripting language.

Java is, of course, famously verbose, and there’s the constant sense of telling the compiler things that the compiler should already know. (The 1.5 language features improve this somewhat, at the cost of moving some of the verbosity elsewhere). Java’s original design goal was basically to get C programmers to do object-oriented stuff without scaring them away, and at that it’s a success, but that does lead to oddities like having both basic types and object wrappers for them, and keeping the ridiculous C-style switch statement.

There’s also the “Java style” of OO design, enshrined early on by Sun, and followed by many third-party libraries. To oversimplify, there’s a lot of design made complicated by the desire to make less common tasks as privileged in the API as more common ones. For example, the need to spell out what are basically boilerplate properties in a web.xml file or a Struts config file. Swing has several features like this, including the event system and say, supporting multiple listeners for a button click.

Python: With Python I suppose you have to start with the whitespace thing, although I know that anybody who actually works in Python is sick of hearing about it. I wrote what I hope was a spirited defense of it in the Jython book, and I’m not going to repeat myself. What I like most about working in Python is the conceptual consistency – objects are like classes are like modules are like dictionaries. I find that to be a very powerful equation, and it makes Python code more predictable to me. I also think the syntax is very clear and readable. (I particularly like the list comprehension syntax.)

On the down side, although there probably is more Python libraries than Ruby ones floating around (although I’m not as sure of that as I was even a year ago), there’s no central repository so they are harder to find. It is true, though, that Python style quirks are more likely to bleed into my programming in other languages than vice-versa – I write a lot of Java code that really looks like it wants to be written in Python.

Ruby: I actually got into Python, Ruby, and XP at about the same time. I started on Ruby because a number of the early XP gurus were excited about it. And while I know I’m supposed to pick a side or something, I actually like Python and Ruby both quite a bit. There are some particular bits of Ruby syntax that I think are particularly well done, for example the way that accessors are handled. I even like that you can leave parentheses off method calls if the line is unambiguous, although a little of that can go a long way. Blocks make the language very flexible, and very easy to build non-redundant code in.

There are a couple of pieces of Ruby syntax that make me nervous, like the syntactic sugar for hashes as the last argument of a method or the way you don’t have to specify that a block is needed in the signature of a method. To be fair, I haven’t experienced practical problems with these features yet. Ruby has a lot of syntax sweetener compared to Python, which is sometimes good (elegant Ruby code is very elegant) and sometimes bad (I’ve had some trouble following Ruby examples if they are very magical). Because Ruby has been the focus of a lot of XP/Agile writers, the testing tools and general XPish support is very good. For a long time, I thought that general library support lagged Python, but that’s becoming less true daily. And of course there is also Rails, about which more at another time.



Comments

comments powered by Disqus

Copyright 2021 Noel Rappin