Of the need for permitive syntaxes

April 30, 2007

I am currently in Copenhagen, Danmark, just after attending the 5th edition of the Nordic Perl Workshop.

Perl conferences are always very stimulating: it may sound self evident to just say that you get to meet other programmers who share your interest, get geekish with them and enjoy it a lot, but it really is the main point with such conferences! In a world where dynamic languages are still relegated to university studies and small hacking projects, it's such a relief and a joy to meet others who actually understand the mind-blowing power of dynamic syntaxes and love to talk about it. You can actually chat with the guys who wrote the books you learned the language with. Even better, you can talk with the guys who actually created the language! Now, those people have insight! and they are usually more than happy to share it, to everyone else's delight.

But that's not what I thought of writing about.

While listening to a couple of talks about Perl6 yesterday, I came to rethink about an article I read recently: Style is substance by Ken Arnold. The main point in this article was that every software project would win in the long term if programming languages were by design restricted to allow one and only one valid syntax.

For example, instead of allowing all the following syntaxes as valid in a given language:


     if () {
     } else {
     }

     if()
          {
          }
     else
          {
          }

     if () {
     }
     else {
     }


you would just pick up on of them as valid, and hardcode it into the compiler so that only that syntax actually compiles.
Which syntax you would take just does not matter. Seriously.

Think of all the wasted time and programming resources that would suddenly be saved! No more arguing at length about which alternatives should be allowed in a specific project's code standard, or spending time developing proper syntax highlighting in text editors, efficient parsers for compilers, and so on and so forth.

At first, I thought it was a great idea.

Then I sat listening to Jonathan Worthington's talk about the design of classes, roles and constraints in Perl6, and I came to reconsider it all.

Just imagine that Perl's syntax had been closed by design from the beginning. Static. No way to mutate and evolve. What would have happened? Obviously, Perl would have died within years.

The fact is that programming paradigms do evolve. With years passing, new approaches emerge to solve known programming problems, new designs emerge. Think of the way object-orientation emerged, and design patterns, and dynamic programming with things like meta-programming or weak typing. Those new ways of seeing things required new ways of expressing yourself in the code, new syntaxes. How would those new syntaxes have been engineered if the syntax of languages had been all static from the very first release? How would new languages have appeared? Would they have to be engineered to perfection from the very beginning they get released, then break backward compatibility each time someone wants to introduce a new syntax into the language? I am sceptical.

The fact is, much of the durability of Perl comes from its amazing flexibility, the way it lets you redefine the very syntax of the language to try out new syntaxes, new approaches. It's almost an evolutionary process: new features are made possible via language modules and pragmas. Some never catch people's interest and vanish. And some make it into the language's core.

Later, when the core has evolved beyond maintainability, you just refactor the whole language. That would be Perl6 :)

Comments

RSS feed for comments on this post.

The URI to TrackBack this entry is: http://lemonnier.se/erwan/blog/bblog/trackback.php/12/

Leave a Comment

Sorry, Comments have been disabled for this post