Software Engineering: The Right Editor for the Right Job

Imagine if you were reasonably skilled with all text editors and all IDEs. Which would you prefer for which tasks?

Clearly, if you're coding elisp, Vim would be a bad choice. Of course, what would be the point? More seriously, Emacs is written in Lisp and has SLIME, the Superior Lisp Interaction Mode for Emacs. Duh, no brainer.

For Scheme, there's something nice to be said about DrScheme's editor. Although, if we stick with the premise of knowing all text editors reasonably well, I'm guessing you might still stick with Emacs.

However, Emacs isn't perfect for everything. For instance, it my have a built-in Web browser, but I can guarantee you that I won't be giving up Firefox just so that I can use Emacs form widgets.

Similarly, Emacs is a little weak on the HTML, CSS, JavaScript side. Aquamacs comes with a fantastic mode for Latex, but if you want to edit an HTML file that has CSS and JavaScript in it, it's less than pleasant. mmm-mode and nXhtml-mode aim to fix this, but (from what I've heard) they're less than fun to set up. Pretty much out-of-the-box (i.e. turn on syntax highlighting, auto-indent, etc.), Vim is much nicer for editing an HTML file with CSS and JavaScript in it. From what I can see in the Aptana IDE videos, Aptana is even slicker.

What about Python? Emacs has very good Python integration, including integration with the shell. However, Vim is also pretty pleasant to use for Python. I've heard multiple times that Wing IDE (commercial) is the best Python IDE available, but Pydev (for Eclipse) also seems very active.

Ruby seems to be a no brainer. The entire core team uses TextMate. Of course, the choice is tougher if you object to using a closed source editor. I've seen other Rails coders use RadRails inside Aptana.

If you're coding Erlang, you should probably stick with Emacs. It was the standard editor among the guys who wrote Erlang. I've heard people joke that the only way to make sure you haven't gotten ".", ";", and "," confused is to make sure Emacs is indenting it right.

Similarly, Emacs is probably a good fit for Haskell, at least based on the Haskell coders I've met.

What do you use to edit config files on a remote system? The conventional wisdom is Vi, of course. However, these days, many editors (including Emacs, Vim, and Gedit) support editing over scp. Hence, you don't have to put up with HP-UX's version of Vi (I've heard it's awful) just because you're on a remote system--assuming you have network access.

Concerning Emacs vs. Vim specifically, I think that if there's a well written Emacs mode, you're better off with Emacs. In other cases, you're better off with Vim. In general, Vim's understanding of most programming languages is much weaker, but it comes builtin with support for many, many more of them. Furthermore, Vim is much better out of the box dealing with multi-mode files like HTML, CSS, and JavaScript files.

Furthermore, it's so nice to be able to say something like ":set sw=4 sts=4 et ai" which means "set the shift width to 4 spaces, set soft tab stops to 4 spaces, emulate tabs, auto indent". That might not be as smart as smart indentation mode in Emacs, but it sure is a time saver if there is no smart indentation mode for the syntax you're editing.

I still think that Vim is the fastest editor for straight text editing if you're a touch typist and you really know it well. A lot of "switch hitters" agree with this sentiment. "2dw" = "delete two words". "j." = "go down a line and do it again". Nice ;)

What about Java? Because of the nature of Java, I know very few people who don't use an IDE for Java. I've heard many people say IntelliJ is the best, but it's commercial. Eclipse is the big open source option. Surprisingly, I've heard a lot of nice things about NetBeans; I think they must have put some serious effort into it lately.

If you need something super general purpose and multi-platform, I've heard lots of good things about jEdit, but I can't think of any language for which jEdit is a must have compared to all other editors.

Ok, last tip: if you're coding in Turbo Pascal, any editor will do--as long as it's made by Borland and uses a yellow on blue font ;)

Happy Hacking!

Comments

Tarek said…
I think one of the main reason people are using an IDE rather than a plain editor like Vim or Emacs is the way the boiler-plate code is dealt in the framework they work with.

I have seen this in my previous company that switched from Python to Java: all Vim and Emacs lovers eventually switched to Eclipse because of the massive amount of boiler-plate code you have to write in this language when you use Jboss or equivalent frameworks.

In Python, the boiler-plate code can be generated through the command line with Paster so it is easy to work with it when using frameworks like Zope.
LeoB said…
Hi JJ

