# [Edu-sig] Re: easy for beginners, even children

Michael McLay mmclay at comcast.net
Thu Apr 15 08:50:52 EDT 2004

```On Thursday 15 April 2004 2:26 am, Terry Hancock wrote:
> On Wednesday 14 April 2004 05:54 pm, Daniel Ajoy wrote:
> > > But why would they say "set 2 equal to 3" if they want
>
> to
>
> > > know "is 2 equal to 3"?
> >
> > Because 2 = 3 is what they would write on paper.
> >
> > But I agree that it does not take much brilliance to
> > understand that = and == are different things, and when
> > to use each one.
>
> Actually there's a very important lesson there. One thing
> that takes some appreciation is that programming (well,
> procedural programming) is *prescriptive*, not
> *descriptive*, which makes it different from, say algebra.
>
> I mean:
>
> x = x + 1
>
> is an extremely common thing to do in programming (so common
> we have a shortcut
>
> x += 1
>
> ).
>
> But that's obviously a false statement in algebra.
> Therefore it's really important to point out that we are
> doing two fundamentally different things when we are
> *assigning* a value and when we are *testing* a value.

If might be helpful to explain that algebra is also an arbitrary syntax. It
just happens to have several hundred years of refinement and general
acceptance by the mathematics community. (The design of computer languages
are constrained by historical and pragmatic keyboard and display device
limitations. These limitations were part of the motivation for the special
encoding of expressions in programming languages.) It can also be pointed out
that just as there are an infinite number of possible algebra languages
possible, there is also an infinite number of possible computer languages
possible. Python, like all computer languages, defines a concrete syntax that
is agreed upon as as the rules for expressing how a program should operate.

Python could have just as easily have spelled '==' with '.eq.'. That is the
spelling for an equality symbol in other languages. If you wanted to make it
more like COBOL the spelling of this operation might have been spelled
'.IS_EQUAL_TO.', but that would be very painful to keyboard compared to '=='.
The decision on the spelling of symbols is an aesthetic choice. This
arbitrary assignment of a symbol is no different than the arbitrary spelling
of the word 'esthetic'. Just as the word 'centre' is the same word as
'center'. The "correct" spelling is a customary choice of different
countries. The spelling choices for Python were selected by the BDFL. One
innovation of Python is there are fewer ways to express the same concept and
there is generally one way that is considered more correct than any other in
most circumstances. This make it much easier to read other peoples writting
in Python. It's his language. If a student complains about the BDFL's choices
for the Python syntax rules then I suggest a few hours of instruction on the
rules of Perl to enlighten them on the alternative:-)

> Even if the syntax let us confuse these two operations (as
> it could -- Python doesn't really need two different
> symbols for these operations since the assignment is
> illegal in tests), it's still a good thing to learn.

Reusing the same spelling for both assignment and equality would present
problems in expressions.
>>> a = 1
>>> b = 4
>>> a = b == 3
>>> a
False
>>> a = b = 3
>>> a
3
>>> b
3
>>>

> Algorithms are fundamentally different from equations, and
> this is a good place for the student to learn something. A
> potential "Aha!" moment, in fact.

As far as case sensitivity is concerned, there are times when the semantics of
a sentence can be derived from the case used in spelling a word. For
instance.

The president of GM told the President, "What's good for GM is good for
America". The President had no comment.

It is very clear from this sentence that the President of the United States
was the person who had no comment. Sometimes capitalization does matter in
English. The first word in a sentence is capitalized. Proper nouns are
capitalized. Python has defined a very restrictive rule on how names are
treated in the language. This is another example of a simplification that
make it easier to read software written by someone else. It eliminates the
creation of arbitrary styles for writing names in programs. When a student
asks why case matters, simply ask why it shouldn't matter. If they think it
would be easier to use Python if they can be inconsistent in their use of
case, then they have the answer. Python helps teach that consistency matters.

I think the point to learn from these examples is that learning to program can
be a good tool for teaching the importance of accuracy in the expression of
ideas. If you make the mistake in an English paragraph the human parsing the
sentence may make an arbitrary assumption of the meaning, or they may point
out the ambiguity. The computer program will not make arbitrary decisions.

I think it is great that programming is an opportunity to improve a student's