Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Functional languages: What they are, where they're going

Paul Krill | Feb. 18, 2016
The men behind Clojure, Scala, and F# explain what functional programming actually is and how the languages are evolving

Even as some argue exactly what it is, functional programming keeps attracting developers. And three of the most popular functional languages — Clojure, F#, and Scala — are on tap for improvements.

Functional programming has a core appeal for some developers, says Scala founder Martin Odersky: "The programmers in that segment like functional programming because it makes code clearer, better structured, and it prevents many classes of errors." But some argue that functional programming leads to less-efficient software.

Functional programming also requires thinking about programming in a new way, says David Stephens, Microsoft's program manager for .Net and a spokesman for F#. Abstractions can be an issue: "When you make code more abstract, when you're moving further away from manipulating bits and explicitly going through loops, it can take more time to understand these abstractions."

What is a functional language, exactly?

In its most basic terms, functional programming is about treating computation as mathematical functions. In addition to languages billed as functional from the start, the likes of Java and C# have become more functional by adding support for lambda expressions.

But a precise definition of functional programming can be hard to pin down. The Clojurefun blog cites several definitions it believes are incorrect, including defining functional programming as enabling a functional style with higher-order functions or a language supporting lambdas. It says the correct definition is a language emphasizing functions and immutable data.

But the Clojure blog's preferred definition isn't necessarily correct, others say. "The author picks one, which incidentally fits Clojure best — no wonder, this is a Clojure blog," Scala's Odersky says. "I have an interpretation that is close to his, but not the same."

A function, Odersky says, is a piece of code that maps inputs to outputs and has no other effects beyond that. "It's the mathematical definition of function we are using here. Sometimes these functions are called 'pure,' to distinguish them from, say, functions in C." A functional language focuses on programming with pure functions, making it easy and powerful to do so, says Odersky, who founded Typesafe, the provider of the Typesafe JVM application development platform.

Functional programming can be combined with other paradigms, he notes. "For instance, functional goes really well with object-oriented. Scala is a functional language in that sense. I agree that just having lambdas does not make a language functional; it is necessary but not sufficient."

Clojure developer Rich Hickey, who's also CTO at systems developer Cognitect, concurs with a main contention of the Clojure blog. "The article correctly points out that first-class or higher-order functions are not what functional programming is all about. Functional programming is about making programming more like mathematics," he says. That says, there still remains a spectrum of definitions for functional programming, Hickey says.


1  2  Next Page 

Sign up for CIO Asia eNewsletters.