Chad Woolley's blog
In a recent thread on the East Bay Ruby Meetup list, several people chimed in with Ruby IDE suggestions. I suggested RubyMine, which we use at Pivotal. Several people mentioned NetBeans and Aptana RadRails, so I decided to have a little contest.
Now, if I am going to work in an IDE and sacrifice the speed of a text editor, I want to see it work for me ('cuz RubyMine can chew through all your CPU and RAM and then some faster than you can say Moore's Law). That means understanding Ruby, and using that information to save me some significant thinking and work.
I don't mean code-generation macros or dumb context-aware keyword-completion, I mean something useful like knowing where my classes and methods are. In my book, that leaves out Emacs, Vi, and even TextMate, regardless of their other merits (sorry people, I like text editors too, but I'm making up this test - flame away, the comments section is below).
So, here's the smackdown scenario:
- Download the latest NetBeans, RadRails and RubyMine.
- Open a Ruby project, this example is one of mine (I wrote this three years ago to learn Ruby, so don't make fun of me for doing dumb stuff...)
- Test the ability of the IDE to navigate through Ruby language constructs. This should be easy, it is a command-line app using a Dependency Injection architecture, no metaprogramming curveballs!
- Open the root Ruby class for the project (
lib/geminstaller.rb) - Pick a variable (
appinself.install) - Try to work back to the class declaration (
GemInstaller::Application) using IDE navigation (Command-clickin all the IDEs, although sometimes they ignore you)
- Open the root Ruby class for the project (
Result? RubyMine succeeded, NetBeans and RadRails failed miserably. Here's what happened in each:
NetBeans
- Click
create_applicationclass method reference inapp = create_application. NetBeans takes me to the method declaration in same class. - Click the
appmethod inregistry.app.
FAIL! ANGRY BEEP! app is an attr_accessor on another class, NetBeans can't find it.
RadRails
- Click
create_applicationclass method reference inapp = create_application. RadRails takes me to the method declaration in same class. - Click
appmethod inregistry.app. RadRails takes me to theattr_accessoron theRegistryclass (without a prompt, and highlighting the symbol, which is even better than RubyMine). - Click (and F3) on the
:appsymbol argument toattr_accessor.
FAIL! ANGRY BEEP! RadRails can't figure out the symbol parameter to attr_accessor. It says "Current text selection does not resolve to a Ruby element".
RubyMine
- Click
create_applicationclass method reference inapp = create_application. RubyMine takes me to the method declaration in same class. - Click
appmethod inregistry.app. RubyMine pops up a dialog asking if I mean theattr_accessoron theRegistryclass, or the local variable I'm declaring. That's rather silly, I admit, but the point is it followed the reference to another class. - Click on the
attr_accessorchoice. RubyMine takes me to theattr_accessorline in Registry. - Click on the
:appsymbol argument toattr_accessor. RubyMine takes me to the point where the@appinstance variable is initialized. - Click on the
Applicationclass name in theGemInstaller::Application.newconstructor invocation. RubyMine pops up a dialog asking if I mean theApplicationclass in my application, or two other Application classes that happen to be in my Ruby installation. This is also a silly question - it should have known the correct choice because of my namespacing, but it still found the class. - Click on the
GemInstaller:Applicationchoice. RubyMine takes me to the class declaration.
SUCCESS! RubyMine drilled all the way to the class declaration, even through an attr_accessor, albeit with a couple of stupid questions.
Summary
I personally think this is a Big Deal. In the past, I've mocked Ruby IDE functionality as a poor simulacrum of the vast power in Java IDEs. When using Eclipse in Java, I could perform epic refactorings, extracting superclasses and adding parameters to method signatures; refactoring scores of classes across multiple projects in a few mighty keystrokes. Yes, I'm fully aware that this is because Ruby is a dynamic language, but that doesn't make me miss a real refactoring IDE any less, and others have long lamented these shortcomings, as well.
So, for years, even though I'd always indulge my pairs if they wanted to use an IDE, I've done all my personal hacking with a fast, lightweight text editor and command line tools. To me, the benefits of a memory- and processor-sucking IDE with tons of unnecessary, unconfigurable, resource-eating tiny-ass-fonts and chrome did not justify giving up the speed and responsiveness of a great text editor.
However, RubyMine can now navigate code for me. I don't have to think and manually find that class, RubyMine knows where it is. Granted, that ain't no Extract Superclass, but it saves me a lot of thought and time, both of which are increasingly rare commodities for me.
To be fair, this is really just a problem related to parsing and interpreting attr_accessor declarations, and I expect that NetBeans and RadRails will pass this test as well in another release or two. That's all great news, because it means that Ruby IDEs are finally, slowly, coming of age. I think I'll still be waiting a long time for an automated Modify Method Signature refactoring, though...
