[Pythonmac-SIG] talking points, Pythonismus

Christopher Barker Chris.Barker at noaa.gov
Tue Apr 18 23:14:57 CEST 2006


Charles Hartman wrote:
>> Actually, I am using Matlab, which is dynamically typed as well, in 
>> some of my courses and I know it works well until types become 
>> important.

Matlab is a far cry from Python, as a programing language. Indeed, until 
recent versions, it was not the least bit dynamically typed, every 
variable was a matrix of doubles. It had some tricks for interpreting 
them as integers, booleans, or strings in some cases, but that was all 
there was. More recent versions do support other "real" data types, but 
the it's really more "weakly typed" than dynamically typed.

Python's dynamic type system, is in fact, quite strongly typed. A given 
Python object is one type, and one type only and will not be interpreted 
differently depending on context. NAMES are not typed, but OBJECTS are.

There can still be a bit of confusion when the same name refers to 
different objects of different types at different places in the code, 
but it's not as bad as Matlab.

As for Matlab vs. Python:

Anyone using Matlab, but feeling like it's not a "real" enough language 
for more powerful use, or to teach more about programming, should really 
look into using numpy (and SciPy). It gives you a powerful flexible 
array data type, similar to Matlab's but more powerful. And it gives you 
all the power and flexibility of Python.

Numpy arrays are essentially statically typed: when they are created you 
define the size, shape and data type, so they can really teach a lot 
about data typing.

>> Sometimes they claim that the program 
>> (the interpreter) isn't working right.

and people also wonder why:

x = 0.0
while x != 10.0:
    x + 0.1

never terminates. In any language. It's an opportunity for teaching. In 
fact, if you make a data type mistake in C, you get a segfault, or 
totally bogus results. People don't blame the compiler, because they 
expect C to be hard. The fact that users blame the interpreter is 
because most of time things do work as expected!

I agree with another poster (and Joel Spolsky), that really learning 
about things like data types, pointers, recursion, etc, is critical to 
being a computer scientist, or a truly versatile programmer. However:

1) A lot of people can benefit from knowing how to do some programming 
that are not ever going to be computer scientists or professional 
programmers: Python gives them a very useful tool for a wide variety of 
programming needs, without the painful learning curve.

2) Even if someone is going to become a computer scientist or 
professional programmer, why do they need to learn all those painful 
details first? I think Python provides an excellent introduction to a 
lot of what programming is about, and it can be later supplemented with 
a course in Lisp, or C, C++ ,or even JAVA, later. Frankly, I wouldn't 
call anyone a "real" programmer that has only used one language. Any one 
language.

In some ways, JAVA is the worse choice: you don't learn about the nitty 
gritty details of pointers and memory management that you get from C, 
and you don't get the high-level power and flexibility or Python either!

-Chris

Does that help?


-- 
Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list