Sunday, October 29, 2006

Whiteboard Doodles

the birth of linux
A student wanted to know if Python might be used to write an operating system and, if so, what we'd use to compile it -- a kind of chicken & egg question (aside from Python not being a system language at this point).

Above you'll see my outline of a response, the real world story of how our operating system Linux (one of several) was compiled using Stallman's GNU project's capable and free gcc.

The rest of the doodling has to do with Vpython's cylinder syntax, which aims a vector from a pos in the direction of an axis. I'd thrown out the challenge to draw a tetrahedron, starting with a "make hundreds of randomly generated balls" script for clues.

accessing toyz
Chronologically earlier in this talk, but easily inserted later, was this overview of Python talking to graphical widgets libraries to get its windows, mouse-pressable buttons and whatnot, called "widgets" in the trade.

IDLE, our out-of-the-box offering, relies on Tk for widgets, via the Python module Tkinter.

Other shells such as PyCrust pull from wxWidgets, a C++ library accessed from Python through the module wxPython.

But keep in mind that other languages bind to these same libraries, explaining what Ruby and Perl are doing in the picture.

The blue snake icon is about "__rib__ syntax," my shorthand for Python's special name methods (e.g. __add__, __call__), which look like ribs, and snakes have lots of ribs -- a good mnemonic that helps with writing one's first classes (we did Dog and Mammal), and needing to define __init__(self).

Below that, I'm polling the class with my "simplest polyhedron?" question, getting back "three sided pyramid" and "sphere" (both good answers, though I define the latter away). Mathematicians call it a Simplex, in honor of its simplicity.

However, connecting any four randomly generated balls with six edges isn't as easy as feeding startpoint, endpoint pairs to visual.cylinder. Next week, we'll take a more formalized detour into vector arithmetic within Vpython, plus introduce some wrapper classes.