[Edu-sig] Python as a first language for computer sciencist

Mark Engelberg mark.engelberg at alumni.rice.edu
Wed Oct 19 07:31:41 CEST 2005


In my mind, one important feature of a first programming language is
that it must provide meaningful error messages for every common error
a student might make.  Bugs that are easy to make and hard to track
down are a surefire way to turn kids off of programming.

Python falls short in this respect.  Consider this program:

def plus2(realNumber):
 raelNumber = realNumber+2
 return realNumber

The problem, of course, is that when you intended to assign a value to
a variable, you actually created a new one.  It is very bad that a
minor typo can really mess with the semantics of your code.  Similar
situations crop up when you intend to modify a global variable in one
of your functions, but forget (or are unaware of) the global keyword,
and end up creating a new local variable.  Also, this problem happens
all the time within objects, in which you try to assign a property,
but because you misspell the property, it just creates a new property
for the object.

Typed languages, of course, don't have this problem, because you have
to declare the types of everything you use, before you use them.  But
this is not the only way to solve this problem.  For example, Scheme,
as I recall, won't allow you to modify a variable (using set!) that
has not already been bound to some initial value (using let).

I think this is Python's greatest weakness as an educational language.
 In a lot of other ways, however, it is very nice.

--Mark


More information about the Edu-sig mailing list