Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982)
by wruza on Saturday January 06, 2024 @11:25AM
(#38892707)
I got little scars from knowing precedences and then switching languages. I also got them from short-testing booleans that later turned into T|boolean. And all these clean just_p’s incrementally evolved into !just_p ? !un_q : t’s. Because I was flying through a mass-change after a day and had no mental capacity to repack the meaning of the previous expression and retain the context of a changeset.
Crystallized syntax is clear, but also extremely fragile, if you take humans into account. We have limits. Everything pushes us to these limits. Any complexity spike that overlaps with secondary complexity or fatigue is above our limits. That’s where we make mistakes.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982)
by mkbosmans on Sunday January 07, 2024 @04:32AM
(#38899830)
The big difference between adding the first `== true` to `if (x)` and adding more is that for a bare `x` you need more context to know whether the expression inside the `if` is of boolean type or something that will implicitly be casted to boolean. With `x == true` you know just looking at the `if` statement that it is a boolean expression. Adding more `== true` does not make it more explicit.
IMHO it's on a similar level as "== true" "== false" and variations thereof --- absolutely redundant and unnecessary, and shows a lack of knowledge. The same "explicit is better than implicit" mantra is often repeated to justify the latter, but if you think
is somehow more "explicit", then surely is even better?So at the end of the day, what's more clear depends on How familiar the engineers working on your code are with a given set of operators
If someone is not familiar then they should be encouraged to learn and level up, rather than pulling down everyone else.