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

I would draw the line at additive, multiplicative operators generally, but I would also include &&, || and comparisons in C-derived languages (contra Tim). Knowing the extra three precedence levels is a cheap investment that covers such a wide range of commonly used languages - C, Java, C++, C#, bash's let/for/etc.

I don't think it's necessary to have to parenthesize:

    u*t + a*t*t / 2.0
Working with Pascal (Delphi) quite a bit as I do, I also find this idiom - required in Pascal with its limited number of levels - tedious:

    if (a > b) and (b < c) then // ...
The trouble is that you begin writing this:

    if a > b then
but updating it to add in the new conditional means you have to go back and forth over the expression inserting parentheses. I think C and related languages at the expression level make this better by making comparison operators have a higher precedence to boolean operators.

Bitwise operators, of course, have an entirely different precedence level and if you're using C, it's easy to get caught out:

    if (flags & MASK == FLAG1 | FLAG2) // cue much confusion


I fully agree, but replace "much confusion" with "compiler warning".


The only compiler I use that will warn for it is gcc, and even then you need to use -Wall.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: