Advantages of function objects vs. classes/methods

R. Anders Schneiderman (
4 May 1994 19:22:54 GMT

Thanks to all the folks who responded to my earlier Q re: python vs.
other alternatives; your answers got me the go-ahead.

As I've been reading through sample python scripts, I've noticed that
often people use a series of function objects rather than creating one
or two classes that cluster the functions together. OO Purists would
have a heart attack if they saw this, arguing that function objects
are precisely what we want to avoid: they don't fit well with OOA/OOD
(since function objects take your attention away from the data) and
are less likely to promote long-term reusability (sure you can reuse
procedures--you can reuse BASIC or FORTRAN functions--but a procedure-
oriented approach doesn't bias you towads reusability, if only because
it doesn't allow for inheritance).

I'm no purist (IMHO, python is much more readable than Smalltalk or C++),
but personally I'm more comfortable using classes than function objects.
What I was wondering was:
1) Are there any overwhelming conceptual advantages to using function
objects over classes?
2) If I choose to use classes instead of function objects, will I pay
a heavy penalty in speed?

Anders Schneiderman
Center for Community Economic Research
U.C. Berkeley