Functional programming languages are gaining significant traction in industry for building web applications. Functional programming languages coexist with existing procedural and logic language paradigms. To review programming language paradigms:
Procedural language:
1
2
3
4
5
6
7
8
9
|
function greaterThan3(items) {
List<Integer> list = new List<Integer>();
for (int x : items) {
if (x > 3)
list.add(x);
}
return list;
}
|
Logic language:
1
2
|
GreaterThan3(x) = x > 3
SELECT x FROM items WHERE GreaterThan3(x)
|
Functional language:
1 |
items.select( |x| : x > 3 )
|
The allure of a functional or logic language is its expressiveness for developers and extensibility for multi-processor computing. Developers write few lines of code in functional and logic languages to express the same concept as in a procedural language, for example, selecting items from a list (above). Functional and declarative languages only specify the result to obtain, not the steps to obtain the result as in a procedural language. The compiler decides how to use multiple processors, threads, and computer servers to complete the computation.
New web frameworks have been created for functional languages in the past decade. Here are some examples. Running on the JVM, Groovy is a variation on Java with function language features such as closures and Scala makes the functional paradigm primary. Scripting languages such as Python (own runtime & JVM option), Coffeescript (compiles to Javascript), and Ruby (own runtime & JVM option) incorporate functional language features. Popular web application frameworks run on these functional languages. Groovy has Grails, Scala has Lift and Play, Python has Django, and Ruby has Rails.
As it currently stands, functional languages are flourishing in web frameworks, which is the middle- or back-end tier of a website. The front-end tier, which does not assume or need multi-processor computing, remains exclusively a procedural paradigm as this time. JavaScript, Flash’s ActionScript (JavaScript variant), Java applets, and improbably Silverlight are used for front-end programming.