2 ms·
The former can be understood by anyone with a basic grasp of English grammar, while the latter requires understanding the Boolean operator. So yes, the former i
by krapp 8y ago
The former can be understood by anyone with a basic grasp of English grammar, while the latter requires understanding the Boolean operator. So yes, the former is more readable.
- tigershark 8y agoIf someone doesn’t have a basic grasp of Boolean logic then maybe programming is not the right choice..
- HolyHaddock 8y agoEarnestly: Yes. But there may well be programming tasks or jobs that they are suited to, for which no understanding of boolean logic will make no difference on a day to day basis.
- deleted 8y ago[deleted]
- krapp 8y agoDoesn't matter. Unless one option leads the compiler to generate better code than the other, it's a matter of aesthetics, not correctness. And since you don't even need to be a programmer to understand what the first one means, it's still easier to read.
- moomin 8y agoAn observation that comes from studying foreign languages: you learn “and”, “or” and “not” a long time before “if”.
- ummonk 8y agoBorrowing the variable examples from another comment, do you believe that the former is easier to understand for someone who knows English grammar than the latter? (I'm using Python syntax since we're going for English-like readability and added parantheses to the boolean operation to indicate order of operations for the liberal arts major that we've decided is the target audience of this code): if isAdmin: return false if not isActive: return false return true vs return (not isAdmin) and isActive