Software

What's the future of programming? The answer lies in functional languages

Simon Peyton Jones describes functional programming languages like Haskell as a proving ground where programmers can test new ideas.

If you want to see which features will be in mainstream programming languages tomorrow, then take a look at functional programming languages today.

So says Simon Peyton Jones, principal researcher at Microsoft and key contributor to Haskell, a longstanding and consistently popular purely functional programming language.

avataruser1465484273-180x180.jpg

Simon Peyton Jones says functional programming languages time has come.

Image: Microsoft

Functional programming differs from what many people think of as programming, stripping away the complexity of tracking the global state of a program in favor of the simplicity of focusing on feeding values into functions and collecting what they spit out.

"The way most programming languages are built, they're called imperative programming languages, they say 'Do this and then do that'," said Peyton Jones.

"A functional programming programming language doesn't say that, it says 'The result is this'. Think of a formula in an Excel spreadsheet, it doesn't have a sequence of steps, it just says the value of this cell is something."

Peyton Jones describes functional programming languages like Haskell as a proving ground where programmers can test new ideas.

"Functional languages have a particularly compact intellectual core. They're particularly tractable in your head and because they're tractable that means you can be more ambitious in what you do with them," he said.

Over the the years, he says functional programming languages like Haskell and OCaml have given rise to a wide variety of features that have ended up in other languages.

"There's repeated examples of ideas being born and growing up in the functional programming space," he said.

SEE: Hiring kit: Python developer (Tech Pro Research)

"Languages like Haskell and OCaml have served as a laboratory for new ideas to be developed, some of which have then made the transition into the mainstream.

"Garbage collection is one, parametric polymorphism is another. Generics in Java were introduced in the early 2000s, but they'd been in functional languages for 20 years before that. The Java guys thought 'That's cool, we should have that'.

"Things like Linq, the language-integrated query stuff in C#, that's straight from Haskell actually. F# workflows are drawn directly from this [Haskell's] monadic I/O story."

That experimentation within functional languages continues to this day, with developers finding ingenious ways to tinker with mechanisms that control which types of data can be fed into and returned from functions in Haskell.

"I think in the last few years we've seen type systems get a lot more sophisticated, and Haskell's is a particular example, it's a wild-west for cool new increments to what you can do with static types," he said.

"There's really interesting stuff going on there, and I think Haskell is right at the front of that. I find that it's our industrial users who are investing most effort in writing these more sophisticated types.

"There's a company down the road [in Cambridge] called Maplesoft, who built a compiler written in Haskell that's something to do with their machine learning. They do really scarily clever things with Haskell types."

To some extent functional languages' time has come. As Moore's Law slows down, computer users have to rely on software being able to run in parallel on multi-core chips to deliver the biennial speed ups in processing power that have taken place historically. Functional languages like Haskell are particularly well-suited to executing code in parallel, because there are far fewer opportunities for code to clash.

"If you think about a parallel program, [you need to know] can you do these two computations in parallel? Well, yes if they don't interact. How do you know if they interact? That turns out to be a very hard question," he said.

"But in a functional language it's true by construction that they cannot interact. So it forces programmers to be very explicit about all the interactions between the parts of their programs and that that leads to fewer bugs."

Functional languages are still relatively niche, but despite being around for 27 years, the user base for Haskell, and other functional languages, remains strong. Corporate use is also rising, and today Haskell is used by Facebook for spam filtering, as well as at Bloomberg and Google. Peyton Jones doesn't see interest in functional programming evaporating anytime soon, particularly not as companies wrangle with the complexity of managing massive codebases and distributed systems.

"What I think has changed is that people care more about writing software that works," he said.

"They always did, but the more ambitious we've become, the more difficult it becomes to keep our existing sellotape and string stuff of imperative programming to hold it together.

"Writing software is all about managing complexity, the only thing that limits how ambitious the software that we write is, is really our ability to manage complexity, and functional languages give you much sharper tools for managing complexity than imperative ones do."

Also see

About Nick Heath

Nick Heath is chief reporter for TechRepublic. He writes about the technology that IT decision makers need to know about, and the latest happenings in the European tech scene.

Editor's Picks

Free Newsletters, In your Inbox