To set up nXhtml you have do download and unzip it and then add one line to your emacs init file. Is not that pretty easy?
cowmix said…
Komodo Edit seems to be a good basic editor you can count on being available for any platform you happen to be working on. It's knowledge of dynamic languages seems very current.. personally I use it for almost all my Python, HTML, CSS, PHP, etc editing.

The minor feature that I really love is that it has the ability to remotely mount a filesystem via ssh is built into the editor.
By the way, one thing I really find helpful is to learn from other people whenever possible. Whenever I see someone using a strange editor or IDE, I ask them to give me a tour of its cool features. If I can't figure out how to do something, I ask an expert. I have friends that I know are experts at Emacs, Vim, Eclipse, IntelliJ, jEdit, etc. It's very difficult to be an expert at many things all at once, but it's not that hard to have multiple experts give you advice on multiple things.
> I have seen this in my previous company that switched from Python to Java: all Vim and Emacs lovers eventually switched to Eclipse because of the massive amount of boiler-plate code you have to write in this language when you use Jboss or equivalent frameworks.

Agreed. It's one of the things that turns me off about Java.
> To set up nXhtml you have do download and unzip it and then add one line to your emacs init file. Is not that pretty easy?

Ah, that's a good hint. Thanks. I tried it, but got some weird error. I'll try again.
> Komodo Edit seems to be a good basic editor you can count on

Ooh, good tip. I don't know of anyone else using Komodo Edit. Thanks for the ssh tip--that's good. In the spirit of this post, can you tell me all the other things Komodo Edit can do that seem to be missing from other editors?
LeoB said…
jj: I would be glag do know how it works for you.

If you find bugs please report them at

https://bugs.launchpad.net/nxhtml
Mark said…
vi is also nice as $EDITOR for commiting to VCSs (e.g. svg, git, ...) -- anything where you just want to pop up a quick editor in the current terminal window.

ESS mode for emacs seems to be the preferred way to do interactive R scripting. It provides shortcuts for some of the clumsier syntax like '<-' and deals well with the large text dumps that tend to occur during an R session.
> jj: I would be glag do know how it works for you.

Thanks.
Mark said…
@jj "Furthermore, Vim is much better out of the box dealing with multi-mode files like HTML, CSS, and JavaScript files."

David Welton has a neat elisp snippet for changing the indent style locally Emacs:

http://journal.dedasys.com/2008/06/06/indent-region-as
Mark said…
Oops, that should have been
"in Emacs:

http://journal.dedasys.com/2008/06/06/indent-region-as
> David Welton has a neat elisp snippet for changing the indent style locally Emacs:

Cute :)
cowmix said…
Sure.. here is a little more on Komodo Edit...

First off, how I started to use Komodo Edit on a consistent basis was that I *was* using PyDev as my main cross platform Python editor. The issue with using Eclipse was by the time I got Eclipse setup for Python, HTML, PHP, Perl, etc for basic editing my download would turn out to be well over 100MB (across all the main and 3rd party modules) and I didn't end up using 1/2 of the features all the modules supplied. Eclipse based editing was just a lot of setup/hassel for a lot of features I didn't really use. Komodo Edit is around 38MB for any platform I work on (Linux/Windows/OSX) and its one complete easy install.

Komodo Edit implements just enough features automatically that I hardly reach beyond to other editors. Some of those features are:

1. KE supports auto-completion for most of the languages it supports.. but doesn't support fancy things like refactoring code.

2. Komodo Edit will allow you to highlight a block of text and it will know how to indent/dedent or comment/uncommnet the block based on the type of file it is.

3. The syntax highlighting is pretty top notch and very accurate. If you bounce around from PHP, HTML, Perl, Python, XML, etc.. KE is very pleasant to look at and view.

4. The performance of KE is very good. The current version is built on the same XUL engine that FireFox 3.0 is based on, and its performance has increased tremendously since the version of KE that was built on XUL RUNNER 1.8.

