The Rise of Functional Languages
Functional Languages seem to be pushing for the title of the next cool thing. Talks and tutorials about them are starting to show up in conferences and conventions, books about them are hitting the shelves, people are even asking about talking about them in blogs and mailing lists devoted to some of the current hot languages.
Does this mean you’ll be using one next year? Maybe, but probably not. Does it mean you might want to spend some time learning one? Absolutely. Brief description of functional languages. Dave Thomas and Andy Hunt the Pragmatic Programmers recommend learning a new language every year, calling it a LOTY (Language of the Year). In his book ‘My Job Went To India’, Chad Fowler complains about programmers who say things like: ‘No I haven’t been given the opportunity to work with language Foo, or framework Bar.’ This is a great chance to look at something that’s very different from the way you’re programming today, something that could change the way you think about programming challenges.
So, what are functional programming languages? At the core, they’re languages that carefully follow mathematical concepts. Variables aren’t, at least not as most programmers think of them They’re more like a variable in algebra—once you’ve found the value of X in a problem, it’s not going to change on you.
Functional languages also avoid ‘side effects’. That is, if you pass a value into a function it will not be changed and the function will not cause other changes somewhere else in your data (there’s a formal method for getting around this to do things like output … I’m not planning on getting into that here though).
Meta-programming, lazy evaluation, and type safety are much more common idioms in the functional languages I’ve seen too.
These differences mean that doing simple things like iterating over a loop and incrementing a counter as you do just don’t work in functional programming. Recursion, list mapping, accumulation, and the like are much more common in the functional world.
This might sound a little strange—I mean, how can you program without loops, or variables that can vary? In truth, functional programmers seem to be doing very well. They seem to be over-represented in the top finishers in programming competitions. Their code tremendously terse, and often scarily efficient. It’s just not mainstream (yet).
Functional Languages seem to get a lot more traction in Europe and academia right now. Over the last couple of years, they’ve been making up ground in that group Tim O’Reilly likes to call ‘the Alpha-geeks’. Whether or not functional languages are poised to take the next step into wide spread adoption is anybody’s guess, but it’s certainly a possibility.
Recently, three different publishers have release books about different functional programming languages. First, Apress put out Practical OCaml, which didn’t go over very well in the community—I know they’re looking at what they can do to ‘get back on the horse’ and get a really successful functional language book out the door.
Next up was Cambridge University Press was next with Programming in Haskell. This looks like a very solid book, and I’ve heard other people say good things about it too. I have to admit that I’m put off by the use of special characters in program listings, where the actual code would use a normal ascii symbol (for example, the greek lambda character in place of an /
).
Most recently, the Pragmatic Programmers have launched a beta of Programming Erlang by Joe Armstrong (the creator of Erlang). While this isn’t done yet, It looks wonderful, and everyone I know is raving about it—even my local Ruby brigade is going to start working through the book one night a month.
I’ve been buried under a huge load so far this year, so I’m coming late to my LOTY for 2007, but I’ve settled on Erlang. The combination of functional programming, a tremendous level of concurrency baked into the language, and a great book from Joe Armstrong and the prags has sold me. I’m looking forward to starting in the second half of May.