# Python's simplicity philosophy

Douglas Alan nessus at mit.edu
Wed Nov 12 09:37:34 CET 2003

```pmaupin at speakeasy.net (Patrick Maupin) writes:

> Douglas Alan wrote:

>> Your claim is silly.  sum() is not *way* simpler than reduce(), and
>> anyone can be explained reduce() in 10 seconds: "reduce() is just like
>> sum(), only with reduce() you can specify whatever addition function
>> you would like."

> Maybe reduce() can be explained in 10 seconds to someone who has used
> sum() a few times, but that has no bearing whatsoever on trying to
> explain reduce() to someone if sum() is not available and hasn't
> been used by them.

Describing reduce() in 10 seconds is utterly trivial to anyone with an
IQ above 100, whether or not they have ever used sum():

"To add a sequence of numbers together:

To multiply a sequence of numbers together:

reduce(mul, seq)

To subtract all of the numbers of a sequence (except the first
number) from the first number of the sequence:

reduce(sub, seq)

To divide the first number in a sequence by all the remaining
numbers in the sequence:

reduce(div, seq)

Any two-argument function can be used in place of add, mul, sub, or
div and you'll get the appropriate result.  Other interesting
examples are left as an exercise for the reader."

If someone can't understand this quickly, then they shouldn't be
programming!

> I'm sorry, but from a pure CS viewpoint, reduce() is way off the
> radar screen.  Especially for a 101 course.

I'm sorry, but you are incorrect.  When I took CS-101, we learned
assembly language, then were assigned to write a text editor in
assembly language, then we learned LISP and were assigned to write
some programs in LISP, and then we learned C, and then we were
assigned to implement LISP in C.

If you can write a !\$#@!!%# LISP interpreter in C, you no doubt can
figure out something as mind-achingly simple as reduce()!

>> You should be assuming that your audience are the smart people
>> that they are, rather than the idiots you are assuming them to be.

> Ignorance is not stupidity.

Assuming that your audience cannot learn the simplest of concepts is
assuming that they are stupid, not that they are ignorant.

>> I sure hope that Python doesn't try to emulate C.  It's a terrible,
>> horrible programming language that held back the world of software
>> development by at least a decade.

> I used to hate C.  But then, when it borrowed enough good concepts
> from Pascal and other languages, and the compilers got smart enough
> to warn you (if you cared to see the warnings) about things like
> "if (x = y)"  I stopped using Modula-2.  C held software back 10
> years in the same manner as Microsoft did, e.g. by helping to
> standardize things to where I can buy a \$199 system from WalMart
> which would cost over \$20,000 if everybody kept writing code like
> the pointy-headed ivory tower academics thought it ought to be written.

You score no points for C by saying that it is like Microsoft.  That's
a strong damnation in my book.  And you really don't know how the
world would have turned out if a different programming language had
been adopted rather than C for all those years.  Perhaps computers
would be more expensive today, perhaps not.  On the other hand, we
might not have quite so many buffer overflow security exploits.
Perhaps we'd have hardware support for realtime GC, which might be
very nice.  On the other hand, perhaps people would have stuck with
assembly language for developing OS's.  That wouldn't have been so
pretty, but I'm not sure that that would have made computers more
expensive.  Perhaps a variant of Pascal or PL/1 would have taken the
niche that C obtained.  Either of those would have been better, though
no great shakes either.

that code should look something like Python.  The reason these
languages are not widely used is because typically they either did not
come with batteries, or there was no lightweight implmentation
provided, or they only ran on special hardware, or all of the above.

>> The reason for Python's wide acceptance isn't because it is
>> particularly well-designed compared to other programming languages
>> that had similar goals of simplicity and minimality (it also isn't
>> poorly designed compared to any of them -- it is on par with the
>> better ones) -- the reason for its success is that it was in the right
>> place at the right time, it had a lightweight implementation, was
>> well-suited to scripting, and it came with batteries included.

> I'd vote this as the statement in this group most likely to start
> a religious flamewar since the lisp threads died down.

The only way it could start a religious flamewar is if there are
people who wish to present themselves as fanboys.  I have said nothing
extreme -- just what is obvious: There are many nice computer
programming languages -- Python is but one of them.  If someone
wishes to disagree with this, then they would have to argue that there
are no other nice programming languages.  Now that would be a flame!

> I'm not particularly religious, but I _will_ bite on this one:

> 1) In what way was it at the "right place at the right time?"

Perl was in the right place at the right time because system
mishmash of shell, awk, sed, and grep, etc.  And then web-scripting
kicked Perl into even more wide acceptance.  Python was in the right
place in the right time because many such script-writers (like yours
truly) just could not stomach Perl, since it is an ugly monstrocity,
and Python offered such people relief from Perl.  If Perl had been a
sane OO language, Python would never have had a chance.

> You didn't name names of other languages, but I'll bet that if you
> can name 5 which are similar by your criteria, at least two of them
> were available when Python first came out.

I'm not sure what you are getting at.  There were many nice
programming languages before Python, but not many of them, other than
Perl, were portable and well-suited to scripting.

Oh, yeah, I forgot to mention portability in my list of reasons why
Python caught on.  That's an essential one.  Sure you could elegantly
script a Lisp Machine with Lisp, and some Xerox computers with
Smalltalk, but they didn't provide versions of these languages
well-suited for scripting other platforms.

> 2) What part of "lightweight implementation, well suited to
> scripting" contradicts, or is even merely orthorgonal to
> "particularly well-designed"?

Again, I'm not sure what you are getting at.  "Lightweight
implementation" and "well-suited to scripting" do not contradict
"well-designed", as Python proves.  Lightweightedness and capability
at scripting are certainly orthogonal to the property of being
well-designed, however, since there are a plethora of well-designed
languages that are not suited to scripting.  They just weren't

> 3) Do you _really_ think that all the batteries were included when
> Python first came out?

It certainly was not a particularly popular language until it came
with pretty hefty batteries.  There are many other languages that
would have been equally popular before Python started coming with
batteries.

> Do you even think that Python has more batteries _right_ _now_ than
> Perl (via CPAN), or that some competing language couldn't or hasn't
> already been designed which can coopt other languages' batteries?

Um, the last time I checked Perl was still a lot more popular than
Python, so once again I'm not sure what you are getting at.  Regarding
whether or not some future language might also come with batteries and
therefore steal away Python's niche merely due to having more
batteries: Anything is possible, but this will be an uphill battle for
another language because once a language takes a niche, it is very
difficult for the language to be displaced.  On the other hand, a new
language can take over a sub-niche by providing more batteries in a
particular area.  PHP would be an example of this.

> I can accept the premise that, for Python to enjoy the acceptance it
> does today, Guido had to be lucky in addition to being an excellent
> language designer.  But if I were to accept the premise that
> Python's popularity is due to sheer luck alone my only logical
> course of action would to be to buy Guido a plane ticket to Vegas
> and front him \$10,000 worth of chips, because he has been extremely
> lucky for many years now.

I never claimed *anything* like the assertion that Python's popularity
is due to luck alone!

|>oug

```