Configurable syntax

bearophile bearophileHUGS at lycos.com
Fri May 22 07:45:30 PDT 2009


A configurable syntax has some advantages:
- It makes the language more flexible. I like the idea of this a lot.
- allows to do things that are otherwise hard to do.
- It can be used to write shorter programs.
- It can be used to define a sub-language fitter for a specific job. (Ruby shows some of this, and CLisp shows lot of this).

A configurable syntax has some disadvantages too (you need some experience to understand the following points):
- Every program can look different. So you may need lot of time to understand code written by other people. This is bad if you have 50+ programmers working on a project.
- The language gets more complex.
- Meta-programming is generally not easy to understand. So newbie programmers will need more time to learn the language, the entry barrier to the language is higher.
- It fragments the language community, creating more differences among programs. This probably leads to a language that has much less already written modules (example: In Python you can find a module for almost everything. This sharing of code comes from the syntax that is standard, people using the same single CPython interpreter, and so on. In Python even the coding style is codified, there is only one normal way in writing code. This allows people to share code in a simpler way. And having a rich community of re-usable modules is probably the most important quality a modern language can have).
- Creating macros is sometimes like extending the language. But the discussions on the D newsgroups and Python newsgroups have shown me that adding new good syntax/semantics to a language is a very hard job. So most people that write macros are going to add bad designs to the language. This is bad.

A silly solution is to have macros only in the standard library and in few autorized libraries :o] But this is impossible to enforce.

So in the end it may be better to keep finding special and localized situations where the D language may enjoy becoming a bit more flexible (generic infix operators? Merging the syntax of compile-time functiong with some templates? Etc etc) but it may be better to not add a generic configurable syntax (macros) to D...

Bye,
bearophile



More information about the Digitalmars-d mailing list