Guido on Functional
fold.sigusr2.net
fold.sigusr2.net
For the record, here's a link to the Haskell Prelude version of reduce, aka, foldr. Looks like "a few lines" to me...
http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0...
It amazes me how some programming language authors seem to be clueless about really major areas of our field.
If I ever were to design a language, it would only be after studying all of the various interesting programming languages. How else can you be certain that you aren't doing something that hasn't been done before?
O industrial PL designers, how easily we let you off the hook.
I think the guy who had the misfortune to create newLisp caught more flack than Guido, Matz and Larry combined.
Find anyone who hates it :-)
This is another standardized Lisp that even Common Lispers and Schemers respect. The ISLispers were the Trotskyists persecuted by the DoD backed CL Stalinist politburo. They had a beautiful Lisp that reconciled all the Lisp differences without sacrificing good taste. However, it was a high-level design that left too many details to the whims of implementers, and would have been impossible to stay compatible to without active and deliberate cooperation.
There you have it. And I must go now to board a chopper to to an Alaskan rehab/work program for my reactionary accusations against the U.S. Department of Defense, and the venerable X3J13 ;-)
Also, EuLisp is a more divergent dialect, and even more ambitious than common lisp; it had ML style modules, continuations via let/cc, generic LAMBDA (yes, first class anonymous methods!) full support for TCO and other goodies. EuLisp was an ideological successor to LeLisp (which was ancient and fugly) and I consider both the academic dabblings of one Christian Quinnec, Lisp designer extraordinaire.
If that always happened, there would be almost no new langs ever.
Again: definition of a gentleman computer scientist: Some one who knows enough to write a new programming language, but doesn't.
Guido isn't the only one. Andrew (the submitter/author of this post) once told me a story of how Brian Kernighan told him Scheme had too many parentheses and is too strange and functional to be useful (take that with a grain of salt - it's a paraphrase of a paraphrase). I've also yet to see any non-Smalltalker/Erlanger language author understand the importance of OOP in the sense of creating encapsulated objects which can be hot-swapped at will. As far as I can tell, this was the point of OOP as Alan Kay saw it. Java-style "reload the VM to reload objects" being called OOP is just painful.
I saw Larry Wall speak within the last year or so about Perl 6. His presentation on the stuff inherited from Perl 5 was solid, but when he started talking about the other things that were more functional and/or "like Haskell", there was a marked change in his confidence and depth of description. I saw him go to dinner with some people organizing the talk and when asked about what other languages he had studied besides Perl, I recall his answer was something along the lines of "well, lots of Perl is written in C." I came away with the impression that he didn't study other languages in order to improve Perl, and the more functional stuff in Perl 6 was coming from somewhere else.
That's an unfortunate impression. I've worked with Larry for several years, and he's most assuredly a polyglot, as are many of the other Perl 6 developers.
foldr f z [] = z
foldr f z (x:xs) = f x (foldr f z xs)
Clojure does it like this (note the overloading - this is both "foldl" and "foldl1" in Haskell terms): http://github.com/richhickey/clojure/blob/49a7d6b8e14050a45d...r' f (x:xs) | xs == [] = (f x):[] | otherwise = (f x):(r' f xs)
or:
[(f a) | a <- myList]
- another edit -
r' f (x:xs) | xs == [] = x | otherwise = f x (r' f xs)
(and the fact that everybody who hasn't implemented a tautologous reduce has basically used the same tail-recursive algorithm lends a bit more support to this theory)
The more I think about it, it's just another expression of the old "when all you have is a hammer" aphorism. Guido's being yelled at and called names not because he's wrong or because he's stupid or doesn't understand what he's talking about, he's being yelled at and called names because the "hammer" in this case -- functional programming -- is a bit of a sacred cow, and a lot of people get really defensive about it.
Of course all functional programmers write the same tail-recursive implementation of "reduce." That's like observing that everyone uses a loop to implement "reduce" in an imperative language. It's the simple, straightforward way to do it. (And since folds are trivially implemented in any functional language with tail recursion, why would the language designer include them as a primitive?)
It's also very common in Haskell to implement your own fold for various reasons. For example, in a simple 50-line text processing script[1], I defined a fold for a list-of-trees data structure without calling any builtin fold function[2].
[1]: http://github.com/mbrubeck/outline-grep
[2]: http://github.com/mbrubeck/outline-grep/blob/master/OutlineG...
P.S. I like your blog, and huge thanks for Django!
Take a look for yourself.