
Guy Steele Interviews John McCarthy, Father of Lisp (2009) - joubert
http://www.infoq.com/interviews/Steele-Interviews-John-McCarthy
======
ScottBurson
_People have added some Englishy stuff and at least the syntax of that is not
in the spirit of Lisp._

Ha! I knew it! He hated LOOP as much as I do! :-)

~~~
lispm
There are others who don't hate LOOP.

Me for example. The by far best looping construct is Jonathan Amsterdam's
ITERATE. But that is LOOP on steroids. LOOP is surprisingly practical. ITERATE
is even more practical and has more parentheses. ;-) But since LOOP is there,
it's good enough for a lot of purposes...

There are several objections against LOOP:

* another language. Don't use Common Lisp is embedded languages are a problem. ;-)

* the syntax. Okay.

* Spec is not good enough. For me it is good enough.

* Not enough parentheses -> ITERATE.

* non-extensible -> LOOP variants or ITERATE

I've used all kinds of stuff when it comes to loops and iterations.

Bad: tail recursion. Worse: RECUR in Clojure. Both lead to hard to maintain
and hard to read code. I've one believes in Functional Programming, it might
look attractive. But I don't buy that. Having read and refactored a lot of
these constructs, I find them hard to maintain.

LOOP: very useful in many cases.

Series: hard to extend

ITERATE: cool, everything I want.

Btw., LOOP comes from Interlisp from the 70s and was called FOR. The idea was
to have english-like embedded languages. It was then moved and extended to
Maclisp, and from there to Lisp Machine Lisp and then Common Lisp.

~~~
ScottBurson
The common-lisp.net page for ITERATE has this example for finding the longest
list in a list of lists:

    
    
      (iterate (for elt in list-of-lists)
               (finding elt maximizing (length elt)))
    

But what's wrong with this?

    
    
      (reduce (lambda (a b) (if (> (length b) (length a)) b a))
              list-of-lists)
    

Okay, you have to do a little more work if you only want to take the length of
each list once instead of twice. But if you don't care about that, this is
quite elegant and introduces no new vocabulary. (Unless the lists are very
long, calling LENGTH twice isn't anywhere near twice the cost of calling it
once, because of cache effects.)

~~~
lispm
The reduce code is just not very declarative. I have to inspect the code and i
need to have a mental model of REDUCE (which is not trivial). What is b and
what is a? I need a mental model of ITERATE too, but the declarative wording
gives hints what it is supposed to do.

Code like above is simply less readable. There are lots of uses of REDUCE
which are simple to understand. Code like above, less so - where I need to
write a special purpose function.

Another problem is that you need to think about the corner cases:

    
    
        (reduce (lambda (a b) (if (> (length b) (length a)) b a))
                '())
    

-> Error

Also you can see that the REDUCE version is slower. Usually there will be a
function call overhead - unless the compiler has some optimization for that in
some optimize level. Also 'LENGTH' is called multiple times on the longest
list so far. You could work around that in REDUCE ... In ITERATE this is not
needed: it calls LENGTH only once per list item.

~~~
ScottBurson
You always need to think about the corner cases. What is the longest element
in an empty list of lists? It might be better to get an error in such a case
than to have an empty list returned, since that's not an element of the input
list, in violation of one possible interpretation of the function's
specification.

> Code like above is simply less readable.

I write code like this all the time, and have for 35 years. I think it's
perfectly readable.

------
wwweston
"I started on [Lisp] during late summer when I was at IBM and I decided to
write a program for differentiating algebraic expressions. What I noticed is
that I could write conditional expressions, which I'd already used in those
legal move routines for the chess program and that they could be used to
embody the rules that were given in the calculus text, in an extremely direct
form. Differentiation of algebraic expressions was the leading example that
led to the functional form of Lisp programs."

I'm not very familiar with Lisp. Does anyone have a solid enough idea what
he's talking about here to be able to give possible concrete examples?

~~~
btilly
See [https://mitpress.mit.edu/sicp/full-text/book/book-
Z-H-16.htm...](https://mitpress.mit.edu/sicp/full-text/book/book-
Z-H-16.html#%_sec_2.3.2) for sample code demonstrating how to implement
symbolic differentiation in Lisp.

