Home > Articles

  • Print
  • + Share This
From the author of Functional Programming

Functional Programming

As many people have observed, the march of ever-faster CPU speeds has almost ground to a halt. Today's gains tend to be much more incremental than in the past. Had CPU speeds continued to double every 18 months, as we experienced during the era of Moore's Law (roughly 1970–2003), today we would see CPU speeds far in excess of 20 GHz—and climbing. Last time I checked, however, new corporate desktops still sported 3 GHz CPUs.

We may not be getting faster CPUs, but we're certainly getting more CPUs—first dual-core and now quad-core. Rest assured, something like "octo-core" is coming, and not long after that we'll see many more cores in commodity desktop computers (so long as cooling fan technology can keep up).

Functional programming is a technique that leverages lambda calculus to make computation be about the evaluation of mathematical functions, rather than about the business of initiating and maintaining state, which has been the mainstream model of computation for most of the history of computing. Functional programming has been around for a very long time, starting with the Lisp programming language in the late 1950s. It certainly isn't a new technology! So why all the sudden attention?

Functional programming languages work better in a multicore environment—remember all those additional processors? This happens because state (variables whose values can change) is very difficult to manage across threads that might be executing simultaneously on multiple cores. As anyone knows who works with databases, deadlocks can occur when two people are blocking each other from finishing their work. If you're attempting to program a multithreaded system using multiple cores, you depend heavily on variable manipulation, and your chances of creating deadlocks are high without very careful programming. This is the main reason that not a lot of software out there can leverage four cores—much less 64 cores!

While leaving state as a possibility, the features, structures, and defaults of functional programming languages, especially those that run on major software development stacks (such as F# on the .NET Framework and Scala on the Java platform), strongly deemphasize state.

Many people believe that our current systems are fast enough, and that we don't need to leverage this additional horsepower. But using these processors is key to doing everything—from desktop-based business intelligence work to high-performance transaction processing, risk analysis, customer analysis, and dozens of other ways in which smart companies will use computers to lower costs and increase margin. Start asking your friendly IT executive some loaded questions about how they're going to handle the multicore revolution and what they would do with some extra computing power, and see where the conversation takes you.

  • + Share This
  • 🔖 Save To Your Account