1.5. Editors and IDEs

Talking about editors is like entering a minefield. As the Latin would say "De gustibus non est disputandum," which can be liberally translated as, "There's no arguing with taste." Editor and IDE preferences are highly personal, and I will therefore refrain from telling you which one you should use. I do, however, provide a list of a few popular choices, and I invite you to try them out at your leisure, until you find the one that's right for you.

1.5.1. IDEs Are Helpful, Not Necessary

Microsoft evangelists may occasionally use Notepad in their demos, but as a Microsoft developer you know all too well that without a serious IDE like Visual Studio, writing ASP.NET or .NET desktop applications would be a nightmare. Your proficiency in Visual Studio may make or break your productivity.

In the Rails world there isn't an official IDE and we're not big fans of drag-and-drop tools either. The truth of the matter is that Rails doesn't need either of these two things. Most Rails developers are very happy about using text editors. As a matter of fact, when programming in Ruby or in Rails, a good text editor is all you really need. Even something as simple as SciTE, which we installed through the One-Click Ruby Installer, is probably sufficient.

C# and Visual Basic are both relatively verbose languages that take advantage of a huge framework. Ruby is so expressive and concise that an IntelliSense system like the one you are used to in Visual Studio would be helpful, but it is not required to the same extent.

Another great feature provided by IDEs is their ability to do the drudge work for you by generating a lot of code. This, again, is not necessary in Rails. The generation of controllers, models, or scaffold (aimed at rapid prototyping) to name but a few, are all carried out by simple scripts that you can run from the command line. And the generated code could be written (even in Notepad) in very little time. When dealing with Rails there simply isn't a need for a lot of code generation of the sort you'd expect with some other languages and frameworks.

