axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] On syntactic coloring of language


From: daly
Subject: [Axiom-developer] On syntactic coloring of language
Date: Mon, 19 May 2014 03:07:57 -0500

I had a debate about syntax highlighting of languages, an idea that
dates back to Ada, as near as I can determine. In Ada publications
it was traditional to highlight, by bold characters, all of the
keywords in the language. This notion continues today.

Highlighting, and in particular bolding, is intended to draw attention
to things of interest. In normal prose one highlights portions of text
that are under discussion, items of controversy, or famous quotes. The
technique is a primary tool of communication.

In computer languages, of which I have professionally coded in over 60,
it is usually used in the Ada tradition of highlighting syntax.

Several objections can be raised. 

First, suppose we applied this to English. We could make the editor
bold the 19 basic prepositions (at, after, by, down, for, from, in,
of, on, over, past, round, since, through, till, to, under, up, with).
While syntactically correct it is, to say the least, distracting.

This draws attention to these "keywords" in the sentence but, as a
native speaker of English, adds nothing worthwhile. In computer
languages this has the same effect. It is not at all useful to bold
keywords like IF, THEN, or ELSE. Any native speaker of the language
can see these at a glance. Bringing such "background" items to the
"foreground" of attention highlights the static, inverting the usual
use of the technique in communication.

Even worse, some languages don't have "keywords" in the usual sense.
In Lisp it is entirely possible to use the symbol "if" in any number
of contexts, only one of which invokes its meaning as a conditional
statement. It is a complete waste of cycles to dynamically re-parse
text that a native speaker can read.

Second, and worse, such highlighting undermines the most important
aspect of the technique, namely to draw the reader's attention to
something noteworthy. Bolding and other forms of highlighting are
textual means of emphasis in communication. Regular, repeated, and
non-communicative use removes this from the toolbox of the author.

Third, and on a personal aside, one often encounters color-coded
program text in these highlighting schemes. As someone who is
partially color blind it is often impossible to see some characters at
all. It is usually possible to change these settings online but in
printed text whole passages are unreadable. Thus

   void foo(char *x) {
     if (x > b) then c else d;
   }

in certain colors becomes

       foo(     x) 
       (x   b)      c       d

which, I must say, certainly de-emphasizes the language syntax though
losing a bit in semantics. :-)

So consider the difference between "coding for yourself" where your
editor highlights code in pretty rainbow colors and "coding or writing
for communication" where the techniques for directing the attention of
the audience matters.

BE BOLD! may work for a wiki but not for communication.

Tim Daly
The uncommunicative curmudgeon.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]