I enjoy programming in Perl. There, I said it. And, although a lot of the stuff I write could easily be written in Emacs Lisp, I generally reach for Perl to solve most of my programming problems. However, if I had to choose between Perl and Emacs disappearing, I’d choose Perl any day of the week and twice on Sunday.
The reason is that there isn’t any competition in the emacs space. Vim, Visual Studio and Eclipse are not acceptable substitutes. But if I want a dynamically typed langugage with good syntactical support for arrays, hashes and regular expressions and loads of libraries I know where to find Ruby or Python.
Q. Why not switch to Ruby today?
A. I enjoy programming in Perl
What makes Emacs so great?
(or what would I need to switch from Emacs to another editor)
Many people put it as Emacs has QWAN (the quality without a name), but that doesn’t really help to quantify things. Saying that all of the features work very nicely together is true, but also not that helpful. Let me try and point out a few things.
(If the c2 link above isn’t working, try the Bing cache).
Keystrokes are bound to functions
…and it is all very discoverable. If I want to know what a given keystroke does, I just press
C-h k <key> and it tells me the function that calls. For example, arrow key calls
forward-char. Now, say I want to make a function that needs to move forward a number of characters, I know what the function is called.
The utility of this discoverability in making composite functions cannot be overstated. You might think that macros are equally good, but what if I want a function that persists between sessions. For my line duplication function I glued together functions found with
Okay, new utilities, great but not that impressive.
What about fixing stuff with the editor that you just don’t like. For example, recently I had a problem where <page down> went to the beginning of the line rather than remembering the current column position. You might be thinking a proper editor wouldn’t do that, or it isn’t really a problem, but you can’t imagine how annoying that was after the first ten times.
Anyway, what I did was… I fixed it. With
C-h k I found that the command was scroll-up and I wrote a wrapper function that remembered the current column (alternatively I could have used advice). Saved my blood pressure and took around 5 minutes.
- Key strokes / key chords call functions (which can be user-defined)
- New functions can be created within the editor at any time
- any key / key chord can call any function
- information about the function can be viewed
Okay, you’re not convinced. Vim can do that, albeit with a much less pleasant language (or with perl, ruby, python, etc. if you’ve compiled a fat vim)
Tabs are not the right mechanism to deal with hundreds of open files. Emacs (together with ido) works beautifully. Generally I’ll have a couple of hundred files open with different file types and I’ll use progressive filtering to first find the perl files and then narrow down the file I wanted. Very quick and very nice. I’ve spent hours scrolling through tabs in Visual Studio and it was not fun.
So all your keys are bound to various useful commands. M-e steps forward to the next sentence nicely. But then you’re editing lisp (or perl) and sentence doesn’t mean much. What does emacs do?
In this case it has a keymap hierarchy. The global keymap defines a bunch of keys which can be overridden by keys defined in the major mode keymap. These can be added to with keys defined in one or more minor mode keymaps.
Comint is an awesome bit of kit. Out of the box, Emacs provides fantastic support for interacting with asynchronous processes. Comint codifies a lot of the functionality you would want to make a decent REPL for an external interpreter. Because this is one of the more tricky interactions to manage, it is an excellent API for dealing with any external process.
A while ago I wrote an article about a comint based stock price subscriber which demonstrates a few comint features.
Take a look at the interaction with gdb following
M-x gdb-many-windows. It looks like an IDE no?
Some people have developed some impressive applications in emacs.
- Org Mode
- Emacs Muse
- SLIME (A full-featured Lisp IDE)
And my own Emacs Database Mode
Which in turn is based on the excellent sql-mode.
Read Full Post »