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

The fact that half the people in this subthread think that your version is less readable and half think it's more is really strange to me. If you have to traverse more lines and scroll down and switch between lines to track variables and conditions, that's unpleasant to parse. On the otherhand, excessively dense code where you have to figure out which of multiple function calls or syntax constructions to start at, then that's unreadable, too. But if you can do one thing and do that one thing in one line with predictable syntax, that's the ideal solution. I have a hard time empathizing with those who prefer verbosity over succinctness.


I think part of the problem is that it'sn't visually obvious that ? and especially : are lower precedence than < and >. I suspect that most of the people with genuine objections would feel better about:

  a<b ? -1 : a>b ? +1 : 0
  # or maybe
  a < b ?? -1 !! a > b ?? +1 !! 0  # perl6 style
  # or
  a < b then -1 else a > b then +1 else 0
not for verbosity vs succinctness but for the mnemonic that visually-smaller operators bind more tightly.




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: