
The Rise Of Functional Programming: F#/Scala/Haskell and the failing of Lisp - lackbeard
http://blogs.msdn.com/brandonwerner/archive/2008/09/16/the-rise-of-functional-programming-f-scala-haskell-and-the-failing-of-lisp.aspx
======
greyman
Can someone please explain in basic terms, what exactly are the advantages of
functional programming, over other mainstream approaches like OOP? AFAIK, some
FP support was added to the newest version of C#, but I couldn't immediately
tell how exactly can I make use of it.

~~~
Hexstream
Just look at some simple uses of closures and you'll see they open a world of
possibilities. (and there's so much more to it than this!) They also let you
make compilers easily but I won't get into that here.

    
    
      CL-USER> (sort (list 1 8 3 2 5) #'<) ; sort just needs a function of 2 arguments that tells if the first parameter is strictly less than the second
     => (1 2 3 5 8)
     CL-USER> (sort (list 1 8 3 2 5) #'>)
     => (8 5 3 2 1)
     CL-USER> (sort (list "hello" "HELLO" "hey" "bye") #'string<)
     => ("HELLO" "bye" "hello" "hey")
     CL-USER> (mapcar #'1+ '(1 7 3 9))
     ;mapcar applies a function to each element of the lists passed as arguments and returns a new list with the results
     => (2 8 4 10)
     CL-USER> (cons 1 2)
     => (1 . 2)
     CL-USER> (mapcar #'cons '(A B C) '(1 2 3))
     => ((A . 1) (B . 2) (C . 3))
     CL-USER> (defun make-adder (how-much-to-add)
     	   (lambda (initial-value)
     	     (+ initial-value how-much-to-add)))
     => MAKE-ADDER
     CL-USER> (mapcar (make-adder 10) '(1 7 3 9))
     => (11 17 13 19)
     CL-USER> (defvar *my-favorite-adder* (make-adder 42))
     => *MY-FAVORITE-ADDER*
     CL-USER> (mapcar *my-favorite-adder* '(1 7 3 9))
     => (43 49 45 51)
     CL-USER> (defun make-modifier (operator operand) ; a bit more general than make-adder
     	   (lambda (initial-value)
     	     (funcall operator initial-value operand)))
     => MAKE-MODIFIER
     CL-USER> (mapcar (make-modifier #'expt 3) '(1 7 3 9))
     => (1 343 27 729)
     CL-USER> (find-if #'numberp '(a "hi" nil 8 "test" 100))
     => 8
     CL-USER> (find-if #'numberp '(a "hi" nil 8 "test" 100) :from-end t)
     => 100
     CL-USER> (apply #'+ (remove-if-not #'numberp '(a "hi" nil 8 "test" 100)))
     => 108
    

That's _not even_ (by a long shot) the tip of the iceberg.

~~~
yters
It's simple to compile because lisp is essentially a parse tree, which
eliminates the parsing stage in compilation.

~~~
Hexstream
I was referring to the ability to traverse a tree structure (made of conses or
objects) and generate a tree of closures from that.

Instead of interpreting the tree structure, you make a first pass where you do
a lot of dispatching in advance (at runtime you'll just do what you must do
instead of first figuring out what to do and then do it), generating a tree of
closures. Then you call your "top-level" closure for a nice optimized run. You
can optimize your source tree before compiling this way, for some crazy speed.

All this without having to read advanced books about low-level compilers,
parsing, machine architecture and optimization!

~~~
yters
V. interesting, thanks:)

------
jimbokun
I'm intrigued by the idea of Lisps built on top of other run-times.

Clojure is the example here that all the cool kids are talking about. But I
just notice Nu in the list of functional languages the article mentions, which
is a Lisp built on top of Objective C. The creator of Nu points out he wanted
a Lisp to extend C, and that Objective C provided a dynamic run time to build
on while still allowing the incorporation of straight C code. I suspect there
is a good .Net Lisp out there somewhere, I just don't know what it is.

Building a Lisp on top of these languages gives you macros, code as data,
culture of functional programming, etc. while still making all of the
underlying libraries available.

~~~
michaelneale
That is probably the future of lisp - I mean we can see it already. Clojure is
one example (in use in some startups) and arc is another (being built on
MzScheme - although thats probably more for practical reasons).

------
lallysingh
A response by Dan Weinreb: [http://danweinreb.org/blog/the-failure-of-lisp-a-
reply-to-br...](http://danweinreb.org/blog/the-failure-of-lisp-a-reply-to-
brandon-werner)

------
felideon
_It was the most thorny and un-inspiring community I've ever participated in,
despite my extreme interest in the language. It's jaw dropping that a language
with such promise has sat out the resurgence, and speaks to what an un-
friendly and un-inviting community can do a technology platform._

As a Lisp newb who frequents #lisp every now and then, I’ve noticed quite the
opposite. People in the channel are very open to newcomers and as friendly as
hackers can get.

Uninspiring? Why? Lack of smug as Cal Hendersen says?

