Follow us on Twitter for more great Slate stories! Follow @slate

BITWISE DECODING THE TECH WORLD.

MAY 9 2014 9:57 AM The Oldest Rivalry in Computing Forget Apple vs. Google. and have been battling for text-editor supremacy among programmers for 40 years.

By David Auerbach

An early Emacs manual cover from 1981. Courtesy of GNU Emacs

n a world where both software and hardware frequently become obsolete right I on release, two rival programs can stake a claim to being among the longest-lived applications of all time. Both programs are about to enter their fifth decades. Both programs are text editors, for inputting and editing code, data files, raw HTML Web pages, and anything else. And they are mortal enemies.

Their names are Emacs and Vi (styled by programmers as “vi”). These editors are legendary and ancient, no exaggeration. Both date back to at least 1976, making them older than the vast majority of people currently using them. Both programs are text editors, which means they are not WYSIWYG (what you see is what you get)—unlike, say, word processors like Microsoft Word, they do not format your words onscreen. Programming is very different from word processing, and the basic goal of Emacs and Vi—fast editing of source code (and any other text files)—has yet to become obsolete. Both have been in ongoing development for almost 40 years.

These two wizened programs are as close to equally matched enemies as any two programs have ever been. If you know a programmer who uses one of them, there’s a good chance that she hates the other. I’ve stuck with Emacs for most of my career; my wife prefers to use , a popular Vi clone that stands for “VI iMproved.” We don’t talk about it, lest we become casualties of the so-called .

Advertisement

The oppositions don’t stop there. Vi was developed by the legendary Bill Joy (who went on to found Sun Microsystems and create Java) while a grad student at Berkeley. It was later included as a closed-source program in most operating systems, though open-source clones have existed since the mid-1980s and dominate today. Emacs got its start all the way across the country at MIT, a project by Guy Steele and , but it only gained prominence when the equally legendary Stallman developed a much more powerful variant, GNU Emacs, in the mid-1980s as part of the movement that Stallman spearheaded.* While Vi remained small and slick, Emacs embraced extensibility and epic size. (Emacs, a joke goes, stood for “Emacs Makes a Computer Slow” and “Eight Megabytes and Constantly Swapping” back when 8 megabytes was a huge amount of memory.) Emacs was so flexible that it could even alter its interface and behavior to look and act exactly like Vi, if you really wanted. Vi’s user interface since 1976 or so. Courtesy of Vi

Emacs emulating Vi. Courtesy of George Leontiev Vi haters say you only need to know one command—the three-character combo “:q!”—because that’s the quit command. I was baffled the first time I used Vi because I couldn’t even figure out how to enter text. Typing just produced a series of beeps. The arrow keys did nothing. And of course I didn’t know the command to quit. A classmate explained what was up, which was that Vi starts up in “normal ,” which rather abnormally does not allow for entering new text but only editing of existing text. You have to type “i” to go into “insert mode,” which will allow you to type freely. Hit the and you’re back in normal mode, where I typed “:q!,” my other piece of new knowledge, and disconcertedly switched back to Emacs.

That brutal introduction is representative of Vi’s learning curve, as depicted in this chart. The upside is that mastering Vi’s arcane command set yields a powerful and lightning-fast editor. I suspect that expert Vi users are capable of making manual edits faster than people in any other program, not just because the command sequences are so cryptically compressed, but because Vi itself has very low overhead, responding instantly to almost any task you set it to. It is unmatched at what programmer Larry Marburger terms text surgery. Jump back five words? “5b”! Delete the next six lines? “d6j”! Search for the next instance of whatever word the cursor happens to be on? “*”! Put quotation marks around every line in a file? Eighteen keystrokes: “:%s/\(^\|$\)/\"/g”

Coincidentally, these are also the obscenicons of the reaction most people will have when they see that set of commands. I’m rusty, so it took me a few minutes to create that combo, but a Vi veteran could come up with it in seconds. (Really.) Just memorize this Vi cheat sheet and you’re ready for lightning-quick editing. Courtesy of viemu.com

Vi was written for a time when computers were slow enough that you didn’t want anything causing unnecessary delays—like extra keystrokes or graphical niceties. Joy tailored it for computers that had net connections that printed out text slower than people could read. As Joy said in 1999, “I was trying to make it usable over a 300 baud modem ... the editor was optimized so that you could edit and feel productive when it was painting slower than you could think.” But even now that unparalleled efficiency has its adherents among people who are driven mad by the slightest delay in their productivity. (For example, software engineers.) Vi is one of the few programs you can use without moving your hands from their default touch-typing position: You don’t even need the arrow keys (that’s what H, J, K, and L are for).

