Wednesday, August 08, 2007

Brace yourself

While doing my usual rounds of Python hacking, a colleague commented how weird Python code looked as it didn't have any braces (for the uninitiated, the Python interpreter identifies control flow using indentation levels). Naturally, I smirked about it and explained how Python is different & how it helped make the code more clean. However, to be honest, I myself didn't have much clue as to why had the Python designers made such a choice. So after some late night Googling, I found this:

"One of Python's controversial features, using indentation level rather than begin/end or braces, was driven by this philosophy: since there are no braces, there are no style wars over where to put the braces. Interestingly, Lisp has exactly the same philosophy on this point: everyone uses emacs to indent their code, so they don't argue over the indentation."

- Peter Norvig, "Python for Lisp Programmers".

Moral: Good languages & good editors go together.