In Love with Emacs
Yes, another geek post, but only because I’ve really fallen in love with Emacs.
For those of you who aren’t in the open source loop, emacs (Editor MACroS) is a very popular text editor written by Richard Stallman, the founder of the GNU foundation. It’s also been around longer than I’ve been on this planet, having been written in 1975. It’s evolved through 21 different versions by now. Now you wonder why I would rant and rave about a text editor of all things, especially one that’s really old and “obscure”. Well, I believe it’s the best text editor ever. Ever!
To get a picture of why I love it so much, you’ve gotta understand the dexterity involved when programming. It is in no way like writing a document or letter. Rather, efficient programming is a mix of mental ability as well as hand-eye coordination. Sure, you can get away without learning to type properly and to use notepad or some basic editor. In fact, during my internship I’ve met programmers who type with two fingers while staring at the keys. But learning how to be efficient can really help the job run smoother by 3 or 4 factors.
Anyways, I discovered all this emacs handiness when I was hacking away at my graphics assignment in C++. I discovered my profs emacs configuration file and browsed through it. I discovered a goldmine of shortcuts and efficiencies.
To get a picture of the repetitive process of programming, this is typically what will happen repeatedly over a coding session:
1) Open up a few editor windows as reference. You write code based on other modules, so it’s usually handy to see what’s going on in other code files.
2) Write some code. As mentioned, this isn’t like writing a letter. You don’t write at the bottom of the letter. You make changes all over the place in a file, and across many files at a time even.
3) Compile your code and run it. Basically, when you have a partial or think you’ve finished what you have, you tell the machine to create the program based off of your code. If your code was improperly written or the program doesn’t run as desired, you have to go back and fix it.
4) Go back and fix errors by finding the line it occurred on.
Each of these actions can take quite a while and require a lot of hand-eye coordination and wasted movement.
Take for example switching between opened files on your computer:
1) Grab the mouse.
2) Use your eyes to locate the desired window.
3) Move mouse to select that window.
4) Click the window and locate the location of what you’re looking for in the document.
5) Select the location.
6) Move your hand from your mouse back to your keyboard. Repeat.
What if you could do all this in 2 steps instead, without ever having to lift your hands to switch back and forth between the mouse and keyboard without the need to use your eyes to scan for the documents you’re looking for.
Similarly, the act of compiling, running, and fixing code requires a lot of movements. You have to switch to the console to compile your code. Then you have to enter the command to run your code. Finally, you have to go track down your errors through the various code files, a process that requires a lot of searching and switching between windows (and more importantly, a lot switches between mouse and hand). Even if you use shortcut keys, with a simple text editor you have to let go of the keys to use the arrow keys and the page-up/page-down keys. That in itself is another unnecessary motion.
In emacs, to open a file you simple hit ctrl+x+f and enter in your file name. You can use that to switch between files in one single window. You don’t even have to enter in the entire file name, you just have to enter in a few letters and hit the autocomplete key. This saves you a lot of time in that there’s no scanning for windows and lifting your fingers off of the keyboard to grab the mouse, and to move your hand back to the keyboard to assume the typing position. One emacs window can open as many files as you like simultaneously.
Want to compile, run, and fix errors? Hit Alt+Shift+C to compile your code. If there’re any bugs, you hit F12 to goto the line that caused the bug. F12 again will take you to the next error line. Wanna run some code? Ctrl+Z will bring up the terminal inside of emacs. The compile-run-fix error task is now shrunk into a few keystrokes.
These few shortcuts are among many thousands of handy tricks you can do in emacs.
People who don’t code will think that the whole idea of shortcutting everything is silly. But when you think about it, these actions are done hundreds, if not thousands of times in a span of a few hours. Removing them helps one become a faster coder and puts less strain on doing repetitive motions.
A second catch in doing this is that in programming there’s often a rhythm. Often your mind will move faster than you can physically code. When I’m really into the zone, I can think up algorithms and solutions faster than I can translate them into code. The longer the gap is between what my mind can figure out, and what I can code, the harder it is to keep in rhythm to generate a solution. The more “in the zone” you can be, the faster and better your code will be.
It’s weird, I know. But I’m now a firm believer in this emacs business. In fact, it’s such a cool editor that my I’ve heard that my prof once dedicated an entire class lecture on the beauties and uses of Emacs.
I only wish that I looked into emacs and read the tutorial in first year. Sure, I’ve been using emacs for years throughout university. But beneath all the “basic” uses of it, I never took a look of how versatile and efficient it is until now. And it only required that I read through a short hour-long text tutorial embedded in the program.
I am grateful that I’ve found it now though, because it will save my precious coding hands from carpal tunnel hell.
Leave a Reply
Calendar
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| « Dec | Feb » | |||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
Categories
- Fighting (2)
- G33k (5)
- The Mundane (3)
- Uncategorized (125)
Archives
- July 2009
- May 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006