Python for Algorithms and Data Structures...
Hi there... I'm trying to convince my colleague teachers to teach the science of computer programming with Python. It's not a problem to teach very basic computer programming with Python, but the major concurrent is VisualBasic which is more sexy with the graphic studio. For my colleagues now teaching basic computer programming is point-and-click to draw a nice interface and add some magic sentences to enforce the computer to do something, it's a non-sense and give a bad idea to the difficulty to think like a computer scientist. To teach "serious" computer programming (algorithm and data structure) there is some problems using Python, in France the course of algorithmic contains a large part about pointers (no pointers in Python), about Pascal-like record and data types, it's independant of the language but very Pascal-oriented. 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 ? -- Laurent PIERRON -*- mailto:Laurent.Pierron@loria.fr Ingénieur de développement Service SeDre : http://www.loria.fr/LORIA/EXT/services/SEDRE/ INRIA-Lorraine / LORIA -*- bureau : B 042 615, rue du Jardin Botanique -*- mobile/SMS : +33 6 72 23 03 80 B.P. 101 -*- voix : +33 3 83 59 30 93 54602 Villers les Nancy (France) -*- fax : +33 3 83 27 83 19
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
[Markus Gritsch]
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.
I've never heard of "mutual and non-mutual data types" and a Google search produced no results at all. Can you explain what you mean by these terms? Just curious. Thanks. -- Patrick K. O'Brien Orbtech ----------------------------------------------- "Your source for Python programming expertise." ----------------------------------------------- Web: http://www.orbtech.com/web/pobrien/ Blog: http://www.orbtech.com/blog/pobrien/ Wiki: http://www.orbtech.com/wiki/PatrickOBrien -----------------------------------------------
Patrick K. O'Brien wrote:
[Markus Gritsch]
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.
I've never heard of "mutual and non-mutual data types" and a Google search produced no results at all. Can you explain what you mean by these terms? Just curious. Thanks.
Excuse me. I meant "mutable" and "immutable" http://www.python.org/doc/current/ref/types.html Markus
Thsee are my top 5 arguments to use Python as a teaching base today: 1. openness Python has good politics [license], good Karma. It is free and sends a fundamental message about the open nature of programmability and social implications of technology selection. Part of the global trend by public sector administristrations to choose Linux and its ilk as the basis of government and education platforms: Finland, Korea, China... 2. interoperability The scope and relationship to other major languages and toolkits [C, Java, .NET etc] make it perhaps the most practical choice. Python is both superglue and superstructure. And it travels cross-platform with almost no overhead. 3. community The diversity and quality of Python's on-line community has to be one its greatest virtues/strengths. High signal to noise, talented, generous and encourging. Used from Nasa to Hollywood, from Google to Multimedia API's, from advanced university science departments to edu-sig high schools! Show them the library of contributed software [Vaults of Parnassus] 4. interactivity The instrinsic dynamics of CLI/script based system make it more conducive to students. 5. readability For students this is especially important as they may spend much more time reading code than writing it. This aids the transition from general algorithms [pseudocode] to implementation and sharing. At the same time I believe Python encourages clearer writing habits. Anyone care to debate this and why it might be so? I agree with Kirby that one must learn several languages. Python Seems to be a great starting point. Habits, lessons learned, and issues will carry well to other languages and complement theitr features. Even the discussion on pointers in Python shows the pros and cons clearly. Forth would be a good companion to studying pointers and hardware. There are some great CLI Forths out there. People think Forth is dead, but they ignore that Forth and its derivitives are widely embedded all around us in commercial products. From washing machines to desktop printers. A case in point [pun intended], Postcript is Forth :-) good luck ./Jason
Even the discussion on pointers in Python shows the pros and cons clearly. Forth would be a good companion to studying pointers and hardware. There are some great CLI Forths out there. People think Forth is dead, but they ignore that Forth and its derivitives are widely embedded all around us in commercial products. From washing machines to desktop printers. A case in point [pun intended], Postcript is Forth :-)
fyi, I just did quick google and found this edu-sig thread on implementing FORTH in Python http://mail.python.org/pipermail/edu-sig/2000-October/000744.html There are many FORTHs but a good one might be Phil Burke's PForth. Phil is also the main author of JSyn, the Java audio synthesis api I mentioned in a recent Jython thread. http://www.softsynth.com/jsyn/ http://www.softsynth.com/pforth/ """ PForth is a public domain, portable ANS Forth based on a kernel written in ANSI 'C'. This makes it easy to port pForth to multiple platforms. So far, pForth has run on Macs, PCs, SUNs, Amigas, Linux, BeOS, Nokia Communicator, SGI Indys, 3DO ARM systems, 3DO PowerPC systems, WebTV systems, Hitachi SH4, OpenTV prototypes, and some internal projects at Lucent. If you build pForth for an embedded system, please let me know and I will add your machine to the list of machines that pForth has run on. """ ./Jason
Hi again.. well the pForth links page http://www.softsynth.com/forthlinks.html led me to this: Minotaur for Perl, Python, andTcl Minotaur is an extension which can be used from Tcl, Python, or Perl to run scripts in any of the other languages. http://www.equi4.com/minotaur/minotaur.html It turns out the author is Jean-Claude Wippler, of MetaKit fame. He has written an intresting article on the need for low-level glue in scripting languages. This is clearly the thinking behind the Minotaur experiment. The nuts and bolts of scripting http://www.equi4.com/moam/bolts.html Scripting - the fourth generation http://www.equi4.com/moam/scripting.html MetaKit http://www.equi4.com/metakit/ MetaKit for Python http://www.equi4.com/metakit/python.html """ MetaKit is an embeddable database which runs on Unix, Windows, Macintosh, and other platforms. It lets you build applications which store their data efficiently, in a portable way, and which will not need a complex runtime installation. In terms of the data model, MetaKit takes the middle ground between RDBMS, OODBMS, and flat-file databases - yet it is quite different from each of them. """ ./Jason
participants (4)
-
Jason Cunliffe -
Laurent Pierron -
Markus Gritsch -
Patrick K. O'Brien