jeudi 4 décembre 2008

Syntax Schmintax

Syntax Schmintax. It's only syntax. Everybody can learn syntax, *everybody*.

When faced with a programming problem there are always multiple choices. We are supposed to sort them out according to multiple criteria. Here are a few
  • Robustness
  • Maintainability
  • Beauty/Ugliness
  • Originality, as in dry
  • Performance
Syntax Schmintax means that the beauty of a solution should be considered only when you know robustness, maintainability, originality and performance are maximal.

One example from C++ : static_cast, const_cast, reinterpret_cast and friends vs C-style casts. C++ style casts provide more information to the reader and to the compiler, are easier to find and have no cost in performance or otherwise. But they are ugly. They are syntax that's possible to avoid, that's possible not to learn. Learn it! Use it! Syntax Schmintax says : learning new syntax is easy.

It's easy to learn a new syntax that does pretty much the same thing as some other syntax you know. There is no semantics to learn. What you think about and how you think about it does not change. It's not like learning Scheme or Haskell (you should, by the way). Learning Scheme means you should understand what a continuation is, what a lisp macro is. Haskel is quite simply alien.

Syntax is vocabulary. Syntax is good for you. Learn what's out there. Invent beautiful syntax if you can, but ugly syntax is better than nothing.

Aucun commentaire: