I've been doing that as a hobby on evenings and weekends, as I'm only using Java at work. Evenings and weekends have added up and I've actually done quite a bit of real functional programming in Scheme and F# now, as well as some functional 'style' programming in Python and C++ in weekend contributions to the Apache Tuscany C++ SCA project.
I'm only starting to digest that Functional Programming experience.
I'm not sure I've completely digested Web programming yet, but I've got over a number of good and bad, or let's say 'learning', experiences.
Last week I was bored and I started to think about similarities between Functional Programming and Web Programming. I thought about a few fun analogies:
- Start with an HTTP GET http://whatever.com/add&x=1&y=2. That looks to me like the application of a function 'add', with precise input and output. An idempotent function with no side effects. Like with Functional Programming, the result can be produced by executing code (a Python script for example), or just a table lookup (a pre-generated page for example.)
- Use a URL like http://whatever.com/add/1/2. That looks less that the location of a script with parameters and more like the location of a resource, or data item. It's starting to blur the line between function application and access to data. Like with Functional Programming, Web functions and data seem interchangeable.
- Do an HTTP redirect or use a URL shortening service to shorten http://whatever.com/add/1 into http://bit.ly/axIyzo for example, and you have function currying.
- Use a caching proxy server or use client side caching based on last-modified of etags headers, and you're doing function memoization.
- The HTTP POST, PUT, DELETE verbs introduce precisely identified side effects. That's what you're looking for when you do Functional Programming. When you can't avoid them, you want to be very explicit and precise about the side effects introduced by your code.
- Return an HTML page. That looks like a value representing a computation, which will perform some I/O in your Web browser at the edge of the system. Will functional programmers see the analogy with an I/O Monad?
- HTTP is stateless. When you pass state around across multiple HTTP interactions, wrapped in additional hidden fields or parameters on your URLs, are you implementing a State Monad?
- Finally, could Functional Reactive Programming and lazy event streams help you implement AJAX callbacks, subscribe to ATOM feeds or Pubsubhubbub updates for example?
Something to think about... What if Functional Programming was a perfect fit for Web programming? What if you could compose Web functions like functional programmers compose functions?