Why Python is like BASIC (and why this is a good thing)
Robin Munn
rmunn at pobox.com
Fri Feb 15 13:59:13 EST 2002
Reading the first few chapters of _How to Think Like a Computer
Scientist_ (http://www.ibiblio.org/obp/thinkCSpy/ for those who haven't
heard of this book), I was struck by how Python resembles BASIC in some
ways that make it a very good language for teaching:
* Interpreted, so there's immediate feedback. Students can just type
'python' at the command prompt and start coding, receiving *immediate*
feedback on the effects of what they type.
* Non-scary assignment and output statements. In fact, Python and
BASIC's output statments look identical. "Print" is a natural choice
for ease of understanding. Using sys.stdout.write can come later, once
students begin to realize that they don't always *want* a newline or
space appended to their output.
* No need to declare variables. Use them and they are immediately
created for you, ex nihilo.
All three of these things make for a very low barrier-to-entry for
people who've never done any programming before. I'm sure there are
other similarities as well, that maybe someone else will point out. Of
course, Python goes beyond BASIC in many ways:
* NO LINE NUMBERS! Enough said.
* Rich control-flow statements. Of course, this is available in more
modern versions of BASIC, but back when I was first learning to
program (at age six, using BASIC), all I had was conditional GOTO. You
know, IF condition GOTO line-number. Or, for the advanced students,
IF condition GOSUB line-number (I never did understand the necessity
for that kind of statement until well after I'd stopped using BASIC
entirely and moved to more "modern" languages like... Pascal).
* Batteries included. This is the big one, which makes Python more than
just a toy language suitable for learning. The richness of the
standard library makes Python incredibly useful, and I for one would
like to see it continue to grow. I understand the concern that people
developing Python-based programs for distribution would like their
users to be able to run a 100k script without downloading a 10M
distribution, but I don't want to see that cause a reduction in the
standard library. Instead, we could make make two Python
distributions, a "full" install containing everything and a "lite"
install containing only the interpreter and maybe -- *maybe* -- a
couple of essential modules like os and sys. Then people developing
Python programs like, say, a pygame-based game, could distribute a
single package containing the "Python lite" distribution, their own
code, and any other modules their code depended on -- all in one
easy-for-the-end-used-to-install package.
Anyhow, I hope this helps develop some ideas.
--
Robin Munn
rmunn at pobox.com
More information about the Python-list
mailing list