Hacker News new | past | comments | ask | show | jobs | submit login

Of course, on the other hand, you can just as easily misread this example if you don't notice the incorrect formatting.

  for (let a of x) {
    f(a);
  if (something) {
    g();
  }
  }
If you're a programmer who looks primarily at indentation for their syntax cues, it's the parens that can lead you into traps.

So there's arguments either way.

Now that I'm used to it, I do feel that indentation errors (or at least an indentation/paren mismatch) should probably be a syntax error either way.

Possibly people who argue for belts and suspenders might be on to something?




I've had a team of programmers come to me and ask why some C code wasn't working after spending some time looking at it. It was a very badly formatted piece of code and yes, they were looking at the indenting rather than the braces. This was decades ago, before the rise of modern IDE's which might make such errors obvious.

To me, that was a definitive proof that while people may prefer braces over white space the majority of those same people read code, they are using indentation to guide their mental parse tree - not the braces. One obvious reason for doing that is they may not even be able to see the braces in the editor window.

It also seems obvious that the compliers should parse the same way humans do. It makes life so much simpler when we both see the same thing, so the code the compiler is emitting matches the semantic tree we are building in our heads. Which means if your goal is correct, readable code python got it right, and just about every other language gets it wrong. The article notwithstanding, there is not a lot of wriggle on that point.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: