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

The syntax is broken. Things like operator precedence and associativity are the exact opposite of math conventions:

    f x + f y    // is f(x + f(y))
    f g x        // is f(g(x))


Not quite -- the rule is pretty simple: Implicit function calls associate to the right, to the end of the line (or the end of the trailing block). This allows you to write code like this:

    console.log inspect value

    model.save(attrs).then ->
      ui.update attrs

    rect.scale height * factor

... and have all of the results come out correctly, while leaving the code readable. If the rules were "more math-like" as you say, then none of that would work. Perhaps it would harmonize with special libraries that used functions (automatic-partial-application a-la Haskell) in a different way than JavaScript does ... but that's not the world we live in. It's gotta harmonize with JS functions as they exist.


I'm not sure where the idea originated that readability scales inversely with the number of parentheses, but I wish it would hurry up and die.


I'm not sure where the idea originated that readability scales with the number of parentheses, but I wish it would hurry up and die.


I'm not sure where the idea originated that readability scales, but &c., &c.


My brain isn't plastic enough to make this switch. :( For me, those code examples are uncomfortable to look at. backwards read to trying like It's


Right-o. The trick is to "read" it like pseudocode, or like English-ish.

    Log the inspected value.

    Save the model, then
      Update the UI with the attributes.

    Scale the rectangle by (the height times the factor).
The big syntactic difference still being the "model.save" vs "save the model" ordering of dot-notation. But them's the breaks.


I don't understand what's wrong with the second example. What do you think it should do?


In ML-family languages like OCaml and Haskell, function application is left-associative: f g x = (f g)(x).




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

Search: