Comment

Comment by goblin89

Having taught programming to novices a little, I believe “if not” is clearer than “else”. Imagining “not” being prepended to the original conditional expression would be natural, especially in languages with “not X” construct (like Python), and it’s easy to forget that “else” is in fact archaic to non-programmer ears, slightly and possibly needlessly raising the barrier.

    if (X) { doY(); }
    if not /* X is implied */ { doZ(); }
In languages like Python it could be generalized to enable one to use “if not” with an expression as usual but omit the expression if it is the last branch of a conditional, thus getting rid of the “else” keyword while maintaining or arguably improving readability.

That said, there is no programming language that could entirely map to a spoken one, so perhaps it’s actually beneficial to shed any semblance of such mapping early-doors in the learning process.

parent goblin89 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton