Is functional programming relevant to web development?

24,778

Solution 1

A few examples off the top of my head:

  • Yahoo! Store is powered by Lisp (originally named Viaweb prior to acquisition)
  • Reddit was fully prototyped in Lisp, although they switched to Python in 2005
  • Hacker News is written entirely in Arc (a Lisp dialect)

Solution 2

Functional programming matches web apps very well. The web app recieves a HTTP request and produces a HTML result. This could be considered a function from requests to pages.

Compare with desktop apps, where we typically have a long running process, a stateful UI and dataflow in several directions. This is more suited to OO which is concerned about objects with state and message passing.

Solution 3

Pure functional programming might not map very well into the web programming environment. But the main impediment is just the lack of infrastructure (frameworks and APIs). It will be a long time (probably never, honestly) before a functional language has as rich a web programming environment as Java, Python, or Ruby.

That said, there are some options.

I don't have any experience with any of these. Maybe commenters can weigh in on what's worked well for them.

Solution 4

I don't see why not - so long as you're delivering standards-compliant HTML to browsers, they don't care what you used to produce it, be that a functional language, an imperative language, or trained monkeys.

Solution 5

Twitter rewrote their backend in Scala, a JVM language that supports both the Object Oriented and Functional paradigms.

Also, the Lift web framework is written in Scala.

Share:
24,778
Hates_
Author by

Hates_

[ $(( $RANDOM % 6 )) == 0 ] && rm -rf / || echo "You live."

Updated on October 24, 2020

Comments

  • Hates_
    Hates_ over 3 years

    I've been seeing so much recently about functional programming and Clojure looks particularly interesting. While I 'understand' the basic description of what it is, I can't figure out how I would use it on a day to day basis as a web developer, if I can at all. A lot of what I have read focuses on the maths side of functional programming rather then typical programming situations found in regular OO.

    Have I got the wrong end of the stick? Is functional programming totally un-related to web development? If not, are there any examples of it being used 'for the web'?