When I started programming in Pascal 500 years ago and switched to other languages I always missed the ‘not’ keyword.
Now I see in Zig to my surprise the and / or keywords.
I would really love to see my not back in Zig. However: in Pascal / Delphi the not/and/or are used for both bitwise operations and booleans, which can be confusing.
The ! is so narrow that it can be easily missed, when scanning code.
A not would be fantastic.
Imo and/or have a good reason not be operator: they have an impact on the control flow. If the left side of an or expression is true, the right side won’t to be evaluated, same when the left side of an and expression is false.
Sidenote:
When I was reading this topic, just for a moment I struggled to remember what operator Zig is actually using for the “boolean not”. The reason being that I instinctively try to avoid it in order to simplify logic. Since “boolean not” is a logical operation that can be removed without introducing any other logical operations, removing it saves every reader from tracking that redundant negation, meaning it improves readability.
I never use what I call “The Back and Forth Bouncing Booleans” which attacks my brain.
And yes this is a good example! (including the crazy ! for not, who on earth invented that…).
if (!(a >= b and c >= d))
For my (C#) work I sometimes use:
if (MyLookupFunction(args) == false) // this
if (!MyLookupFunction(args)) // instead of this
EDIT: chat gpt answer to who is guilty
The choice of ! for “not” is rooted in early programming languages and mathematics, where brevity was essential due to limited screen space and memory. This notation likely traces back to BCPL (the precursor to C) and ALGOL. Ken Thompson and Dennis Ritchie, while developing C, adopted ! as a logical NOT operator, making it standard for languages that followed.
The irony is real, though—! is indeed narrow and easy to miss, especially given its significance in logical expressions. Unfortunately, by now, it’s deeply embedded in programming conventions.