Wandering Thoughts archives

2008-09-26

The aesthetics of syntactic sugar

The Unix test program makes for a great illustration of the aesthetic importance of syntactic sugar, to go along with its pragmatic effects. Consider the following two shell script lines:

if test -f /some/file; then ...
if [ -f /some/file ]; then ...

In any Bourne shell environment worth its name, these two have exactly the same results and in fact run exactly the same program (or an imitation of it), because [ is just another name for test. But at least to me, they read significantly differently, and I find that the second one looks better and reads more clearly.

(I think the problem with the first one is that everything looks the same, because it's all words and switches. In the second one, the [ and ] stand out visually and so act as useful punctuation.)

To go out on a limb, I think that this is one of the drawbacks of languages like Lisp. By having no syntax they also have no syntactic aesthetics, whether bad (all too common) or good; instead, everything disappears into an even flow of words and parentheses. There are virtues to this regularity, but I can't help but think that such languages are missing something too.

(Possibly the answer for syntax-less languages are IDEs that add in 'punctuation' in the form of colour, different fonts, and so on.)

programming/SyntaxAesthetics written at 00:28:22; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.