Take a look at these two equations. I found the first one on Facebook. The second is my first attempt at rewriting it for the computer. What is the answer?
Well the first answer is 1. The second answer is 9. How is that possible? If you think about it there is a sort of implied parenthesis around 1/3. It’s pretty clear in the more traditional mathematical expression that one is to divide by one third and not 1 divided by three. A more accurate expression for the computer would have some parenthesis to make things obvious. That would give one the answer 1 that the traditional expression provides.
We see this sort of thing a lot – students assuming that equations in programming are exactly the same as the mathematical expressions their are used to using. The most common issue is students thinking that the = sign allows copies from left to right as well as right to left. After all in mathematics the = sign means that both sides of the equation have the same value. That is not the same think as the = sign meaning copy the value on the right into the location on the left.
Some functional languages do things differently. The WeScheme IDE and DrRacket used by Bootstrap for example. That curriculum takes a much more algebra focused look at computer science. Or is that a more computer science focus approach to algebra? Either way it seems to be very effective. (Note that Bootstrap training is available though CSPdWeek and other venues.)
Those of us using other platforms though have a lot to contend with as we teach students how to build expressions that mean what students think they mean. Is it worth the effort? I tend to think so. But it is confusing at times. Days like to today make me rethink things.