To IDE or Not

Background
After spending a couple years in the Ruby/Rails world, I made it back to Java (and Groovy/Grails). In doing so I new I’d have some choices to make about my dev environment. Working primarily in Groovy I thought I’d follow some of my previous workflows and use similar tools that I used previously in Ruby and Rails. But being under the gun and not having the luxury of experimenting, I decided I would use what I already knew, the IDE. But I was pretty shocked at how painful it was to go back to the IDE.

The IDE offers a one stop shop of features that increase productivity and is pretty easy to leverage. Just follow the wizards, menus, workflows, etc. You can poke around and find new features pretty easy. Editing, navigating, deployment, even checking code in is pretty easy. Most people might not think they need anything else. However, after using vim for a while, I began to love it and after running into various issues with the IDE, and convinced most developers should experiment with vim and leverage its use.

If you’re not already aware. the Ruby editor of choice is vim with a slew of plugins. Vim is a text base editor that is known for being a bit unfriendly and wooley to the uninitiated. But, vim does one thing and one thing well: editing text. Text can be moved, deleted, changed, duplicated, and more with very simple commands. Boom, boom, boom, done. By the time another developer reaches for the mouse, the task is done. The flip side is trying to remember all the terse commands and just knowing if something can be done. Plug-ins fill in the blanks that a developer needs besides text editing.

No doubt vim is tough. You really can’t experiment with it to see if you like it. You can’t use it for a couple hours and expect any of it to stick or to give you a satisfying feeling in your gut. You have to use it for a while. A few weeks of dedicated use at least. Probably a month, or more. You’ll need to learn the very basics: navigating, editing, saving, quitting. Then you will need more advanced skills, jumping around, substitution, marking, opening up multiple files, and more. Then leveraging plugins for searching, running tests, checking code in and out, and more. It takes a while to learn, but is well worth it.

But hey, I can do all this in my IDE. Why Vim? I don’t need it. Vim is satisfying and efficient once you get the hang of it. There are many places were you can learn about the benefits of vim. My goal is to whet your appetite and encourage the use of vim, not to teach it. Since you read this far, your probably already somewhat interested. The rest of the post will cover the problems I had with the IDE and why vim works better for me.

comparisons
I am currently using Eclipse and this article is primarily targeting Eclipse. I fully acknowledge JetBrains IntelliJ is a much better IDE and hence will be making the switch. I plan on making some updates after I switch and have some time to evaluate. However, I am pretty certain many of the same issues will be present, just less annoying.

Editing
Working with the mouse is just plain inefficient. Thing about saving a file. If I am typing, I can hit ‘:W’ (The save command in vim) well before you can touch the mouse, not to mention to move to the File menu and scroll to save. Don’t believe me? Then why do you prefer ‘ctrl + s’ in your IDE instead of the mouse to save 😉 See your already sold on the IDE. Vim is just a hop and jump to the left away. Next, swap a line of code. I need to get my cursor to the line of code. I can usually get it there in a couple key presses, again about the time you can reach for the mouse. Then a ‘dd’ followed by a ‘p’ swaps the lines. Your still highlighting. A sophisticated IDE user is probably already aware there is a short cut to do this. OK. so there are some nifty commands for editing and moving around, but my IDE of choice has many shortcut keys AND more, it has Auto complete.

autocomplete
A couple notes about auto complete. Auto complete is not always your friend. It gets in the way, especially in Eclipse and more so in Groovy/Grails. My recent forays with autocomplete are frustrating. Given, Groovy is dynamic and the IDE has issues which are not it’s fault, but it still has issues. Eclipse has a habit of completing text that is not what I intended. Options that pop up are of not what I really want. In straight Java, auto complete is pretty cool and works pretty well. But less so in other languages. But what I see is many people use that as a crutch and don’t really learn what is in their code. With that said, Vim has auto complete. It can give you lists of many things that is surprisingly accurate. Typically it buffers information about the file your in and presents those as auto complete field choices. It works surprisingly well. IDE’s get the edge, but vim isn’t really far behind in reality.

searching
Next, searching. I hate searching in Eclipse. I have too many choices. In the file or workspace or maybe working set, remote searching, case sensitive, or wrapping, file name patterns and search pattern, folders choices. Then I get weird output of files that I have to drill down into. REALLY? In vim, I have a few simple options that are super powerful. Built in search is 90% of what I use. In one key stroke I can enter my text or regular expression and can search through the text forwards or backwards, and word wrap by pressing the next button. A line search is handy for jumping to the next character on the line. Handy but not used to often. Then there is the SilverSearcher plugin. A simple ‘ag’ followed by the text will search the current directory and list the output long with file name. You can add folders to limit the search. Need something else. Leverage find and grep. Hey, vim is a Unix/Linux and Mac tool and the OS is our friend. Window guys/gals, upgrade or get something to help like Cygwin to fill the gap. Searching, way better in vim.

resources
Other advantages, vim is lightweight. IDE’s are fat and bloated. Eclipse takes resources. Serious resources. And it keeps taking them. They are memory hogs and freezes are pretty typical for a variety of reasons, most of which you will never know why. Anyone really dare to look at the error log? Set up is often more difficult than it needs to be. Occasionally you can import a project and all works. But when it doesn’t, man, it doesn’t.

