Wednesday, March 26, 2008

Emacs, Unix, geeking out all over the place

This isn't very exciting to almost anyone, but after months of vacillating, I've finally taken the plunge into using GNU Emacs at work and at home.

My PC has been relegated to the dustbin of history, only turning on for music recording now (and that's only because I can't get the guitar pedal control program working). For me lately, Unix has been it at work and it at home.

What is GNU Emacs, you ask? Well, for you non-programmers out there, you might think of it, at first blush, as a very very very sophisticated version of Notepad. It is first a text editor. On the other hand, there is a joke about GNU Emacs: it's a nice operating system, not such a great text editor. This refers to the fact that Emacs is extensively programmable, and as such has become, over the years, a command shell (windows users, open cmd.exe), a software development tool, a program interpreter, a games platform, and pretty much anything you can think of and program. It even edits text.

Why is it so cool? Well, in the Unix world, there are basically two text editors: vi and emacs. They are fruitful, and multiply, and so there are vim and gvim and xemacs and so on. There are other options, like Nirvana Edit and Nano/Pico and such, but vi and emacs dominate the text editor landscape.

A lot of programmers I really respect use Emacs. One in particular, Steve Yegge, got me thinking when I read stuff like the following. Incidentally, if you're a computer programmer, you could do worse than read his two blogs. He has a somewhat unique perspective as an employee of first Amazon, then Google, not to mention the creator and maintainer of Wyvern, which can be described as a cross between Nethack and MUDs. In other words, whether you agree with all he says or not, he's brilliant. So listen:

Emacs is the world's best text editor. It's not just the best for editing program source; it's the best for any kind of text-editing. Mastering Emacs will make you more effective at writing and editing email, documentation drafts, blogs, HTML pages, XML files, and virtually everything else that requires any typing.


The original brilliant guys and gals here only allowed two languages in Amazon's hallowed source repository: C and Lisp.

Go figure.

They all used Emacs, of course. Hell, Eric Benson was one of the authors of XEmacs. All of the greatest engineers in the world use Emacs. The world-changer types. Not the great gal in the cube next to you. Not Fred, the amazing guy down the hall. I'm talking about the greatest software developers of our profession, the ones who changed the face of the industry. The James Goslings, the Donald Knuths, the Paul Grahams, the Jamie Zawinskis, the Eric Bensons. Real engineers use Emacs. You have to be way smart to use it well, and it makes you incredibly powerful if you can master it.


In the meantime, Emacs isn't going anywhere, and Emacs-Lisp isn't going anywhere, not for several decades at least, so it will benefit you to learn them deeply. It will never be obsolete knowledge. You might as well start learning it now, and reap the benefits now.

and finally, the quote that always gets me:

Old algorithms don't suck, unless perhaps you count Bubble Sort. Generally, the more tried-and-true an algorithm or data structure is (DFS, BFS, quicksort, binary search, hashing, etc.), the more confidence you have in it. Ideas are fundamental and timeless, but technologies are always replaced.

Lisp straddles the line between a fundamental idea and a technology — which is another reason it took me so long to settle on it. And in many ways I'm still unhappy with it. But I believe it's the best thing out there, and will continue to be so for (at least) my lifetime. (My bet on Emacs fifteen years ago is still paying off.)

I realized that I was standing at the cusp of a unique opportunity in my career: I could make a great bet, hardly risky at this point given three decades of history on this one. The bet would improve my productivity and understanding for years to come. So why not?

Something just got to me in the last couple of days. I decided to get out Learning Gnu Emacs, read the first few chapters, then just decided that it was time. I knew enough to be dangerous, and I'd look up things in the book when I found I wanted to do them. I got myself running at work, my shell in one window and my text in the split screen, and I really didn't look back.

I was practically getting shivers. It was exciting, to see things just working, to get my fingers used to messing around. There is a reason why you just start up Emacs and don't leave the environment for the rest of the day.

I asked our sysadmin to get Emacs 22, which came out more recently than what we had (Emacs 19 from 1997!), and then tried to build it from source myself. That was a little ambitious for Day One, it turned out. But Day Two should get it going smoothly.

This is one of those programmer rites of passage, like customizing your prompt and terminal. I'm sort of getting it at the same time that I really want to get Unix. On those lines, I also got Classic Shell Scripting so I can pursue another decades-old programming tradition.

I even got Linus Torvalds' biography from the library.

The only regret I have is that I'm putting learning operating systems and compilers on the shelf for a little while to get all this done. But I figure that learning the Unix Way first will be worth it. (For the Unix Way, see also Eric S Raymond's stuff: The Art of Unix Programming, How To Become A Hacker, The Unix and Internet Fundamentals HOWTO, and of course, The Cathedral and the Bazaar.)


Dean said...

On a whim I followed a link to your web site from Vince's. Nice to see you have a job you are enjoying and building a life in Denver...I know right about where you live.

I once spent about 6 months learning Emacs and now when I work on Linux, I use gvim :)

Let me suggest an analogy: I do a LOT of cycling. When I was younger I used to lust at the expensive components, aero wheels, etc of the "good" cyclists. If I just had a set of tri-spokes I'd be that much better. It turns out, the engine is the most important part of the bike.

The guys you mention are brilliant and productive apart from their use of Emacs. I honestly believe if they used a different set of tools, you'd hardly notice a difference in their productivity, particularly when we talk about Unix/Linux kind of development.

I know you know this, I just feel better saying it.

Dean M.

Jen said...

Wow, that really is a whole of geek leakage. Sounds a bit like Charlie Brown's teacher or mom or whoever went "waaaah waaah waaaaah."

Eko Hermiyanto said...

GNU, Scheme, and Emacs are the only way to do computing. Thanks to RMS for creating the almighty Emacs!!!!

The King has spoken,

Dan Lewis said...

Thanks Eko.

I wouldn't call it the _only_ way to program (especially Scheme! I haven't gotten all the way through mzscheme yet, and I use C++ and Perl at work), but it has gone a long way toward improving my day.