Peter Deutsch, the creator of the smalltalk implementation that inspired the javaJava-Jitjit (and much else), famously said:
Here are two identities
$$a(b+c) = ab + ac \tag{distrib. law}$$
$$x^{m+n} = x^m x^n \tag{index law}$$
$$
\begin{aligned}
a(b+c) &= ab + ac & \text{distributive law} \\
x^{m+n} &= x^m x^n & \text{index law}
\end{aligned}
$$
I guess everyone will agree that in the context of school math these are
unproblematic? Almost trivial?
Lets special-case the above with $c=1$ in the first and $n=1$ in the second and we get
$$a(b+1) = ab + a $$
$$x^{m+1} = xx^m$$$$
\begin{aligned}
a(b+1) &= ab + a \\
x^{m+1} &= xx^m
\end{aligned}
$$
(Assuming that the answer to all the above is no,no,no) x
Lets ask now:
Whats this to do with programming?
These can be trivially1 translated to haskell
as
So after i=i+1i = i+1
does i == i+1
?!
Lets ask our math-respecting executor Haskell:
Ok oneOne can writeeasily enough write
And no trouble...it seems
But when we ask what is x
we get, almost literally, an explosion!
2mutation Mutation is actually much worse than assignment; in fact mutation messes up imperative programming as much as imperative programming messes up mathematics. A brief trailer
4 Imperative programming of course must be taught; Ifif it is done in a later course, there is no unnecessary confusion.