files
At the end of the day the IDE is an editor. Everything else is just candy to help you get your editing done. As explained above, vim is just a better editor. But it’s more than just moving the cursor around and typing in text. How much of your IDE. is a text editor? What are all those other boxes surrounding your editor? Not to turn this into a geometry class, but I suspect they take up nearly 50% of the real estate. OK, you can maximize the editor or minimize the other views. But what if you want to see two to different files side by side, or even the same one, but at different points in the file. Do able, but a bit painful in Eclipse. You have to drag tabs around, which always want to go where they want to go, not where you want them to go. But there you go, reaching for the mouse again. In Vim, just a couple key strokes and I have my source file split next to my test file. And I can jump between them with a simple key command. I haven’t figured out how to do this in Eclipse. Gotta grab the mouse. OK, now I gotta look at that other file right next to the one I have open. How do I switch tabs? hmmm…. Oh, there is a funky key command that just made it into Eclipse that allows you to move to another tab. Really? Just recently? Sure there are some shortcuts that go to last edit, which are handy, but not necessarily to the next tab. And if you want to jump from file to file as you dig through the source as a stack, AND keep the other files in view while you do that, with simple key strokes? Don’t try in an IDE. Dealing with file navigation is painful in Eclipse. Big wing for vim.

spelunking
With all that said, an IDE is great a spelunking. I hate poking around source code in an IDE. If I don’t know what I am looking for, but I am just randomly checking files for something, the IDE is much better, I can open a directory and start clicking on files. Very easy and natural. Big win for IDE.

distractions
When I am in my IDE and I maximize my editors, again, because and IDE is primarily and editor and I want to see my code. I get popups that interrupt my editing. This is very annoying. Some view somewhere is updated and it is determined to tell me about it by popping up over my code and taking focus away from my mouse after blinding me of part of my screen. Sure I can find that setting and turn it off, but why the heck was it on in the first place? Again, I should be editing. It seems other things are taking priority over that in the IDE.

Tabs
Tabs. Tabs should not be in source code. That is my belief and your may vary. But like all beliefs mine are correct. Or more accurately, the one that is talking is correct, and this is my blog, therefore… anyways, tabs cause problems. Some environments set tabs differently. Some 8, some 4, and occasionally some to 2 ( but those people deserve what they get). This makes the format of code blow up when code rendered on a editor with 8 space tab is displayed on a 4 space tab. And you get a helpful engineer that fixes the 8 space tab to 4, only to have the even more helpful 8 space tab engineer reset it. In reality, no one does anything and it’s just a mess. Keep tabs as spaces. Wait, is this a diatribe that just lost all focus? Not at all. Try setting tabs to spaces and tab spacing in Eclipse. You will find dozen of places. Did you get them all? Really? Are you really sure? What about for HTML? XML? OK, good. CSS? hmmmmm….. Text files? JavaScript? Other files? Not fun. easy to do in vim.

Compatibility
Many tools work in a specific way. They have to be tooled for the IDE. I was using Spock testing framework and found a feature that wasn’t supported in Eclipse. works fine on the command line but not in the IDE. Probably not common, but it occurs. Tools have to be specially written for the IDE. Bleeding edge experimenting is not for the feint of heart, especially in IDEs.

content assist
And for my number one pet peeve? Content assist. I already mentioned auto completion where Eclipse often just decides it will autocomplete for me, thus interrupting my typing with something not even close to what I needed. But in addition, it tries to complete things other than methods or variables. My quotes. Grails supports triple quotes. Eclipse is damn sure you don’t really mean to use triple quotes. I am sure some poor sap of an engineer spent a long time on that part of the code base to perfect the heuristics of how to deal with quotes. But I can say it is wrong. Sorry dude. Sure Grails is a bit odd in the triple quotes, but truth be told, I don’t use triple quotes that much. My more bothersome issue is when I type regular set of quotes, but I do them in the wrong order. Try typing some text, then add quotes at the end. Not your normal workflow, but I end up doing this a fair amount. I type something and forget the opening quote. Then I add the end quote, but I get two. If I delete the first quote both disappear and I have none. Rinse an repeat, or I have to move over to the last quote. Remember navigation above? I can grab the mouse or I have to move all the way over to the arrow keys. ARGH. The delete the last one. Now I have to get to the beginning of the text to add the first quote. Again grab the mouse, which if I am right handed, I had to let go to hit the back button and re-grab to move the cursor to the beginning of the line. Retype and then delete. ARGH. In vim, the problem never even crops up. and if I do miss the quotes, I have a plugin that will surround text with quotes. Or brackets, or parenthesis, or angle brackets, or what ever. Very cool.

I don’t mean to disparage IDEs, but to show that they have lots of quirks, and I am sure you probably have some of your own, that are much better handled by vim. Vim is not a limited editor, but a powerful IDE in it’s own right with the right support pug-ins and tool support.

resources
A few resources to get you started
A good resource for leveraging Unix as a substitute to your IDE.
Unix as an IDE
A much better explanation of vim and why it is good
Why, oh WHY, do those #?@! nutheads use vi?
A good intro into tackling vim
Vim Revisited
An Example setup for Java
VIM configuration for happy Java coding
And another (primarily for groovy, but still applies to java)
Using VIM as your Grails IDE Part 1: Navigating your project

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s