Functional Programming Principles in Scala: three weeks in

Two of the Guardian's software developers update us on their experience of the latest stage of the programming course

Lindsey Dew, Adam Fisher

Published on Friday, 5 October 2012

Functional programming   Programming  

Some of the Guardian's developers working on Coursera's Functional Programming Principles in Scala course
Some of the Guardian's developers working on Coursera's Functional Programming Principles in Scala course Photograph: Lindsey Dew/guardian.co.uk

We’re now several weeks into Coursera’s Functional Programming Principles in Scala course and thought it was time to update you on our progress so far. The developers here at the Guardian are still very excited about the course, especially now that it’s started to pick up pace. This week in particular, the course has moved on from basic programming concepts, with week three introducing data and abstraction via Scala’s unique synthesis of functional and object oriented programming paradigms.

Weeks one and two saw recursion and set theory, which course instructor Martin Odersky demonstrated with some mathematical examples. While this is a joy for those who love nothing better than pondering abstract data structures and logical quantifiers, those who signed up for the course to improve their web development skills using Scala may have found this high level of abstraction so early on to be fairly off-putting. Examples based on more familiar grounds can be more compelling, particularly for anyone new to programming or without a background in mathematics.

The other main gripe we’ve heard from others taking the course is that the earlier assignments often had very little to do with the corresponding lecture material. It’s almost as if there were two wholly distinct sides to the course. First we learn programming principles from Odersky’s excellent videos and the included exercises, and then we solve a set of challenging and interesting – if irrelevant – computer science problems. While both of these facets are enjoyable, we found ourselves hoping for a bit more focus.

Fortunately, week three’s exercises represent a clear shift towards more tangible concepts with concrete examples that make clear use of the concepts we’ve been learning. With this knowledge, we now have all of the pieces we need to start writing larger programs. This week’s assignment incorporates the recursion and set theory introduced in the first two weeks into a program that analyses trending tweets from popular tech blogs. While this assignment deals with Twitter, the same principles are at play regardless of the type of information being manipulated, nicely demonstrating how the abstract theories introduced earlier in the course can be applied to the problems programmers face in their day-to-day work.

Having started work at the Guardian without any experience in Scala, we both feel that this course would be a fantastic introduction to the language. As well as covering functional programming principles (the unfamiliarity of which often causes a lot of the problems beginners have with Scala), it has now begun to cover the language itself. For anybody thinking about learning Scala, this course is an excellent way to get started. Having a good understanding of just a couple of core principles makes interpreting Scala codebases much less intimidating, and encourages a particular way of thinking when it comes to writing the language.

If you’ve found the first few weeks hard going, it’s well worth persevering through the abstract concepts introduced at the beginning of the course. Getting familiar with recursion and reasoning about higher order data abstraction can change the way you approach programming problems, which can have benefits well beyond this course, and even Scala itself. As the course continues, we suspect we’ll see more and more applications of these concepts.

Continue reading

Winning the metrics battle Responsive design at the Guardian: an introduction