Steven D'Aprano <st...@pearwood.info> writes:
>> Maybe.  Lisp and Scheme are great languages to teach the theory..
> 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.

Python metaclasses are monstrously more complicated than simple
metacircular evaluators in Scheme.

> 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?

The classic SICP course didn't deal with meta-evaluation until towards
the end.  It starts out with simple computation, then goes into higher
order functions, lazy evaluation, logic programming, and other topics;
finally it shows how to write a Scheme compiler in Scheme.

The book is really great, highly recommended, full text online:
   https://www.mitpress.mit.edu/sicp/

Wadler critique (note: Miranda is a forerunner of Haskell):

  https://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf

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

FORTH heh heh ;-)

> - For starters, there's the whole parentheses thing. 

That stops being a problem almost immediately, really.

> 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.

A postfix ("concatenative") language like Factor, with Forth-like syntax
but Scheme-like semantics, would be an interesting alternative to
Scheme.  But traditional Forth, while cool in its own way, is extremely
low level, especially using the classical pure stack-oriented style.
Lots of mucking with raw machine addresses, no type system either at
compile time or runtime, not even local variables in the Forth loved by
purists.  Consider multiplying two complex numbers a+bi and c+di in
Scheme (never mind that it has an actual complex datatype), giving a
2-element list (x y) representing x+yi which is (ac-bd) + i(ad+bc):

  (define (z* a b c d)
     (list (- (* a c) (* b d)) (+ (* a d) (* b c))))

Yeah there's parentehses etc. but it's obvious how to write it.

Now let's try that in Forth.  It takes some head scratching--this is the
best I can do:

    : ad+bc ( a b c d -- x ) -rot * -rot * + ;
    : ac-bd ( a b c d -- y ) rot * >r * r> - ;
    : z* ( a b c d -- x y ) 2over 2over ad+bc >r ac-bd r> ;

Have a look at the table of contents of SICP even if you don't read the
whole book, and imagine covering those topics in a Forth-based course.

You've probably already seen this too:

   http://www.cse.chalmers.se/~rjmh/Papers/whyfp.html

The ideas in that paper translate naturally into Haskell and with a bit
of exertion into Scheme, but would be painful in Forth.

> Lisp started as an academic language in the computer science
> department,

Actually math department (there was no such thing as CS then) but ok.

> while Forth was merely a practical language invented to control
> telescopes,

Forth was actually inspired by Lisp, and was invented while Chuck Moore
was working at a carpet company (he got into telescope control later).
It's still interesting for hardware control but painful for anything
that doesn't fit easily into fixed-width cells and not much use of
memory allocation.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to