[Edu-sig] An OOP view of the "number" concept

Christian Mascher christian.mascher at gmx.de
Sun Apr 22 21:49:10 CEST 2007


Hi,

> The way I look at it, Python ints and floats "out of the box" have a more
> limited repertoire than in Smalltalk apparently.

Limited for a reason, see below.

> Once we import math, then we get these external functions, which don't
> actually reach into the guts of the number type for an answer.  The
> native types are knowledgeable, but not omniscient (likewise with
> user-defined).
>
Right, so there is also a virtue in Pythons way of number-objects _not_ 
knowing about sin(): smalltalk's smart numbers only work, because 
everything (every method/function) is contained in one image; 
mathematical functions are methods defined somewhere in the Number class 
hierarchy of the smalltalk system. And you always have everything 
around, if you use it or not.

Contrast this with Python, where you start with a limited set of builtin 
functions and object types and import other stuff only when needed. You 
save your work with little files (modules) and use rather less 
ressources than a full smalltalk image. Much more lightweight approach. 
Certainly one of the most important reasons I prefer Python, even when I 
admire the uniformity of smalltalk objects: the granularity of module 
files and a small efficient runtime environment running fast enough 
everywhere.

Christian


More information about the Edu-sig mailing list