Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Syntax flexibility is not a virtue. Creating restrictive rules about what I can do to an object or how functions work ties my hands when I try to do tricky things, but syntax only limits my artistic urges to do esoteric code layout.

The C style syntax situation with optional if brackets is almost universally considered a flaw:

  if (foo)
    st1();
    st2();
This is not the flexibility to do hard things. It does not save a lot of typing or make some other common construct less cluttered. It is just a defect in the grammar that it's too late to fix.

It sounds like Coffeescript has more of these flaws.



I don't consider the optional braces in C-if a flaw. I use them for early return often, eg

  if (somethingBad)
    return NULL;

  restOfBody();
And I find that the braces are often just unnecessary visual noise. Of course, there is always the issue of people adding extra statements, but I haven't found that to be a problem in practice. YMMV though


The trick to avoiding the problem of extra statements is to only skip the braces if it all fits on one line:

    if (somethingBad) return NULL;
That's a clear visual indicator that the braces have been skipped, but it's basically impossible to look at the next line and not know that it's NOT part of the conditional. Also, if you're having trouble fitting it all on one line, it's a good cue that you're not in a situation where skipping the braces is safe.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: