Programmers tend to be a crew that likes their tools. From the OS, to version control, to bash and Ruby itself, one could argue that pretty much every aspect of programming involves a tool. Usually, the linchpin of all these tools is the text editor, the place where the code actually gets written. Recently, instead of using Sublime Text, I’ve been using an IDE called Rubymine. While I’m a fan of Sublime Text, I’ve been finding that Rubymine provides some advantages that give me a boost in efficiency. In this post I give a quick review of some of Rubymine’s features.
Debugging
Rubymine comes with a built in visual debugger that can function as an alternative to debugging with pry. Let’s take a look at how this works.
Navigate over to the rspec test you want to run (or the file that serves as your program’s entry point), right click, and select debug (or Option + Shift + D). You can also select a specific test to run within a spec. If there are no bugs, your test will pass and your program will run. When you debug, three tabs will open up at the bottom: the Debugger, Console, and Interactive Console. The Console reports the output of your test, and will alert you if there are any errors. Let’s say you run a test and you hit an error. Here are the steps you can take to take advantage of Rubymine’s debugging capabilities:
Head over to the line in your program where Ruby ran into a problem.
Set a “breakpoint” – this is very similar to setting a binding.pry. The next time your program runs Rubymine will stop it at this point. Use Command + fn + F8 to set a breakpoint. You can set several of these at a time.
Rerun your debugger (Option + Shift + D).
Now, when you check the debugger tab you’ll be shown the current values of the local variables within the scope of your breakpoint and Rubymine will write out these values in your actual code. You can also get access to an Expression Evaluator and can set a watch or a condition on variables or expresssions to see how they change as you move through your code.
Head over to the Interactive Console for an IRB that gives you access to these variables.
Once you’ve corrected your code, hit ‘Rerun’ to rerun your test.
This might not sound like it’s that different from using pry, but when you’re debugging, getting visual cues and having all of the information in one place without having to run multiple commands and switch between panels seems invaluable.
Syntax Highlighting & Auto Suggestion
Rubymine remembers your classes and their methods no matter where you are in your program, so when you reference a class or create a new instance it provides a list of method suggestions. Pretty helpful when you’re trying to remember a method. Also, unlike Sublime Text, it provides code completion and signals you when you have a syntax error or have misused a local variable. No more having to type “end” to a if block.
Terminal
You can run bash directly from Rubymine. Need I say more? No more need to shift + tab back and forth from terminal.
The Verdict?
Rubymine seems to be super powerful. It has other features which I haven’t begun to explore, like other language and refactoring support. It’s keyboard-centric, which means it’s meant to be handled through keyboard commands as much as possible. Of course, having to learn a bunch of keyboard commands can be time-consuming and an extra stress when you’re already trying to learn something new. But, once you have a good number down, they save you a lot of time. Rubymine definitely takes more time to learn than Sublime Text, and can be a learning project all on its own. There are a ton of features, which can seem overwhelming and like a distraction from the actual task: coding. Also, at $99 for an individual license, it’s not cheap. But an upfront investment of time and money seems very likely to payoff in terms of efficiency and support.
Some purists might argue that they like sparse tools like Vim better because they can code right from the command line. In my view, why not use a tool that can provide you more context immediately? When you’re doing something as cognitively involved as coding, it helps to have all the signaling you can get.
In the end, there is no “best” text editor or environment set up – it’s a matter of individual taste and circumstance and what you feel supports you best in your workflow. As long as a tool is empowering you, it’s worthwhile. I’m still getting to know Rubymine, but for now, I’m enjoying it.