Teaching python (programming) to children

Laura Creighton lac at strakt.com
Wed Nov 7 09:37:39 EST 2001


David Andreas Alderud writes:
> 
> I hear you, but it's my experience when teaching at the university that
> students that start with non-declarative languages write sloppy code. All is
> relative of cource, but I just speak from my own experience, myself I
> started with MC68k assembly and went to BASIC and E, and picked up some
> really bad habits in BASIC that took months to overcome.

This is really interesting, because my experience is exactly the 
opposite.  I have no doubt that you learned some very bad habits when
you learned BASIC, but it is not clear to me how you got from that
fact to the conclusion that it was the fact that BASIC is not typed
that ruined you.  

I believe that assembler is bad for you in much the same way that strongly 
typed languages are bad for you.  Unless you really have to tickle the
hardware, in which case how many bits there are in something is part
of your problem domain, any representation of your problem that forces
you to keep track of such things is doing damage to you as a problem
solver.  If you have to talk to the hardware, by all means use a
strongly typed language.  Otherwise, stay away.

We had a good representative of this kind of bad thinking yesterday.
Somebody wanted help with his isnumeric function.  Lines and lines
and lines of code all trying to test to see if a particular string
was possibly a number when all he needed was:

>>> def isnumeric(s):
...     try:
...             f=float(s)
...             return 1
...     except ValueError:
...             return 0
... 

which I mailed him.  Poor soul. Somebody ruined him by teaching him
that computers operate on types.  Now he has to fix himself.  I'd recommend 
a steady diet of Smalltalk until he no longer remembered what types were, 
nay, until the idea of types positively annoyed him, but that might be
hard to arrange.

The other day Tim Peters wrote:

	In a world where 3/4 == 0, how long could any programmer
	survive believing that integer division and multiplcation are 
	"inverses"? The antecedent is dead on arrival.

This is very true.  But it demonstrates that the man has been hanging out
with the bits and the types for too long.  It has done interesting things
to his skull.  Precise, competant, and excellent professional things,
for somebody that has to care about exactly where the bits go, but it
blinds him to the plea 'Awwww. but I wanted multiplication and division
to be _inverses_!'  And that is a poignant cry from somebody whose
problem domain _doesn't_ include bits, bytes, and how you order them
in a computer.

This leads me to believe that it is likely that we have different
standards for sloppy code.  Do you mean 'written with little or no
concern as to where the bits are?'.  That's a different sort of
sloppiness than the sort that usually bothers me, unless of course I
am writing a device driver or a compiler or something that _cares_.

From my point of view, _any_ version of isnumeric that doesn't use
try and except is sloppy, no matter how much precision went into
determining all the possibly string inputs and what to do with each
case. (Unless you are Tim Peters, and rewriting format, for instance.)
It is the sloppiness of bringing the wrong part of your mind to your
job.  Shooting flies with anti-aircraft guns.  And strongly typed
languages encourage you to think on too low a level of abstraction
for most programming problems.

I am curious: my experience with C++ has made me conclude that the
only people who are any good at programming C++ were also good at
programming assembler when they learned C++.  (Or until they learned
assembler, they remained foul C++ programmers.  I _do_ know one person
who was a rotten C++ programmer until he took an assembler course, at
which point he got a lot better.)  Does your experience differ so
much?   Are there many good Ada programmers who know little or no
assembler? If so, I would think that this is evidence that there is
something other than the strong typing that makes Ada a good first
programming language.  C++ certainly isn't a good first language, and
neither is BASIC, but the flaws in both those languages seem to be far
deeper than how strongly typed they are.

> I see big demand for Ada programmers here in Sweden, not as big as Java and
> C++, but indeed much more so than Python :)

Are they all in Lund?  I know people who would like to get an Ada job, 
which they aren't finding here in Göteborg.

all this is very interesting to me,
thanks for writing,
Laura Creighton





More information about the Python-list mailing list