Peter Lyons

Optional Syntax Should Be Illegal

February 14, 2010

Why in the world do some programming languages include optional syntax? To a true type A engineer, this is incomprehensible and unacceptable. For example, in Adobe's ActionScript, statements may optionally be terminated with a semicolon. Usually this is not required, except in a few situations you need it. Evil. The statement that our number one job as software engineers is to manage complexitity really resonates with me, and willy nilly allowing of optional syntax just destroys consistency, predictability, and simplicity for no reason whatsoever. Optional syntax seems to me a bad language design smell that indicates the language authors need to rethink a bit and find something that works always and should be required.

Part of the impetus for this post is my annoyance when my thinking cycles are wasted on unimportant details in a source code file. I'd rather have a strict format so that whenever I am reading or writing in a language, there will be a strong and deep consistency. I don't have to spend time deciding whether I'm going to use some optional syntax or which of the several ways to express the same thing I'm going to use. Similarly, when I come upon someone else's code and it's a mixture of two optional approaches, I feel compelled to go and make it consistent, which is another time waster.