Abolish Syntax

Although I can’t find it now, I think it was Dan Bernstein who said somewhere that programs should avoid syntax when possible. Using syntax means permitting syntax errors. Avoiding syntax means making syntax errors impossible.

Even if it wasn’t Bernstein who said this, you can see the idea in action in things like his tinydns configuration file format. There are no keywords or grouping constructs. Each statement is a single line. The first character on the line indicates the type of statement.

The expectation is that if people want a more comprehensible syntax, they will write a separate program which will read something and generate the un-syntax. That way any problems are isolated to that separate program. (Actually tinydns-data is itself a separate program which reads the un-syntax and turns it into a binary form for the tinydns program.)

I think this idea deserves wider use. It fits with the general idea that modules should be independent. When you have a program which needs to read some data, that format of that data should be as simple as possible. When it is desirable to permit a more complicated representation, that should be done by providing a mechanism to convert the complicated representation to the simple one.

Programming languages are of course a sinkhole of syntax. That said, an example of a programming language with minimal syntax is sed. For those with only a passing familiarity with sed, it is surprisingly powerful, and the t and T commands make it Turing complete. It would not be a satisfactory language for general purpose programming, but it is quite effective in its own domain. Another language with minimal syntax is, of course, APL.


Posted

in

by

Tags:

Comments

3 responses to “Abolish Syntax”

  1. kevingessner Avatar

    “There are no keywords or grouping constructs. Each statement is a single line. The first character on the line indicates the type of statement.”

    But then isn’t each line the “grouping construct”, and the first character a “keyword”? It’s a simple syntax, but a syntax nonetheless.

  2. Ian Lance Taylor Avatar

    Sure, there is a syntax in the minimalist sense. Without that, it would just be random. The minimalism can be seen in that if two strings are different in any character, they have different meanings. And while it’s possible to write a string which doesn’t mean anything, it’s not possible to write a string which is syntactically invalid.

  3. yuri Avatar
    yuri

    I think, more relaxed syntax language has, more context dependent parsing should be done. Syntax is for simplification of statements recognition or for making statements recognition possible.

Leave a Reply