Book Club: Why noone uses functional languages (Philip Wadler)
Date: 2009-07-08 00:29:56

Our latest technical book club discussion was based around Philip Wadler's paper 'http://www.cse.iitb.ac.in/~as/fpcourse/sigplan-why.ps.gz[Why noone uses functional langauges]' which he wrote in 1998. I came across this paper when reading some of the http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/faq.aspx#Goals[F# goals in the FAQs] on the Microsoft website.

These are some of my thoughts and our discussion of the paper:

* One of the points suggested in the paper is that *functional languages aren't used because of their lack of availability* on machines but as http://twitter.com/davcamer[Dave] pointed out this doesn't really seem to be such a big problem these days - certainly for F# I've found it relatively painless to get it setup and running and even for a language like Ruby people are happy to download and install it on their machines and it is also pretty much painless to do so.
* http://erik.doernenburg.com/[Erik] pointed us to an http://prog21.dadgum.com/3.html[interesting article which suggests that functional programming can be very awkward for solving certain problems] - I think this is definitely true to an extent although perhaps not as much as we might think. I am certainly seeing some benefit in http://www.markhneedham.com/blog/2009/04/25/oo-with-a-bit-of-functional-mixed-in/[an overall OO approach with some functional concepts mixed in] which seems to strike a nice balance between code which is descriptive yet concise in places. I'm finding the problems that F# is useful for tend to be very data intensive in nature.
* Matt Dunn pointed out that an http://www.paulgraham.com/avg.html[e-commerce store written by Paul Graham], which he later sold to Yahoo, was actually written in Lisp - to me this would seem like the type of problem that wouldn't be that well suited for a functional language but interestingly only part of the system was written in Lisp and the other part in C.
+
____
Viaweb at first had two parts: the editor, written in Lisp, which people used to build their sites, and the ordering system, written in C, which handled orders. The first version was mostly Lisp, because the ordering system was small. Later we added two more modules, an image generator written in C, and a back-office manager written mostly in Perl.
____

* The article also suggests that it *takes a while for Java programmers to come to grips with functional programs* - I would agree with this statement to an extent although one of the things I found really hard when first reading functional programs is the non descriptiveness of the variable names. It seems to be more idiomatic to make use of single letter variable names instead of something more descriptive which I would use in an imperative language. I'm intrigued as to whether this will change as more people use functional languages or whether this is just something we will need to get used to.
* The author makes a very valid point with regards to the *risk that a project manager would be taking if they decided to use a functional language* for a project:
+
____
If a manager chooses to use a functional language for a project and the project fails, then he or she will certainly be ﬁred. If a manager chooses C++ and the project fails, then he or she has the defense that the same thing has happened to everyone else.
____
+
I'm sure I remember a similar thing being said about the reluctance to make use of Ruby a couple of years ago - it's something of a risk and human nature is often geared towards avoiding those!

* I think the *availability of libraries* is probably very relevant even today - it helps F# a lot that we have access to all the .NET libraries and I imagine it's also the same for Scala with the Java libraries. I don't know a lot about the Lisp world but I'm told that people often end up rolling their own libraries for some quite basic things since there aren't standard libraries available as there are in some other languages.
* Another paper pointed out as being a good one to read was 'http://www.defmacro.org/ramblings/fp.html[Functional Programming For The Rest Of Us]' - I haven't read it yet but it does look quite lengthy! Wes Dyer also has a couple of articles which I found interesting - one around http://blogs.msdn.com/wesdyer/archive/2007/01/15/thinking-functionally.aspx[thinking functionally] and the other around http://blogs.msdn.com/wesdyer/archive/2007/01/18/why-functional-programming-is-important-in-a-mixed-environment.aspx[how functional programming can fit in a mixed programming environment]

I think in general a lot of the points this paper raises have been addressed by some of the functional languages which are gaining prominence more recently - Erlang, F# and Scala to name a few.

It will definitely be interesting to see what role functional languages have to play in the http://memeagora.blogspot.com/2006/12/polyglot-programming.html[polyglot programming era] that my colleague Neal Ford foresees.