Bionic Snaketalk (proposed metaphorics)

So I'm thinking of using this analogy today: MOLECULES Data structures, starting from primitive number types, are like the molecules and macromolecules of life, the beginnings of organic chemistry. MICRO-ORGANISMS Functions, recently augmented with generators, are like the unicellular organisms on up to quite a few cells, but still quite simple. SKELETAL CREATURES Classes, though potentially very simple, provide the framework favored by the truly well endowed creatures, like Mammals (yes I'm applying a bias). Example application: In a language like Java, we're always extending the class framework, extending a tree rooted in the foundation object (Python has one too), and spreading overhead into the hugeness of the Java class library (complete with Applet and Swing branches). Someone coming from Java, looking at Python, might exclaim: wow, how prehistoric! The mitochondria still have an independent existence, their own street addresses." What this means of course, is that in Python we still have top level life forms of the pre-class variety, just as we suspect mitochondria used to have independent lives outside the confines of cells. http://micro.magnet.fsu.edu/cells/mitochondria/images/mitochondriafigure1.jp... [ image of a single mitochondrion, matrix exposed ] Kirby

On 7/19/07, kirby urner <kirby.urner@gmail.com> wrote:
So I'm thinking of using this analogy today:
MOLECULES
Data structures, starting from primitive number types, are like the molecules and macromolecules of life, the beginnings of organic chemistry.
Probably that should be: data structures + control structures ... considering exceptions a kind of control structure. These, then, are the primitive amino acid type proteins necessary for defining low level eat-and-return biota of the next level (i.e. functions, generators and, higher still, methods within classes). What's cool about IDLE is you're free to interact with the low level components without going to all the work of writing a structured program. The immediacy of the shell is what throws students for a loop sometimes -- they're not used to prodding and poking at this low a level, still think you "have to write programs" in order to explore string.Templates for example, whereas yesterday in class we just went like:
from string import Template
boilerplate = Template("There once was a $person from $city...")
boilerplate # trigger internal __repr__ <string.Template object at 0x00D50FD0>
formfiller = {"person":"guy", "city":"a strange faraway country"}
boilerplate.substitute(formfiller) 'There once was a guy from a strange faraway country...'
The idea here is to see "boilerplate" as setting up a View, with our "formfiller" a transport layer to/from a MySQL data base on a server somewhere. We can storytell around these common LAMP-like design patterns, while messing about in the shell, thereby (a) cluing students about how things work (b) giving them practice interacting with objects all without (c) needing to write too much code, at least at first (recall is hard, recog is easier). Kirby

That proteins (control/data structures), biota (functions & generators), skeletals (classes/types) discussion went OK, but I ended up deepening the meme pool with: aquaria or zoos (modules). I didn't even mention packages (ala __init__.py), yet another unit of depth. Plus site-packages itself may have many of those (VPython a case in point). Plus you might have multiple snake engines (a 2.x, a 3.x). Anyway, I think adding modules as an outer container sounds good, as these other components all go towards filling a module: not just classes, not just functions. Data structures may well be top level (*especially* data structures), such as a list of all cities of more than a million people, with latitude and longitude tuples. Tweaking povtoyz.py is harder than tweaking viztoyz.py, at least with the colors, in part because I embed default texture info in my polyhedra.py. Others might choose to refactor here. I sampled Animusic 2 rather heavily again, talking about how rendered action might be driven by a MIDI stream: http://www.atomfilms.com/film/animusic_starship.jsp Kirby
participants (1)
-
kirby urner