__init__ is the initialiser

Rustom Mody rustompmody at gmail.com
Sat Feb 1 05:02:10 CET 2014


Not any direct comments on this... Just some thoughts around a couple
of questions

1. Declarative and Imperative Terminology
2. Is OOP declarative or imperative

1. Python is an imperative language. It does a good amount of
functional stuff.  Are its terms neutral?  Look at sort

sort -- imperative
sorted -- functional

By contrast in scheme one would have something like
sort -- functional
sort! -- imperative

Or haskell

sort -- functional
unsafePerformSort -- imperative

If the simple term corresponds to the standard and therefore default,
this shows a fundamental difference in world-views

2. Is OOP functional, imperative or neutral?
In theory it is neutral:
If we only ever make and use value-objects (ie immutable objects) then
it is used declaratively

If we have mutable objects then OOP is being used imperatively

So much for the theory. In practice (in the words of Neal Ford):
OOP tries to encapsulate moving parts, FP tries to minimize the moving parts

IOW it seems (to me) OOP is almost always used as a clover-leaf on
wanton state-change ie. imperativeness.

This comes from the fact that while objects in programming languages
may pretend neutrality, philosphically objects and values are
fundamentally opposed:
Objects belong to 'this world' -- born change live die
Values belong to the platonic world -- 3 was 3 even without an exsting universe

In
hhttp://research.microsoft.com/en-us/um/people/gurevich/opera/123.pdf
(first few pages) Yuri Gurevich gives an entertaining account of how kids
learning math are platonically indoctrinated.

What most dyed-in-the-wool imperative programmers dont get is that
when we take a task that humans perform in 'this world' and abstract
it effectively into a program that a machine can (at least partly)
perform, this is only possible if we build a model of the action.
And models are intrinsically abstract entities ie platonic.

IOW to modify the standard dictum of philosophy:
"No philosophy is bad philosophy"
we have
"Imperative programmers are bad functional programmers"

What has this to do with how constructors are named?

Both 'constructor' and 'initializer' have (to my ears) an imperative sound
though initializer is perhaps more so -- evokes a picture of a life-story -- 
a saga! Constructor less so

This may be factored in to the choice of terminology



More information about the Python-list mailing list