UPDATE : Some follow up on this here.
My story is probably similar to one thousand others: used to be a Java programmer, switched to Ruby six months ago when I quit my job to start 8th color. While discussing the “why” is probably not really relevant (short version: our product, Sybil, is a web front on a database, so it was globally for us a choice between Ruby/Rails and Python/Django, summarized there), I wanted to take the opportunity to write about the good and bad points of the transition, from my own personal point of view.
Disclaimer: This is an exercise at explaining a personal experience/opinion. I’m more than interested to hear yours. This is not an attempt to “prove” any “superiority” of a language on another.
I still code some Java each week, as a part-time consultant (you need something to pay the bills), and we’re using Ruby for our startup related development, so I’m in both environments each and every week, which gives me a rather good view of my own quirks about each language. While most of those points are not IDE related, I use Eclipse for Java coding, and Sublime Text for Ruby.
What I love
Basically, Ruby is the first language I find that seems to think like me. When I code in Java and looks for a method name, I often rely on Eclipse (really nice) auto-complete feature. In Ruby, most often I just type the name that I would have chosen. More often than not, it works. This is not purely a personal matter or a coincidence: Ruby (and Rails) are known to expose the same methods several times, using synonyms (“size” and “length” can be used to return the number of character of a String, for example).
Collections and iterators
Even in Java, I’m already quite fan of using functors (or more correctly functors interfaces) on collections (take a look at “Predicate” in apache commons-collections for example), but those constructions, while useful, are lengthy in Java, not to type (again, Eclipse does a pretty good job there, creating the anonymous inner class, the method, and positioning your cursor at the place you need to type), but to read (in most situations, a short line will be more readable that the 6+ needed in Java).
Ruby’s iterators and the power that come with them with methods such as collect, select and especially map is staggering. More often than not, I start a method knowing that I have several transformations to do, expecting the code to span 10-20 lines, then write a small part, and discover that I’m done.
In addition to readability, this kind of easiness encourage me to use (abuse ?) collections, which is something I really like.
This has become my “exploratory” tool of choice. When I’m trying to figure out a solution, I often fire IRB and start testing along the way. The feedback is instantaneous, and once I’m satisfied with what I’ve done, I go back to my text editor.
The fact that Rails takes the same approach with the Rails Console is more than an added bonus: it is something I’ll have trouble living without (note that something similar is possible for Java applications, using Groovy. A former colleague did integrate a Groovy console to each of our applications, allowing to explore or patch a situation in production in mere minutes, should the situation require it).
What I miss
Interfaces as Contracts
I really like Java interfaces for using them as a “binding” contract. It means that I can express it in one single place, and have zero chance of forgetting to implement properly (as the compiler will check it). It beats any tentative to document, and is a simple and elegant mechanism that pushes me to really think about the objects responsibility, while being a safeguard at the same time.
You may argue that this is more a “tooling” point, but it is not: Java strong static type system may be the source for much of its verbosity, but it also allows the related tooling to do amazing things (especially since IntelliJ started the “refactor” operations).
Whether your IDE of choice implements them correctly or not is another problem: most of this kind of functionality will never be possible in a dynamically typed language (at least not with the same level of confidence).
While I like the idea of Duck Typing, I would appreciate to be able to optionally type my parameters. In Java, after the method name, it is probably the most efficient documentation that I know. I tend to create small classes for most of my needs, and as such, my methods definitions parameters really tell something. I know that some languages offer optional typing, would be interesting to try. As a result, I’m doubly attentive to my naming in Ruby, because it is the only visible aspect remaining.
Taking a look back as this list, I’m probably wishing for the best of the two worlds (and it is probably not possible). I found two great tools in Java and Ruby, and I intend to use them both when appropriate. I’m sure I’ll have occasions aplenty.
We are developing an Automated code reviews for Ruby developers using Github, discover how you can become a better Ruby developer.