Emacs, on the other hand, offers a far more conventional and accessible editing environment, with commands based on reasonably intuitive combinations: Ctrl-S lets you search, Ctrl-X Ctrl-S saves the file to disk, and so on. The program provides more feedback to the user and is less prone to beeping rudely at novices than Vi. It does lovely text formatting and has lots of helpful features for coders in many, many languages. But Emacs would be nothing special if it stopped there. Where Emacs excels is in its flexibility. You can customize everything. For example, most command sequences begin with the Esc key or the Ctl key, including the Esc-X sequence that gets you to a searchable, list of all commands. But those two keys are murder on your pinkies, and programmers have specifically blamed them for repetitive strain injury; my left pinky is getting a twinge even as I write this. But it doesn’t have to be a problem, since Emacs lets you remap key bindings with ease, so you can change the Ctl key to the caps lock key and Esc to the . Beyond that, pretty much any command can be mapped to any key or key combination. Programmers can customize Emacs down to the tiniest detail to serve their particular needs. God help the schmoe who tries to use your Emacs, but that’s not your problem ... until you’re stuck on someone else’s machine.

Emacs has its own internal programming language, a variant of LISP, that allows you to program all sorts of functionality into the editor: not just text editing and formatting functionality, but really anything, be it a file system, a clock, a , text adventures, instant messaging, and so on, to the point that you really can do most of your daily business in Emacs if you so choose, as certain Emacs fans I know have done —you never have to switch windows! Emacs offers a much gentler initial learning curve than Vi, but the curve never ends, only spiraling into increasing complexity. The endless possibilities of Emacs can consume your life and productivity.

So the broad outline of the two warring programs should be clear. On the one hand, the austere elegance of Vi, which allows programmers to achieve trancelike focus while moving their fingers as little as possible. On the other, the all-encompassing, flexible universe of Emacs, which you can customize and extend until it meets your most idiosyncratic requirements. Vi’s standardized perfection and Emacs’ abstract generality are two of the highest ideals of engineers. The war between the two programs should tell you that these ideals are often not quite compatible.

