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

Just FYI. Brujo is close to being expert in Erlang. This post is a more of a "warning for juniors" than "damn, today I've discovered something new".

And there is nothing really WAT about it. Just part of rather simple Erlang language grammar.




I would argue that the precedence priority is kinda a wat-moment. Most other languages[0][1] have the logical operators `and`, `or` and `not` in the lowest (or near) priority, which makes much more sense IMHO.

If you'd dismiss the above, then I guess one could also argue that JavaScript returning an empty string on `[] + []` is also not a wat moment, but just part of the JavaScript grammar.

[0] http://kevincantu.org/code/operators.html

[1] http://www.tutorialspoint.com/python/operators_precedence_ex...


It is definitely an oddity that it's and/andalso instead of &&/and.

Similar to the fact that shell and perl swap == versus eq; that causes me no end of confusion switching between the two.

Though nothing will ever be as upsetting as the period when I used QBASIC at school and BBC BASIC at home. Number of times my attempts to use COLOUR compiled first time? Not even once.


C/C++ also have & and | in the wrong place, mostly thanks to their heritage as being overloaded for && and ||).

I've personally seen several (flags & MASK != VALUE) bugs make it to the field. Sometimes it's worked for ages as the 0th bit was part of what was being tested.

Whilst adding more brackets can be useful to explain things, there comes a point when you have too much parenthesis. You have to rely at least a little on operator precedence, so you really do need to learn it.


HAHA! Thanks @pepesza :)




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

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

Search: