My environment and tools

Terminal

On MacOS X, I use the standard Terminal program. On Cygwin, I use mintty (now the default), it has native Windows font rendering and looks nice.

Font

I recommend DejaVu – it covers a large amount of Unicode character set and is rather pretty.

Colours

I use black on white (light-grey, actually). I don’t syntax-highlight text, because this distracts me. Everything that exists on the screen should have meaning. When you have some words in blue and some in green, that should mean different things, so it adds a layer of functional semantics on top of the text semantics. Sometimes it’s appropriate — like when appearance of a link in a web page is different from appearance of a simple text. But in the source code you already have that semantics defined by the language, so why duplicate it? Of course that’s not obvious when you’ve used an IDE through all of your career.

Keyboard typing scheme

By saying “typing scheme” I mean how you type “chords” which are a combination of multiple keys pressed together.

There’s a scheme which I find easy, convenient and universal: press all modifiers by one hand and the actual character by another.

C-M-n is typed like this: Control-Alt by the left hand, n by the right. M-% is typed like this: Alt-Shift by the right hand, 5 by the left. When the target character is in the left half of the keyboard, press modifiers on the right, and vice versa. This approach also reduces the harm which repetitive strain does to your hands (press C-t by the left hand to understand what I mean).

If you look at the design of the “Space Cadet” keyboard (the Wikipedia says it influenced the design of Emacs), you won’t be surprised: the modifier keys are grouped together. By the way, it had seven modifier keys! Of which, “hyper” and “super” still can be used in Emacs — you can assign them to some keys and bind commands as usual.

Switching buffers

There’s a basic, but frequently overlooked feature in minibuffer called “future history”. This is suggestions which M-n skips through while in minibuffer. Its contents are the same as C-x C-b shows. And it’s incrementally-searchable via C-s! So you type C-x b, C-s, then some part of the buffer name – and skip through matching names with C-s until you see the desired buffer name.

Recursive dired

If you have many files in many directories in a (sub-)project (which is common for Java projects), you can use C-u s to add ‘-R’ ls option. With ‘dired-isearch-filenames’ set to ‘t’, you can then isearch files by name conveniently.

Info manuals

To switch between info manuals more convenient, assign for yourself numbers for frequently-used manuals, remember them and use prefix argument for C-h i. Like, M-2 C-h i will always open elisp manual, M-3 C-h i – manual for cc-mode etc. Bind ‘info-display-manual’ on some convenient key; with C-u it limit offered manuals to already opened.

Cygwin

On Windows, I use Cygwin. It is basically a Windows DLL offering an implementation of POSIX system functions, so it allows to compile for Windows a program that’s written for GNU/Linux or other *nixes. If offers many pre-compiled packages including Bash and Emacs.

There was a long-standing Cygwin problem with loading when multiple DLLs collided in memory, but it was fixed some years ago by introducing an internal table of addresses and there are no serious problems now. There’s a special program call rebase (and rebaseall variant) which fixes the DLLs, it is usually run automatically after Cygwin setup. You have to know this in case you’re building something yourself. Read the Cygwin user guide for more information.

There’s a special option for people using Cygwin on Windows — a separate package called emacs-w32. It is a version of Emacs which uses native Windows GUI. That’s important because you get font anti-aliasing and rendering as in mintty.

Posted in emacs | Leave a comment

A novelist programmer

It’s not hard to see analogy between a writer and a computer programmer. Both have a concept which they materialize in their work. Design and architecture are plot. Phrases are statements. Chapters are modules. Syntax is the rules which make the text readable (both by humans and machines). It’s not hard to observe analogies between a reader and a computer programmer, too. Although it’s not common to just read the program code for pleasure, it’s rather common to read it for knowledge.

Let’s imagine a book with a complex plot. It has a lot of intricacies, it’s long and twisted. The same could be said about a complex program. Writers of both need to understand the concepts behind them deeply. A thorough investigation is needed to gain deep understanding of their views and intentions. This requires time, experience and good memory. One has to “dive” into the book or program and stay for a long time there.

While it’s not very practical to modify the existing book, modifying a program is often desired and/or needed. This is where the processes differ, but the distinction is not harmful for our discussion. The distinction is natural — a book is a finished product or art object which expresses someone’s thoughts and opinions, while the program is basically a tool which is expected to be improved after its creation. This difference should be reflected in the works themselves. A book can be of any structure, while the program should be readable and understandable – that is, easy to maintain.

By now, we were talking about what we called “complex” narrations. But there can be a collection of short novels, possibly united by means of some literature techniques. A reader is generally not expected to read through all the book from the first page to the last, but rather she could open it at any page and start reading. The novels could be treated as parts of some bigger entity, but nevertheless they are somewhat independent of each other. Returning to the programming, it should be easy to understand isolated modules, and after that a programmer is ready to change whatever she wants. Such modifications could be called “short-term tasks”, which do not require the understanding of the whole system.

It’s different with “long-term tasks”. In case of complicated work one has to follow all the turns of the author’s thought and create a detailed “map” in their head. This often makes the reading interesting, but absolutely does not suit when the goal is practical — that is, not an entertainment. Digging into such work will be time-consuming and sometimes just boring. But it is required. Contrast this with learning a system step-by-step, by gathering knowledge of different parts and then integrating them in the head and thus seeeing how they are interconnected and interact with each other. The progress can be seen immediately. Of course, to make a big change (like altering the concept of a whole book) one still has to learn everything, but that is just an increase in scale. Small changes can be done instantly.

That is, we can say that a good program is similar to a collection of short novels or to a good-structured educational material.

Posted in comp.misc | Leave a comment