Just know that KE is missing a lot of features because its the little brother of this proprietry sibling Komodo IDE. Things like true code refactoring, built in version control, etc are missing. Personally, I don't miss those features (I use the command line version of GIT and Subversion for instance) and I appreciate the scaled down feel of KE.
LeoB said…
Mark: MuMaMo (which is part of nXhtml) does indentation according to the major mode in the chunk. It also tries to adjust the indentation level to the surrounding chunk.
> by the time I got Eclipse setup for Python, HTML, PHP, Perl, etc for basic editing my download would turn out to be well over 100MB

Yeah, Eclipse + Aptana + Pydev is a beast. I feel overwhelmed every time I try it. I'm glad I'm not the only one.

> I appreciate the scaled down feel of KE.

Ah, a man after my own heart. I think the same reason is why the Rails guys like TextMate over a full IDE.

Ok, I'm going to have my buddies give me a tour of Pydev, but I'm going to try KE on my own.

It's funny: normally a Vim diehard, but for the last week I've been using Emacs (again) just because I needed a change in pace. KE might not be appropriate for Erlang, Haskell, or Lisp, but it sounds a heck of a lot more polished (at least compared to Emacs without nXhtml) for HTML, CSS, and JavaScript.
Ok, I checked out nXhtml: http://jjinux.blogspot.com/2008/12/emacs-nxhtml.html
cowmix, you're right. Komodo Edit is quite nice. I wrote about it here:

http://jjinux.blogspot.com/2008/12/editors-i-dig-komodo-edit.html
Corey Goldberg said…
I would recommend SciTE for any editing job on just about any platform.
> I would recommend SciTE for any editing job on just about any platform.

What does SciTE do for you that you like so much?

You say "any editing job", but clearly SciTE can't be better for editing elisp, can it? ;)
> I would recommend SciTE for any editing job on just about any platform.

I just looked at it, but it didn't seem overly impressive. I wrote a long overview of Komodo Edit here: http://jjinux.blogspot.com/2008/12/editors-i-dig-komodo-edit.html. Is there anything in SciTE or Scintilla that is missing from Komodo Edit?
dm said…
Nobody seems much interested in C/C++ anymore, but a pretty nice open source IDE focused on C/C++ is code::blocks, see http://www.codeblocks.org

the nice thing is that it's so light-weight you can use it as a standalone editor and for many more languages than just C/C++

features:
* gui is wxwidgets, so code::blocks works on virtually any platform.
* the editor is scintilla based, so you get syntax highlighting for the gamut of languages.
* the project management is flexible enough to accomodate a variety of compiled languages and supports user created templates
* supports plugins (e.g. compilers, code completion, find & replace addons, SCM, file managers) and scripting (in squirrel). you can develop and debug C/C++ based plugins from within the IDE

biggest weaknesses:
* a tad ugly visually,
* codecompletion is c/c++ only and a bit buggy,
* the development is progressing slowly (some plugins can be pretty buggy or have poorly thought out interfaces)
* limited keyboard customization (no vim/emacs modes)
* the docs reflect the fact that most of the devs are non-native english speakers
Thanks for the note on code::blocks.
Fz said…
Hey, there is general multi-mode support in Emacs, support which everybody always forgets to mention: indirect buffers. In Emacs user can create an "indirect buffer" (C-x 4 c) which is a clone of a buffer. Content is always the same in the cloned-from buffer and the clone. Otherwise they are like separate buffers with possibly different major and minor modes, own local variables and everything.

This general solution may not be perfect everywhere but on the other hand it's always available without other support needed. I have used it succesfully with HTML/CSS code. One buffer is in html-mode, the other in css-mode.
That may not be as nice as what Vim or NetBeans can do, but that's still a pretty good trick. Thanks!
LeoB said…
I thought this thread was dead...;-)

Since I first saw this a lot of bugs have been fixed in nXhtml, maybe mostly because I have got bug reports so I knew about them. You must have been using version 1.60 when you tested. A lot of things has happened since then:

http://ourcomments.org/Emacs/nXhtml/doc/nxhtml-changes.html#v1.60

I was recently able to fix some annoying bugs which was impossible to fix before I rewrote some parts of nXhtml. So if anyone is interested in how nXhtml works now (and maybe contribute by reporting new bugs) then please try the latest version. (If you are using Emacs 22 then try the latest beta where I think I have worked around a bug in Emacs 22.3.)
I'm pretty happy with NetBeans with the jVi plugin, but I definitely think nXhtml is the best thing going for Emacs in the Web space ;)