Friday, November 13, 2009

Syntax Matters

Yesterday I wrote about why I wasn't very interested in Go. Two of my three major complaints were about the syntax of Go, and based on the comments I got here and on Hacker News a lot of people didn't seem to mind the syntax, or at least didn't think it was worth talking about. However, the opposite is true, for me the syntax is among the single most important things about a programming language.

I'd estimate that I spend about 60% of my day thinking about and reading code and 40% actually writing code. This means that code needs to be easy to read, that means no stray punctuation or anything else that distracts me from what I want to see in my code: what does it do when I run it. This means any code I'm looking at better be properly indented. It also means that I find braces and semicolons to be noise, stuff that just distracts me from what I'm reading the code to do. Therefore, code ought to use the existing, nonintrusive, structure, instead of obligating me to add more noise.

"Programs must be written for people to read, and only incidentally for machines to execute." This is a quote from Structure and Interpretation of Computer Programs, by Harold Abelson and Gerald Sussman. It has always struck me as odd that the people who wrote that chose to use Scheme for their text book. In my view Lisp and Scheme are the height of writing for a machine to execute. I think David Heinemeier Hansson got it right when he said, "code should be beautiful", I spent 5+ hours a day reading it, I damned well better want to look at it.


  1. Interesting, I find Lisp to be the most beautiful language from a syntax perspective.

  2. I totally agree with you on this. Python's significant whitespace was makes reading code much less cumbersome at worst, and a pleasure at best.

    I think the reason Google opted for C-style curlies here was because of the bigger picture. Systems programmers are (presumably) much more comfortable with curly braces and if Google is going to win them over they need as few barriers as possible.

    My guess is that they saw it as a tradeoff between niceness and adoption, and they went with adoption here.


Note: Only a member of this blog may post a comment.