Don't use Notepad as your editor. There are issues associated with the use of the Windows' end of line characters, which would cause trouble when deploying or committing your code to a non-Windows machine. If you must, at least consider Notepad++ (http://notepad-plus.sourceforge.net).

IDEs help with the compilation of software, but Ruby is interpreted and, as such, the process is already much more straightforward. You write the code and then run it directly, plain and simple.

That said, IDEs can be helpful even when programming in Rails. But they are usually much lighter in terms of features (and responsiveness) when compared to Visual Studio and similar programs. A good Rails IDE needs first and foremost to have a solid editor. Syntax highlighting and auto indentation of the code are, in my opinion, a must. Not so much with Ruby, but Rails has a tendency to use very long method names, which can become quite tedious to type. An editor that enables fast typing and proposes contextual automatic completion of code can make your life easier.

I find that the most successful Rails IDEs (and some editors) tend to provide quick access to files and folders within your project, given that multiple folders and files are created when Rails generates the skeleton of an application. IDEs should also allow you to run shell commands directly within the environment, so that you aren't forced to switch between the editor and the command line. Some IDEs also provide support for refactoring, testing, and debugging/profiling of both Ruby and JavaScript.

1.5.2. Popular Choices

In an informal survey — admittedly not one of an overly scientific nature — performed by Tim Bray, the Ruby and Rails communities were asked to provide information about what tools they were using. I'm reporting the results of Bray's survey here because they definitely confirm the anecdotal evidence that I've gathered over the past few years in the Rails world.

Figure 1-7 shows a chart with the most popular choices for Rails, according to the survey available online at http://www.tbray.org/ongoing/When/200x/2007/11/26/Ruby-Tool-Survey.

Of the first 1,000 programmers who responded to the survey, 38.30% replied that TextMate was their Rails editor of choice. As you can see, text editors are very popular; in fact TextMate, Vi, Emacs, gedit, SciTe, jEdit, and E Text Editor are all editors. NetBeans, Eclipse, and IntelliJ are IDEs. ActiveState Komodo represents a mix of both, given that there is an Edit version and a commercial IDE. From these numbers, let's briefly consider the most popular choices.

1.5.3. TextMate: The King of Rails Editors

TextMate (http://macromates.com) is not an IDE, but a fast and extendable editor that is both very powerful and easy to use. It is a commercial product, but it's fairly inexpensive at about $63 US. TextMate's strength lies in its ability to employ user-contributed bundles, which are very easy to create and modify. It ships with a Ruby and a Rails bundle, among others, and new contributions, with improved features created by other open source developers, are often shared with the community.

Figure 1.7. Figure 1-7

TextMate has a Drawer that can contain your project folder and file structure, multi-tabs, and the ability to quickly access a file by simply pressing a shortcut and typing the start of the file name. Among many useful features is the ability to trigger snippets of code (often, common idioms), which can save a lot of time and help you with Rails' long method names (for example, validates_uniqueness_of). The catch is that it's only available for Mac OS X.

E Text Editor (http://www.e-texteditor.com), used by less than 1% of the surveyed sample, is a clone of TextMate for Windows and its tagline is quite aptly "The Power of TextMate on Windows." It's cheaper than TextMate at about $35, and can take advantage of TextMate's bundles (see Figure 1-8), but you'll need Cygwin, a Linux-like environment for Windows, in order to get the best from its many features.

Cygwin and the One-Click Ruby Installer

The first thing I do whenever I need to work on a Windows box is to ensure that it has a POSIX emulation layer installed. I do this because I feel greatly incapacitated without being able to take advantage of the many powerful tools available in Unix-like systems.

The E Text Editor encourages you to install Cygwin upon startup and thanks to this you will be able to take advantage of TextMate bundles on Windows. Unfortunately, the native Ruby installed by the One-Click Ruby Installer and the emulated Ruby provided by Cygwin are not compatible. If you installed the One-Click Ruby Installer, and then tried to use Ruby or Rails from within Cygwin, you'd face all sorts of problems.

If you decide to uninstall the One-Click Ruby Installer and use the Cygwin version of Ruby, you will have to manually install RubyGems and then Rails through the gem command within the shell provided by Cygwin. Alternatively, by taking the E editor out of the picture, you can use the command-line tools provided by Cygwin (or similarly MinGW), but resist using the Ruby version they provide.


Figure 1.8. Figure 1-8

TextMate is what I personally use when I'm on a Mac, and I feel that the experience provided by TextMate on a Mac is hard to beat; but given that TextMate is not available for Windows, you may find E to be very useful. Expect it to be very different from what you're accustomed to with large IDEs. After all, it's still a text editor.

1.5.4. Vi and Emacs

Vi and Emacs, and all of their respective variants, are two powerful and very different text editors that have been popular for decades in the *nix world. They're free software and have Windows versions, but if you've never used them before, both will seem extremely complicated to you. In the Rails community Vi is the most used of the two, and in the Ruby community, according to that particular survey, members of the Vi family are even more popular than TextMate.

Some developers swear by either of them, whereas others consider them suboptimal for developing in Rails. It's true that Vi and Emacs are very extendable, powerful, and that there are all sorts of resources for using them for Ruby and Rails development, but unless you come from a Unix background, I don't particularly recommend you check them out. They are worth all the effort that's necessary to learn them, but I don't feel that you need extra obstacles while trying to learn Ruby, Rails, and a different culture.

1.5.5. NetBeans IDE

Sun Microsystems has vested a lot of interest in Ruby and RoR. One of the fruits of its involvement with the community is the NetBeans IDE. This multi-platform Java-based tool has been continuously improved to add new Ruby- and Rails-specific features and, in a short amount of time, it has gathered a growing following.

The tool works well and it even offers code auto completion as shown in Figure 1-9, but don't raise your hopes too high, because currently it's not nearly as refined and efficient as Microsoft's IntelliSense.

Figure 1.9. Figure 1-9

1.5.6. Aptana Studio and RadRails

Aptana RadRails is an award-winning open source plugin for Eclipse-based IDEs. It is available as a plugin for Eclipse and can also be installed from within the free-of-charge Aptana Studio, the community edition of a commercial IDE (Aptana Studio Pro). Aptana Studio is based on Eclipse, and once you've installed the RadRails plugin, it provides you with a very pleasant working environment, full of useful Rails features. This product is constantly being improved upon, has excellent support from the company, and it's one of the best liked and most used IDEs in the community.

Just like NetBeans, it offers basic support for code completion (see Figure 1-10) and many more features. You can see a feature comparison with NetBeans on Aptana's website (http://www.aptana.com/rails/).

Figure 1.10. Figure 1-10

Out-of-the-box features aside, its real advantage over NetBeans is that it's part of the Eclipse ecosystem, where many useful plugins are available for Web developers. Of all the editors and IDEs presented here (which work on Windows), Aptana Studio plus the RadRails plugin are definitely one of the most valid choices (and what I use when I'm on a GNU/Linux or Windows workstation).

If you decide to try RadRails, install Aptana Studio (or Eclipse) and then click Install RadRails from the Aptana Start Page.

RubyMine

Currently available as a public preview release, RubyMine is a new Rails commercial IDE by JetBrains. Dubbed by its makers as "The Most Intelligent Ruby IDE," it's probably too early to establish the impact that it will have within the Rails community. The Java-based IDEs mentioned previously are quite smart in their own right and are available for free.

Nevertheless, JetBrains has a reputation for creating great IDEs (it makes IntelliJ IDEA) and RubyMine 1.0 is scheduled to be released in the first quarter of 2009. By the time you read this sidebar, it will most likely have been released, and it may be worth checking out.


1.5.7. Ruby In Steel: I Still Want Visual Studio

Ruby In Steel is not on the list of the most common Rails tools. Still, in a book aimed at Microsoft developers, it's too important to be omitted.

You may spend a week or so trying out several of the recommended IDEs and notice that they all have little in common with the RAD tools you've spent most of your professional life working with. You may feel a bit lost, and would prefer to still work with something along the lines of Visual Studio 2008.

If that describes you, Ruby In Steel may be your best bet. It's not just similar to Visual Studio, it actually is Visual Studio! In fact, Ruby In Steel adds support for Ruby on Rails to Visual Studio 2005 and 2008. As such, this commercial IDE may greatly simplify your transition to the Rails world.

Four downloads are currently available (http://www.sapphiresteel.com/spip?page=download):

  • Ruby In Steel Developer 2005: A plugin for Visual Studio 2005.

  • Ruby In Steel Developer 2008: A plugin for Visual Studio 2008.

  • Ruby In Steel All-in-One Installer: A complete package that installs Visual Studio 2008 Shell (integrated mode) with the Ruby In Steel Developer edition. This installer can also optionally setup Ruby, Rails, and MySQL for you.

  • Ruby In Steel Text Edition: A lightweight entry level edition that can be installed in Visual Studio 2008 (standard and up) or in the Visual Studio 2008 Shell that is installed by the All-in-One Installer (but not with Visual Studio 2005).

Both versions (Developer and Text Edition) have a very fast debugger called "'Cylon" and provide support for IntelliSense (as shown in Figure 1-11). The Developer edition also features a Visual Rails WorkBench for drag-and-drop client-side design.

Figure 1.11. Figure 1-11

Ruby In Steel Developer (version 1.3) currently costs $199, and Ruby In Steel Text Edition is sold by Sapphire In Steel for $49. The trial versions will permit you to use them free of charge for up to 60 days. You may not be fond of Visual Studio in the context of Rails, but it's far more likely that you'll enjoy the familiarity of the environment.

Recently the company introduced a free edition known as Ruby In Steel PE 2008, which has most of the useful features offered by the commercial versions, but lacks the integrated debugger (available starting with the Text Edition), auto-expanding of code snippets, and technical support. Though not as useful as the commercial versions, it is still a good starting point nevertheless. You can find it online at http://www.sapphiresteel.com/Ruby-In-Steel-New-Free-Edition.

A fourth edition, Ruby In Steel IronRuby Edition — for Microsoft's implementation of Ruby on the Dynamic Language Runtime (DLR) — is free and currently in Alpha. I don't recommend that you install the Alpha version at this stage because neither IronRuby nor its VS plugin are currently suitable for developing Rails applications. This will probably change fast though, so feel free to check IronRuby's progress periodically at http://www.ironruby.net.

Spend some time exploring these tools; it's important to find the editor/IDE that you're most comfortable with. No matter what you choose, you'll be able to follow the rest of the book with ease.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.206.112