Jun. 7th, 2008 09:42 pm Editor Wars: Revenge of the... oh, whatever. You know, I've never understood the whole Editor War thing.



(Before we get started, I'll pause to let all you dumb vi users think up some really good insults.)



(What are you laughing about, emacs guys? You don't have time for that, you need to be using this time to get started on another of your interminable, self-absorbed rants.)



(You TextMate kiddies aren't even invited. This is a war that started before you were even born. Just keep licking your screens and eating paint chips.)



(And all you Windows users... well, to start with you need to know that there's this thing called the "Editor War" that's been going on since 1976, and it--hmm. You know what? Just skip this post. Bye!)



So... the Editor War. A couple of uncomfortable experiences at RailsConf made me realize that the war may have gone cold, but it is still very much alive.



Here's my take on the whole which-editor-is-better thing:



First Point. I use all three editors mentioned above. I use emacs on my "real computers": Windows and Linux desktops, and my MacBook Pro, because emacs will give you godlike editing power if you are willing to pay the price. I use Vim on my PDA/cellphone because it's tiny and fast (and my PDA doesn't have Ctrl or Alt keys). And I use TextMate on my MBP whenever I need to share an editing session with my teammates. They all use and love TextMate, so it's the editor of choice for shared meaning.



Second Point. There is a significant percentage of people out there using one of those editors who will now hate me because I use the other two. You are the reason I need to get this off my chest, and for you my entire point is this: You people need to shut the hell up.



Third Point. As an illustration of what I mean in the Second Point, I hold no opinion as to which editor you should use. At least, not without some more information about you and how you like to edit. Do you consider an editor to be little more than a typing area with cursor keys and a clipboard? Any of those editors will be far more than you will want or need. You should use Notepad, Nano, or TextEdit, whichever came with your OS.



Fourth Point. If you are a power editor but you've never really thought about your editor beyond how to get things done, like mass search and replace, keyboard macros, and syntax highlighting, then any of those editors will make you happy. Vi was made to drop to bash and work with other unixlike "small, sharp" tools. TextMate has a huge arrangement of very useful bells and whistles. And Emacs can power edit all day long without breaking a sweat--or even breaking into lisp.



Fifth Point. If you are a totally crazy power editor, you're going to want to start scripting your editor. Here is where we start to lose the vi guys. Not because they can't keep up, but because they think we've left the realm of editing and entered the realm of programming. They can do everything we're going to do here, but they see it as a distinct activity: they'll use vi to write a bash script then call it from vi; they don't consider this vi scripting. TextMate takes the external script metaphor and wraps it in a clean, lickable interface; you write a bundle in bash or Ruby or Python and TextMate lets you run it from whatever hotkey you want to assign. And emacs... well, emacslisp is an infinitely deep rabbithole full of LSD.



Sixth Point. I forgot what the sixth point was, because I'm still tripping out on emacslisp. Woo.



Seventh Point. I don't have an opinion on what text editor you should use, but if you are a programmer, you should know your editor. Learn its ins and outs. Learn how it formats regular expressions, and use them. Learn how it can be scripted, and script it. At a minimum, you should be able to do all of the following in your sleep:



Replace every instance of "foo" with "bar" in every file your project, without trashing your .git or .svn indexes. (If you don't know what a .git or .svn index is, well, this is why I told you Windows users to skip this post. Shoo, shoo!)



Replace every 8-digit date like 20080607 with a hyphenated date like 2008-06-07.



Take a list of usernames like "'alice jones', 'bob smith', 'carol johnson'" and turn them into a hash like "ALICE_JONES => 'alice jones', BOB_SMITH => 'bob smith', CAROL_JOHNSON => 'carol johnson'"

If you're editing code, you should also be able to

Select a block of code and comment it in or out.



Jump to the definition of a class, symbol or function.



Compile your code.



Run your unit tests.



Launch your debugger.

Those last three are more of an IDE thing than an editor thing, but all three editors can do them, and if you're not using them, you're not using the power available to you. For all intents and purposes, this means that you are stupid.



Eight Point. There are people out there who are smarter than you who use emacs. Deal with it.



Ninth Point. There are people out there who are smarter than you who use vi. Deal with it.



Tenth Point. There are people out there who are smarter than you who use TextMate. Deal with it.



Eleventh Point. Emacs is the most powerful of the three by a full order of magnitude. If you don't believe this, you don't know what the hell you are talking about. Vi users will freely concede this, they don't think an editor should do all those things. TextMate can run scripts but it bundles features together rather than forcing every feature to be fully composable with all the other features. Example: Can you Go To File using fuzzy matching anywhere on your hard drive?



Twelfth Point. The good news for emacs haters is this: if you don't like it, you don't ever have to learn it. Hard work pays off in the end, laziness pays off now. See point 18 before you stop reading, though.



Thirteenth Point. Emacs is the hardest editor to get full use out of. It may be ten times more powerful than TextMate, but it's a hundred times harder to get used to. In TextMate, you click Preferences and choose colors. In emacs, you have to write a file called .emacs. This file is a lisp program. Your first time using emacs you'll just cadge someone's .emacs file and pray you never have to understand all those parentheses. But you'll have to, before you can witness the firepower of this fully armed and operational text editor. If you want to have conversations with your code, and have your code talk back meaningfully, you should look at emacs.



Fourteenth Point. Sorry, tripping out on emacslisp again.



Fifteenth Point. If you use Linux, you have to know Vi. It's on every system, requires no special configuration, and lives up to it's "small, sharp" heritage. If you can't bring yourself to memorize the keys, print out the cheatsheet and keep it handy for when you have to do some emergency editing.



Sixteenth Point. Vim is not a toy. It is a full power editor in its own right. It has syntax coloring, smart indentation, and a clean separation between command and editing modes that make it possible to shovel text around wholesale. If you're a power editor who wants the code to line up, sit down, and not talk back, Vim can make you happy.



Seventeenth Point. When it comes to sheer editing power, TextMate sure has a pretty interface. Actually, it's also powerful enough to stand unashamed next to vi and emacs. Like vi, TextMate lets you go off and script modules to do anything you want. But also like vi, those modules are siloed from one another and from the editor, so mixing and matching partial features doesn't happen. Unlike emacs and vi, however, you can make those modules look dead sexy with html, css, and even javascript in the UI.



Eighteenth Point. If you are bumping your head on the ceiling of your editor, you need to learn emacs. Emacs is an order of magnitude more powerful, and two orders of magnitude harder to learn. But if you are frustrated with your editor's inability to keep up, saving time by not learning emacs is a false economy. Once you pay the price to learn it, you get to reap the benefits of its power. And the longer you put up with a frustrating editor, the longer you risk believing that what you are getting is all there ever is.



Which editor is the best? It exactly like asking which spaghetti sauce is best: different people like different things.



(And everybody who doesn't like chunky vegetable marinara is ugly and stupid.)



Life is too short to not be happy with your editor. And it's way the hell too short to not be happy with anybody else's choice of editor. Current Mood: cranky

Current Music: Alive 2007 - Daft Punk

78 comments - Leave a comment