Why not allow empty code blocks?

Steven D'Aprano steve at pearwood.info
Sat Jul 30 23:14:00 EDT 2016


On Sun, 31 Jul 2016 04:16 am, Michael Torrie wrote:

> On 07/30/2016 11:53 AM, Steven D'Aprano wrote:
>> On Sun, 31 Jul 2016 02:29 am, Rustom Mody wrote:
>> 
>>> MIT on practical reasons for python over scheme:
>>>
>>
https://www.wisdomandwonder.com/link/2110/why-mit-switched-from-scheme-to-python
>>> Berkeley on fundamental reasons for the opposite choice:
>>> https://people.eecs.berkeley.edu/~bh/proglang.html
>> 
>> Not a very useful discussion. His argument basically boils down to:
>> 
>> "Lisp came up with some good ideas that were copied by other languages.
>> Therefore Lisp is a good teaching language."
> 
> Maybe.  Lisp and Scheme are great languages to teach the theory of
> programming with because they are so easy to use to build DSLs (all
> within the same syntax as Lisp), and it kind of acts like a
> meta-language.

Doesn't sound like a good teaching language to me.

Meta-reasoning is harder than regular reasoning. That's why metaclasses are
harder to use than ordinary classes. Beginners have trouble enough learning
even simple features of languages, and you want to drop them straight into
meta-languages as their first taste of programming?

I suspect that Lisp/Scheme would make a really good *third* language. Or
even fourth.


> I'll never use Scheme again in my life, but I'm very 
> glad to have learned it in my Theory of Programming Languages course at
> uni.  Python would have been alright to teach "programming," but to
> teach the actual theory of programming languages (lambda calculus, lists
> as a foundation unit for all other data structures), Scheme was an ideal
> choice for teaching these fundamentals.

People misuse language. You say that scheme was "ideal". That literally
means that there is *not one single thing* about Scheme that isn't PERFECT
for the task, that it reaches a faultless standard of perfection lacking
all weaknesses. That's much stronger than saying "Scheme is the best
language for...", and much stronger than saying "nothing will ever be
better". It's saying that nothing *could* be better, because perfection has
been reached.

(Yes yes, I know you don't actually mean that, not literally. I'm making a
rhetorical point.)

Let's look at some problems with Scheme:

- For starters, there's the whole parentheses thing. While its true that
people claim[1] that the experienced Schemer or Lisper stops seeing them,
beginners and students are possibly five or ten years away from being
experienced Schemers. In the meantime, all those nested parentheses hurt
legibility and code comprehension.

- And then there's the use of prefix order of terms (Polish notation). For
the beginner, having to learn in prefix notation instead of infix notation
(which comes much more easily to English speakers) is a major problem.

- Writing DSLs is not something that ought to be encouraged, or at least not
required. DSLs impose a maintenance burden: you know have to learn both the
DSL and the metalanguage it is written in. One needs to be wary of going
there without a good reason.


It has always perplexed me that Lisp's prefix notation is held up as
the /sine qua non/ of elegance and power, while Forth is ignored if not
ridiculed. Forth is just as expressive as Lisp, just as meta, just as
customizable. You can create your own syntax in Forth. Forth doesn't have
macros, because it doesn't need them: you have complete control of what is
compiled and what is interpreted and when.

Perhaps it is because Lisp started as an academic language in the computer
science department, invented by people who knew all the right terms from
formal and complex mathematics (the parts they don't teach undergraduates)
while Forth was merely a practical language invented to control telescopes,
by an astronomer. Perhaps it is because the most popular Forth book
("Starting Forth" by Leo Brodie) shamelessly and intentionally
anthropomorphised the Forth interpreter in order to make it more accessible
to non-academics, while Lisp/Scheme are elitist languages used by elite
academics who, for the most part, would probably stop using Lisp/Scheme if
they became popular outside of university again.

I maintain that Forth would be a better meta-language than Lisp. If you're
going to require students to learn to think using a grammar which isn't OVS
or SVO (i.e. infix) then it seems to me that postfix with a stack is easier
to learn than prefix with parentheses.


> The continued confusion that 
> pops up on the list from new users on how Python variables work wouldn't
> be an issue if they came from a Scheme background.  The idea of names
> and binding of names would make perfect sense to them.

Of course. But that's because they would have suffered the same confusion
when learning Scheme, and got past it by their second language, Python.






[1] I'm choosing this word carefully. People claim all sorts of things.


-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list