Sometimes it boils down to people’s personalities: whether they prefer to bend to a rigid but popular system (like Vi) or to create a singular environment for themselves (with Emacs). Tim O’Reilly, of O’Reilly Media, switched to Vi after his customized Emacs setup had inadvertently been destroyed. He decided to follow the “cult of Vi,” praising Vi’s ubiquity: “It was just there on any system I sat down at.” (Still, he said, “I don't want to pour gasoline on this fire.”) inventor , on the other hand, not only prefers Emacs (a somewhat stripped-down variant called MicroEmacs, to be precise), but has even modified the underlying code to make it even more suited to his particular needs.

Top Comment

A story I still tell on occasion is that in late 1995 I gave an interdisciplinary physics/math/engineering colloquium, the theme of which was contrasting the continuous vs. the discrete representations of physical quantities. (Basically theory vs. approximation. More... -Tom Marchioro

191 Comments Join In

While Emacs can emulate Vi (to a point), it can’t catch up to it. Even the biggest Vi detractor will not dispute that it’s faster than Emacs. (The Vi fanatic will say that you can learn the Vi command set in the time it takes for Emacs to start up.) Make no mistake, Emacs is still considerably faster than a graphical editor like or Microsoft Visual Studio, but Vi partisans see no reason to sacrifice any efficiency to Emacs’ bloat. The Emacs fan will respond that you start up Emacs just once and leave it running, preferably forever. Let Emacs become your . Emacs as operating system. Courtesy of the author

But any programmer will sometimes have to make edits on a different system, possibly even one without Emacs installed (horrors!), and at those times Emacs is a 16-ton weight attached to your shoes. So many Emacs users will grudgingly learn the basics of Vi to use in a pinch. In turn, Vi’s narrowness has softened over the years, as it has taken on more features and more extensions to the point where, in its more powerful clones like Vim, it offers a good number of Emacs’ more popular and mainstream editing features (as well as Tetris).

So the two enemies have gradually moved a bit toward convergence. The preference for one over the other is frequently not practical but philosophical and aesthetic: Which ideal, focus or flexibility, is closer to your heart? Which would you save first from a burning house? Engineering is in large part the art of coping with imperfection and incompatibility, and the compromises made are not purely utilitarian, but reveal a particular engineer’s sense of what is the most beautiful option—or more frequently, the least ugly. Correction, June 18, 2014: This article originally stated that Richard Stallman spearheaded the open-source software movement. Stallman started the . (Return.)

NEWS & POLITICS

POLITICS

JUNE 2 2015 6:55 PM The Hawks Return George W. Bush and Dick Cheney were reviled at the end of their administration. Now their disastrous ideas are flying high.

Jamelle Bouie

The Supreme Court’s Logical, Humane Ruling for a Man Who Hid Drugs in His Sock Rand Paul Is Rand Paul’s Worst Enemy

Why Almost Nothing Is As Resilient As Hillary Clinton’s Popularity

The Supreme Court Really Cares About What This Facebook Poster Was Thinking

I Called the Police Blotter in the Point Reyes Light the Best in the Country. Was I Totally Wrong?

The USA Freedom Act Won’t Harm National Security

Dennis Hastert Is Being Treated Fairly, According to Dennis Hastert

BUSINESS

MONEYBOX JUNE 2 2015 6:13 PM American Apparel Got a Restraining Order Against Its Jilted Former CEO

Alison Griswold

Smart Poor Kids Are Less Likely to Graduate From College Than Middling Rich Kids

How to Get Rich from El Niño

Walmart Is Giving More Employees Raises to Fix Its Long Lines and Empty Shelves

An Insurer Wants to Raise Its Obamacare Premiums by 85 Percent. Don't Sweat It.

Netflix Is Running Ads That It Insists Aren’t Ads

Global Warming Is Drying Up Dams. So Why Is the World Doubling Down on Hydropower?

New York City Wanted to Approve Tons of Changes to Uber’s App. All of Tech Freaked Out.

LIFE

THE HISTORY OF AMERICAN SLAVERY JUNE 2 2015 4:51 PM Inside the Slave Ship History of American Slavery, Ep 2: The Atlantic slave trade during its heyday and the remarkable life of Olaudah Equiano.

Jamelle Bouie and Rebecca Onion

Why Do Comic Books Mean So Much to Some Queer People?

Mike Huckabee Says He Would Have Pretended to Be Trans to Shower With Girls in School

Help! My Husband Rails Against People Who Misspell Our Last Name.

North Carolina May Soon Let Clerks Refuse Marriage Licenses to Gay and Interracial Couples

Should Teachers Friend Their Students on Facebook?

For a Lesson in Biphobia, Look No Further Than The Bachelorette

This Meteorite Hit an Alabama Woman While She Was Napping on Her Couch

DOUBLE X

THE XX FACTOR JUNE 2 2015 5:04 PM Lauren Conrad’s “Body Positive” Message Is a Good Start but Misses the Mark

Laura Bradley

Should You Bring Your Baby to TED?

Area Man Takes Creepshot of Nursing Mother Because Her Breast Frightened Him, Terror Spreads Via Social Media

The “Quickening” Used to Be a Momentous Event. How Did It Fall Out of Favor?

Phantom Skulls and Former Fetuses in Fisticuffs: It’s the Worst State of the Week Rankings

If We Want to Help Working Mothers, We Could Start With Paid Paternity Leave

Denver ComicCon Convenes a “Women in Comics” Panel, Forgets to Invite Women

Why Did Republicans Love the Duggars So Much?

SLATE PLUS SLATE FARE

JUNE 2 2015 5:21 PM Get Discounted Tickets to Slate’s Political Gabfest Live in D.. Here’s how to get access to our 24-hour presale, plus 30 percent oᕙ your ticket purchase.

The History of American Slavery, Episode 2: Complete Transcript

To the Teacher Who Changed My Life: Thank You (Audio)

What Comes Up When Slate Writers Google Their Own Names. Which They Do. All the Time.

From Wedding Debt to the Evolution Debate, These Were the Best Stories Published in Slate This Week ARTS

BROW BEAT

JUNE 2 2015 9:09 PM If The Shawshank Redemption Were an 8­Bit Video Game

Sharan Shetty

Why Did The Bachelorette Censor Random Anatomical Words During Its Absurd Sex Segment?

Here’s the First Teaser Trailer for Pixar’s Next Movie, The Good Dinosaur

The Great Trick Filmmakers Use to Empower Monologues

Michael Shannon Is the Gordon Gekko of Real Estate in the First Trailer for 99 Homes No One Talks About Community Anymore. Here’s Why We Should.

“What a Spray! What a Lovely Spray!” Mad Max’s War Boys Review Spray Cans on Amazon

TECHNOLOGY

FUTURE TENSE

JUNE 2 2015 7:08 PM Senate Approves USA Freedom Act, Which Ends NSA Bulk Surveillance

Lily Hay Newman

A Slice of America’s Tech Workers Is Primed to Desert the Democratic Party. And Rand Paul Wants Them.

People Were Talking About the Ebola Epidemic on Twitter Three Days Before Health Officials

Uber “Partnered” With Carnegie Mellon, Then Betrayed It. Here’s How Everyone Wins.

The U.S. Government Is Addicted to Secrets

How Drones Can Help Indigenous People Protect Their Land

Facebook Will Send You Encrypted Emails (If You’re Into That Sort of Thing)

HEALTH & SCIENCE

WILD THINGS JUNE 2 2015 3:26 PM Going It Alone

Rachel E. Gross

NASA Orders First Round of Crew Launches from Boeing

School Boards, Principals, and Teachers Are Pushing Creationism on Kids

Science Advice and Sexual Harassment

An Abortion Provider Describes What It’s Like to Have to Lie to Patients

Cassini's Last Visit to a Bizarre World

Bad Astronomy Video: Going to Europa

SPORTS

THE SPOT JUNE 2 2015 1:07 PM Sepp Blatter Is the King of World Cup Jerks

Jeremy Stahl

Why Fewer Goals at the Women’s World Cup Means More Excitement and Better Play

Olympics, FIFA, Congress, or Dictator? Take Our Bribery Quiz!

Why the American Justice System Actually Stands a Chance Against FIFA

Ali­Liston 50 Years Later: The Real Story Behind the Greatest Sports Photo of All Time

The Indy 500 Is Turning Into a Car­Flipping Debacle. How Organizers Can Fix It.

Deflategate Has Sent New England Patriots Fans Over the Deep End

Slate is published by The Slate Group, a Graham Holdings Company. All contents © 2014 The Slate Group LLC. All rights reserved.