sabato 2 febbraio 2013

My story about using GNU Emacs

GNU Emacs is surely the program I use for the most of the time I spend in front of a computer. It is the first program I install into a new machine and it is my favourite editor.
I started using GNU Emacs back to the days when I was an university student. In those days I was attending an Operating Systems course that was based on Unix, and being Unix a system where handling text files (both for configuration or programming) is so important, the course had a particular focus on the vi text editor. 
I have to admit: I hate vi with the passion. Is not that I don't see how powerful it is, but I find the editor too awkward for me to use in day-by-day activity. 
Am I in the editing mode? Command mode? Aline mode? What is that ~ at the beginning of each line? You get the idea of what I was thinking!

However, at that time I both did not have the choice to switch to another editor (because the exam had to be done in vi!) and I did not have enough skills to evaluate another editor.
The only choice was therefore to study vi and try to understand why my professors were so excited in using it. And my hate raised up again when I discovered that they were teaching us a really inefficient way of using the editor itself. As an instance, the official course documentation mentioned the :wq! way of exiting the editor without forgetting to save the current file. Well, good luck with make then! I found that ZZ was a more intelligent way of exiting having the editor to save only if really needed, and therefore without modifying the file metadata and without firing up a make each time. Well, begin an university course, the projects were really limited to a few files, so having to run make each time was not a big deal, but the fact is that each tool should be used in the much proper way. As another example, there were no explaination about splitting windows, regular expression search and so on. After all, they were teaching vi much more like an Unix Notepad application!
Actually, I see a lot of my colleagues that still proudly use vi in a very elemntary way, and others that have chosen to switch to Notepad++ because it is much more powerful.
Sorry guys, you are using the tools in the wrong way!

Last but not least, not only university was teaching vi in a bad way, but for the worst reason ever! In fact, one reason to study vi was that "it is an editor you can find on any Unix installation". I discovered years later that it was not true at all, and in fact many Unixes does not include vi in the base system. Another reason gave to us from the professors was
that "it can run even when X Window does not work", and while this is true, I have to mention that professors were using SSH to connect to servers from Microsoft Windows clients and that none of the servers at the university were running X Window. So who cares if the editor works or not with X?

Once the Operating System course was over, I decided to study another editor for my incoming Unix activity, and since I did not want to waste my time learning some naive program, I decided to give a try to the other World's Dominating Editor: GNU Emacs.
Well, I cannot explain why, but the GNU Emacs commands were simpler for me to remember than the vi modes one, even if I have to admit that both have a very cryptic set of keyboard mappings! The only drawback of Emacs at that time was the resource consumption: Emacs required a few megabytes, around 32/64, and for my poor Intel Celeron 700 MHz with 192 MB of RAM it was a big deal to load the editor. But once
it was loaded it was fast and responsive. And by the way, it was much lighter than Forte4Java or Eclipse!
At least Emacs had a status bar (the mode line) and the minibuffer and there was also a X port, even if I never used it because I wanted to learn the "real" terminal one application. For a lot of time I was using Emacs as a pure editor, and the set of commands I knew were the basic ones that allowed me to do the routinely work. And I was proud to be almost the only guy that was firing up Emacs instead of vi in the whole laboratory!

Then came the days of my master degree thesis. As usual (for me), I decided to use the thesis as an excuse to learn other tools, so I picked up Borland (now Inprise) JBuilder for the Java development, LaTeX and Emacs for writing the documentation, Umbrello UML Modeller and Dia for the diagrams and pictures. Everything was going fine, and my LaTeX file was growing quickly: at the end it was more than 84000 words and more than 9300 lines. Emacs was working diligently, without showing any problem with such a big file. Almost at the end of the thesis, when I was relaxing and enjoying the last days of work, I decided to give a try to other editors: Kate (the default editor for the KDE environment) and Kyle (an ad-hoc editor for LaTeX). The result was horrible in both cases: Kyle was crashing on each forward-search I was doing, and Kate was extremely slow even in jumping from the beginning to the end.
This little and simple experiment convinced me that there was no need to search for another good editor, and that Emacs was what I needed for almost every job.

The next year I was working as sysadmin and developer and I was using Emacs for pretty much everything I did including scripting, Perl  programming, text processing and so on. The only programming  language I was not using Emacs for was Java, since I was switching to Eclipse (a tool I still use for Java development). In particular I had also to
develop in a strange language, Dataflex, that is similar someway to Cobol. I was disappointed to see that Emacs did not had a specific major mode for such language, but at least it was something I could use for doing my programs!

I continued to use Emacs for several years, pretty much for any editing that does not involve a whole IDE. And often I fire up Emacs when I want to have a quick view at files or folders without having to start
a more complex and heavy tool. Sometime I try other IDEs, because I believe that one should always try everything, but sooner or later I always come back to Emacs. The "heavy" factor is no more important these days: Emacs has not grown in size as other tools (like Eclipse) did, and therefore is fast to load and always responsive.

Last year I decided to study Emacs Lisp, in order to improve both my developer and Emacs skills. I have to admit that elisp is not my ideal language, but it is fun enough for me to write some function to  instrument the editor to do what I want, when I want, where I want. And this is the power of Emacs.
Today a lot of people think at Emacs as a text editor, but Emacs is a text editor as much as Eclipse is a Java IDE: this is not true! 
Eclipse is a whole Java platform on top of which the IDE is the mainstream product and Equinox is the reference platform;
Emacs is a lisp interpreter on top of which you can work with files. 
This is what I see.

Today, thanks to Org mode, Magit, Autocomplete and other features, Emacs is really a great environment to spend the whole day into.

Nessun commento: