SAP TechEd Blog Posts
Share your experiences about SAP TechEd: Write about your favorite sessions and other conference highlights.
cancel
Showing results for 
Search instead for 
Did you mean: 
fred_verheul
Active Contributor

Intro


Last week at sapteched Barcelona I did an expert networking session on functional programming. The talk was meant to make clear why this functional style of programming has been gaining popularity since about a decade, and how to get started with functional programming. The 'why' was explained using some slides, the 'how' by some live coding in Haskell, one of the most 'pure' functional languages available today.

Since a lot has been written about these topics already I'm not going to reiterate too much here. The purpose of this blog post is to show some pointers to relevant materials.

Why?

So, why should a developer be interested in functional programming? The answer is basically multi-core processors, and our inability to write decent imperative concurrent applications that make use of these multiple cores. Functional programming can and does help, because it enforces (or at least encourages) immutability. Without mutable state it's much easier to write concurrent programs. A longer explanation exactly along these lines can be found here.

For further reading I recommend Herb Sutter's Welcome to the Jungle, and even more his older piece The Free Lunch is over. Another post that's worth reading is chris.whealy 's "Why We Find Concurrency So Hard – Programming on a Multicore Machine with a Single-core Mindset".

Shameless plug: Language Ramblings is a new blog by Chris, dj.adams and myself (though I've yet to write my first post over there), targeting (SAP) developers who're also interested in the functional style of programming.

During my talk at saptd I also mentioned two secondary benefits: first, it's a lot of fun to challenge yourself mentally and to try to grasp a very different approach to software development. Secondly, having more tools (languages are basically programmer tools just like IDEs etc) at your disposal will make you a better developer. Related to this is the book Exercises in Programming Style by Crista Lopez, which I've referred to before. Another interesting reference I alluded to during my talk is Paul Graham's essay Beating the Averages. Definitely worth a read!

How?

It's of course impossible to capture a live demo in a blog post. So I won't even try :smile: . The list of topics that I wanted to cover was as follows:

I managed to get to (and through) recursion, but as you can see I had to leave some important stuff out, especially the algebraic datatypes and pattern matching. So one of my lessons learned is: no live coding next time, as it proved to be too time-consuming.

By the way, before anybody points out that type inference has nothing to do with functional programming: yes, that's basically true, but in practice sophisticated type inference is happening mostly in languages that support and embrace the functional style of programming.

As I've said above in the introduction, much has already been written on all of these subjects, and there are a lot of tutorials online. What has worked for me so far was doing a couple of MOOCs on functional programming. Here are some links:

Functional Programming Principles in Scala, Coursera

Programming Languages, Coursera

Introduction to Functional Programming, edX

More free online materials on functional programming:

Haskell tutorials

Clojure Tutorials

Erlang course

... or just Google for <insert favorite functional programming language> + "tutorial".

N.B. I prefer the MOOCs to the online tutorials, because the tutorials tend to focus more on syntax, while the MOOCs really try to teach you a new way of thinking.

Last tip: alvaro.tejadagalindo3 has written a number of blog posts on SCN about specific and sometimes weird languages. Among them some functional ones (Erlang, Racket come to mind). Check them out!

What's next?

Well, as Erik Meijer (instructor of the FP101x edX course mentioned above, and a crazy guy :smile: ) would say: Happy Hacking!!

5 Comments