2000 Stajano Native
2000 Stajano Native
Frank Stajano
AT&T Laboratories Cambridge
24a Trumpington Street, Cambridge CB2 1QA, UK
http://www.uk.research.att.com/˜fms/
and
University of Cambridge Computer Laboratory
New Museums Site, Pembroke Street, Cambridge CB2 3QG, UK
http://www.cl.cam.ac.uk/˜fms27/
2
3 The target audience a safer or less resource-hungry way of doing what they
want.
We have spoken so far of introductory courses meant The second advantage is to give back to ordi-
for future programmers, i.e. people that would naturally nary people the power to solve simple problems. In
continue to intermediate and advanced courses, where the days of the Apple II and of its even less powerful
they would learn new skills and new languages as ap- home-oriented followers from Commodore, Sinclair and
propriate. But the more novel and provocative aspect of Acorn, the distinction between using a computer and
this proposal to use Python in education sees this only as programming one was blurred. The BASIC interpreter
the marginal case. Future programmers are people who in ROM was more than just a programming language: it
choose to use computers. The really relevant case—the was also an operating system (insofar as there was one)
one towards which the community of computer profes- and a glue language to plumb things together. Despite
sionals and academics has the greatest responsibility—is the then-popular claim that “a computer can do any-
that of the vast majority of people who will be forced (by thing”, those machines did very little; but at least their
us) to use computers and will probably never attend an users were in control and there was no barrier to writ-
intermediate or advanced programming course: histori- ing short programs to do simple things. Over the subse-
ans, surgeons, lawyers, musicians and so on. At present, quent 20 years, home computers have become unbeliev-
they may not receive any programming training at all. ably more powerful (as well as better suited to actually
The idea put forward here is that they all deserve to get performing useful tasks, such as organising one’s col-
such training, in moderate quantity, at around secondary lection of comics), but BASIC in ROM has gone. In
school age, and that Python would be a good language to fact, from the mid-Eighties, most home computers have
teach them. The Van Rossum proposal [13] is even more been shipping without a programming environment at
radical, advocating that programming should be taught all. And even BASIC, for all its many perversions, was
at elementary school level as a basic skill, on a par with not as bad as what unofficially replaced it as the native
natural language and arithmetic. programming tool of the average machine, namely the
Establishing the most appropriate age at which to MS-DOS batch “language”. . .
introduce programming in the curriculum is left open for It is easy, with hindsight, to recognise that this need
debate; here we shall only remark that the implementa- for elementary programmability is perfectly solved by
tion details may depend on other factors than just the in- scripting languages. Only a tiny fraction of computer
trinsic merits of the new subject. As Wilkes says about users will be professional programmers, but all users de-
historical studies [14]: serve to be taught how to write useful five-line scripts to
automate simple repetitive tasks3 .
It is always easy to make a strong case for
including new topics in a syllabus. The prob-
lem is to decide what to leave out to make 4 Is Python a good first language?
room for the new material and, for this reason,
discussions of syllabus reform always resolve As a separate issue from the desirability of introduc-
themselves into discussions of what to cut out, ing schoolchildren to programming, let’s come back to
not what to put in. Python in particular, and to its suitability as a first lan-
guage.
But, apart from the age question, the crucial mes- One might think, especially in the light of what we
sage is that all children, and not just the technically just said, that two types of students ought to be distin-
minded, would benefit from learning the principles of guished, namely the future professional programmer and
programming, as opposed to just being taught how to the future non-technical user, since the requisites for the
drive prebuilt applications as users. respective ideal first languages might be quite different.
Spreading the knowledge about programming has In the first case, one might wish to emphasise good
at least two advantages: the first is to somewhat demys- programming habits that favour program correctness and
tify computers and give those future users the intellec- maintainability, while in the second case one might lean
tual tools to understand, at least qualitatively, what goes more towards giving the students some directly usable
on under the hood. Instead of I-don’t-want-to-know- practical skills, especially if this is expected to be their
about-it-ly2 blaming all malfunctions on voodoo or Mur- first and last programming tutorial.
phy, they will have some insight into possible causes for
3 This brings to mind the magic power of Expect [5], which allows
the problem and might be able to devise, if not a fix,
your script to drive character-based applications as if it were an inter-
2 <0.5 wink> to Tim Peters who, with characteristic wit, active user; but unfortunately the tool’s usefulness is reduced by the
introduced such insidiously contagious linguistic acrobatics in modern prevalence of graphical interfaces. Besides, Expect is far too
comp.lang.python years ago. complicated for a non-techie.
3
For some, the requirements for the first case will Besides, one should not entirely dismiss the pos-
mark Python as unsuitable. Faculty member Peter sibility that the choice of ML, while technically and
Robinson [10], in presenting the criteria for the choice pedagogically sound, might have an element of Cam-
of language to be taught initially to the computer sci- bridge elitism in it, as hinted at in the following ex-
ence undergraduates at the University of Cambridge, tract from Haemer’s witty and enjoyable chronicle of the
lists “mathematical basis”, “strong typing” and “func- 1994 VHLL symposium [2].
tional emphasis” as the three main objectives, accom-
panied by “a friendly environment for experimenting”, While [speaker Andrew Koenig] isn’t put
which translates as “an interpreted language”. This be- off by some of ML’s unusual properties, Andy
cause the students “need to start with a sound founda- admits that it is the twenty-first programming
tion for programming that can establish the principles language he’s learned. I didn’t have the im-
which will subsequently be applied in many different pression that he was the norm. Neither, I think,
languages”. did he.
The value of being able to see a program as a for- Early on, he warned us that “ML makes far
mal description of an abstract algorithm, and to analyse fewer concessions to practicality than you’re
algorithms mathematically, is emphasised. From these used to, but the payback is occasional breath-
requirements Robinson justifies Cambridge’s choice of taking elegance.” True enough, but it wasn’t
ML which, as an interesting side effect, puts all students long before John Ousterhout asked whether it
on an equal footing: even those with previous program- would be unfair to characterise ML as a lan-
ming experience have never heard of the language be- guage for people with excess IQ points. Some-
fore and are typically accustomed to imperative rather one in the audience volunteered that ML is
than functional programming. a standard undergraduate programming lan-
Python cannot score as well as ML against these guage at Cambridge, without saying whether
criteria, especially for what concerns the mathematical that meant “yes” or “no.”
purity: although it includes functional constructs and
supports functions as first class objects, Python lacks Python’s principal advantage as an introductory
ML’s sophisticated type inference mechanisms and is language is its high abstraction level, which is appropri-
certainly not a “pure” functional language—or a pure ate to introduce the fundamental concepts of algorithms
anything else for that matter. In fact, the following com- without getting distracted by irrelevant details such as
ment on C++ by Stroustrup [11] applies equally well to machine level micro-optimisations and memory alloca-
Python, whose computational model fruitfully borrows tion issues. Naturally, the future computer scientists will
from various inspiring sources. have to be introduced to such details at some stage—but
this can happen later, in the context of explaining them
Too often, “hybrid” is used in a prejudicial
how Python’s own building blocks were made.
manner. If I must apply a descriptive label, I
Anyone with an interest in the didactics of pro-
use the phrase “multi-paradigm language” to
gramming should not miss the excellent article by
describe C++.
Stroustrup [12] on learning Standard C++. Since C++
The reason why an educator, notwithstanding is so large, it must necessarily be conquered in stages;
Robinson’s valid points, might still choose Python over and, Stroustrup argues, an all too frequent mistake is to
ML for a first course to computer science undergrad- take the C subset as the first such stage.
uates is probably one of simplicity. While functional
concepts can still be presented and explored in Python In my considered opinion, that’s not a
where appropriate, the core of the course can proceed good [choice]. The C-first approach leads to
using a notation that, while less rigorous and more de- an early focus on low-level details. It also ob-
tached from the mathematical foundations of comput- scures programming style and design issues
ing, is nevertheless going to be much closer to the usual by forc[ing] the student to face many techni-
pseudocode used in language-neutral textbooks. The cal difficulties to express anything interesting.
outstanding introductory volume by Goldschlager and
Lister [1], which Robinson himself elsewhere lists as What he instead suggests is an approach that,
required cover-to-cover reading for the computer sci- among other things, “presents code relying on relatively
ence undergraduates even before they turn up at Cam- high-level libraries before going into the lower-level de-
bridge [9], presents its algorithms in a format and pro- tails (necessary to build those libraries)”, “presents com-
gramming style that is going to look rather more familiar mon and useful techniques and features before details”,
to a native Python speaker than to a native ML speaker. and “focus[es] on concepts and techniques (rather than
4
language features)”. To use Python to introduce pro- Sometimes even historical accidents are useful.
gramming is consistent, in spirit, with the above guide- Python’s explicit self argument to the methods of a
lines. Of course, since Stroustrup discusses studying class instance, which seasoned OO programmers may
C++, he implicitly targets students who have already view as an inelegant artifact of the minimalistic imple-
committed to taking programming seriously; but the mentation, helps less experienced programmers under-
same guidelines define a sensible strategy even for our stand who is calling what on what else, and how object
“type 2” students, i.e. those for whom the fundamen- oriented programming actually works. When I was once
tals of programming are a useful piece of 21st century asked to explain subtle distinctions between class and
culture but not the foundations of a career. instance methods, it was helpful to be able to point out
Someone might even argue that the ultimate goals that the class method wouldn’t have worked in that ex-
for a first course to “type 1” and “type 2” students are ample because, lacking self, it couldn’t find the object
not that different after all. In both cases we want to cul- to which the operation applied. The same explanation
turally imprint the students with a good methodology would have been more nebulous in “more advanced” OO
and an archetypal idea of how a complex construction languages.
such as a piece of software should be built in order to be
manageable—indeed this may be what that makes the
course more generally useful, even to the “type 2” stu- 5 It can’t all be good!
dents who will never write a program longer than ten
lines. Moreover, again in both cases, we want to retain It is reasonable to expect that, under at least some as-
the students’ interest by letting them practice with real pects, Python will be unsuitable as a first language,
problems (such as file manipulation and Internet pro- since it was not originally designed for this specific pur-
gramming) rather than just abstract data structures; and pose. Van Rossum [13] openly admits this possibil-
Python’s standard library is just what we need here. ity and declares himself ready to modify the language
where appropriate. He quotes case sensitivity of iden-
At a structural level, the absence of a direct lan-
tifiers and truncation of integer division as features that
guage ancestor saves Python from perversions dictated
actual teaching experience proved to be confusing. But
only by the need for compatibility. The language is fairly
there may in fact be more substantial sources of prob-
clean, in the sense of being based on the regular combi-
lems.
nation of a few powerful orthogonal constructs.
First and foremost, the whole conceptual model of
At a syntactic level the minimalistic punctuation,
reference counted objects may at times produce side ef-
while conceptually irrelevant, is actually a significant
fects that, for people who haven’t been introduced to the
advantage during the learning phase. Meyer, in the sec-
delights of pointers and explicit memory management,
ond edition of his masterpiece [6], confesses his dis-
are justifiable only through black magic. The canonical
appointment at discovering that students learning Eif-
example is in the Python FAQ [8], entry 4.50: the follow-
fel considered the absence of statement-delimiting semi-
ing apparently innocuous attempt at a two-dimensional
colons as the best feature of the language:
matrix will generate a mischievous structure in which
poking an element in one row makes it appear in all the
Some of the Discardists were very force- others too:
ful, in particular a university professor who
said that the main reason his students loved the A = [[None] *2 ] *3
notation is that they do not need semicolons
— a comment which any future language de- A less fundamental point, but nonetheless one that
signer, with or without grandiose plans, should never fails to puzzle newcomers, is the distinction be-
find instructive or at least sobering. tween lists and tuples (“So why can’t you get away with
just lists?”), and the related business of mutable vs. im-
It is in fact only fair to remark that, if the block mutable.
structure of language-neutral pseudocode can be ex- Finally, for a language to be used to teach program-
pressed clearly and unambiguously by nothing more ming concepts, not being able to specify types in, say,
than a legible page layout, there are few good excuses to the signature of a function is probably a drawback.
justify an abundance of brackets, semicolons and begin- These aspects of Python’s behaviour are so deeply
end markers in the real code just to simplify the com- rooted in its current structure that it is hard to imagine
piler. Making indentation count as block structure also them being removed in a future revision of the language
has the beneficial side effect of forcing everyone to in- even if actual practice were to show that they effectively
dent their source code correctly, under penalty of it not cause serious problems to the young students. It will be
working. extremely interesting to see how the problem is tackled if
5
it effectively arises. Breaking compatibility is allowed: primarily to offer some extra food for discussion, from a
the challenge is to devise a new construct that still fits slightly different point of view and in a small and easily
in naturally and elegantly—in other words, one that still digested format.
has the Python nature. Actually, within the gastronomic metaphor, the
most appropriate image is perhaps that of an appetiser:
this little piece doesn’t give the reader any meaty sub-
6 Conclusions stantiated facts—nor any cheesy language comparison
tables, for that matter—but if a potential educator (or
Python has done very well as a general purpose script- publisher, or author. . . ) finds it sufficiently enticing to
ing language. As with some of its direct competitors, its want to find out more and maybe bite a bigger chunk
high level data structures and high level primitive oper- of the action, this appetiser will have served its humble
ations allow most typical data manipulation tasks to be purpose.
expressed in tens rather than hundreds of lines of code.
Unlike other scripting languages, however, its clean de-
sign and its good support for modularity and objects 7 Acknowledgements
have allowed developers to fruitfully keep on scripting
It was a pleasure to discuss some of these ideas over
way past the canonical now-move-to-a-system-language
lunch with Frank Willison at IPC7 in 1998, as we clearly
limit of a thousand lines or so. Indeed it is thanks to
both believed in Python’s great potential as a teaching
this circumstance that, in a self-sustaining virtuous cir-
language.
cle, many of the excellent contributions in the language’s
I am also grateful to the anonymous referees (par-
rich standard library have come to life.
ticularly the one thanks to whom I bought the delightful
But, despite this success in the rapid application The Practice of Programming [4]) for their pertinent and
development arena, Python is still under-utilised. The encouraging comments.
same cocktail of well chosen language trade-offs that
gave Python the edge in the hands of experienced de-
velopers also makes Python a great resource for the im- References
portant task of teaching programming. Newcomers—
for whom the first language is a system to organise their [1] Les Goldschlager, Andrew Lister and Timothy R.
new thoughts about algorithms as much as it is a tool for Lister. Computer Science: A Modern Introduction.
building programs that work—find in Python a clean no- Prentice Hall, Englewood Cliffs, Mar 1988. ISBN
tation that invites expression at the appropriate level for 0-13-165945-6.
their experience; they may familiarise with general pro-
gramming concepts in an environment built out of the [2] Jeff Haemer. “Very High Level Languages Sym-
regular composition of a few powerful constructs, rather posium Report”. ;login:, 20(1):5–10, Feb 1995.
than out of the irregular accumulation of cute hacks, ISSN 1044-6397. (The symposium, organised by
compatibility kludges and special cases. As an added Usenix, was held in Santa Fe, New Mexico, from
bonus, they get a language that enables them to per- 1994-10-26 to 1994-10-28.).
form useful practical work on their own data (Python’s [3] Douglas R. Hofstadter. Gödel, Escher, Bach: An
versatility with text manipulation and Internet protocols Eternal Golden Braid. Basic Books, New York,
comes immediately to mind) rather than being confined 1979. ISBN 0-465-02685-0.
to toy worlds populated by lists, trees and integers. Fi-
nally, they get a language that will take them a while [4] Brian W. Kernighan and Rob Pike. The Practice
to outgrow—as demonstrated by the multitude of pro- of Programming. Addison-Wesley, 1999. ISBN
fessional developers who, even as non-native speakers, 0-201-61586-X.
have now adopted Python for a substantial portion of
their work. [5] Don Libes. Exploring Expect. O’Reilly and Asso-
Some of the best names of Pythonland have already ciates, 1995. ISBN 1-56592-090-2.
committed to a substantial concerted effort that will vali- [6] Bertrand Meyer. Object-oriented Software Con-
date the above claims and make Python, with the invalu- struction, 2nd ed. Prentice Hall, 1997. ISBN 0-
able feedback loop of actual school experience, an even 13-629155-4.
better first language. Now that the Computer Program-
ming for Everybody project rationale [13] is out, there is [7] John K. Ousterhout. “Scripting: Higher Level
in fact much less need than before for a paper such as Programming for the 21st Century”. IEEE Com-
this one. At this stage, the contribution of this piece is puter, 31(3):23–30, Mar 1998. ISSN 0018-9162.
6
http://www.scriptics.com/people/
john.ousterhout/scripting.html.