[Edu-sig] Python for Algorithms and Data Structures...
Markus Gritsch
gritsch@iue.tuwien.ac.at
Fri, 23 Aug 2002 12:18:01 +0200
Laurent Pierron wrote:
> Hi there...
>
> It's not dfficult to teach Pascal-like record with empty classes.
> Data types is just a matter of convention.
> But how to introduce pointer with Python, pointer is very important in
> computer science because it's very used in C and C++, and C/C++ are very
> used in computer science ?
In my opinion:
Pointers are not necessary. They are only an artefact of C which you
have to know and to use to write useful code. C++ introduces references
and actually Python also uses references. Python combines this with
mutual and non-mutual data types which is IMHO quite elegant.
The separation of algorithm and data-types is done in C because C has no
method for including algorithms into data-types, i.e. Classes.
Therefore generating this artificially in Python by struct-like Classes
seems not optimal to me. To decouple algorithms and data-types when
really needed, C++ introduced templates. This is only necessary because
of the static typing of C++ variables. Python has dynamic typing, so
there is no need for templates there. Polymorphism is also a strong
technique, but just not supported by C.
My 2c,
Markus