Functional Programming Principles in Scala

I recently finished a Coursera class entitled ‘Functional Programming Principles in Scala’, taught by none other than Martin Odersky himself. For those that don’t know, Martin is the creator of the Scala language and a professor at École Polytechnique Fédérale de Lausanne.

Read it and weep: scala_certificate

For those contemplating taking this class, I encourage you to do so. It was well worth it! My only “caution” would be to take note of the title — the class is truly about FUNCTIONAL PROGRAMMING using Scala. Meaning, you will focus on solving problems in a purely functional way (in the mathematical sense). E.g. no mutable variables, functions as first class citizens, currying, etc.

I think the code snippet below is one of the more beautiful pieces of code I’ve ever seen, and it’s representative of the types of things you’ll learn. It defines the (infinite) series of prime numbers in a ‘lazy’ way.

def from(n: Int): Stream[Int] = n #:: from(n+1)
def sieve(s: Stream[Int]): Stream[Int] = s.head #:: sieve(s.tail filter (_ % s.head != 0))
val primes = sieves(from(2))

The entire class is 7 weeks. Each week you’ll watch approximately 90 minutes of video lectures, and you’ll have some assignments that get progressively more difficult as the course progresses. At first the assignments are very easy, but by week 6 they get fairly difficult. Expect to average around 5-7 hours per week on assignments. You’ll upload the assignments using a provided tool, and within a few minutes you’ll get your grade. You can submit the assignments as many times as you like to improve your grade, up to the point the assignment is due.

Here is the week by week breakdown of topics:

  1. Functions and Evaluations
  2. A lot of basic syntax in here. You’ll learn about the concept of functions as first class citizens, evaluation strategies and tail recursion.

  3. Higher Order Functions
  4. Composing functions using other functions, currying

  5. Data and Abstraction
  6. How to compose more complex data structures, polymorphism

  7. Types and Pattern Matching
  8. Functions as objects (everything is an object!), subtyping, generics, pattern matching

  9. Lists
  10. Pairs, tuples, higher order functions on lists (such as map and filter),

  11. Collections
  12. Collections other than lists, such as maps and sets. for comprehensions (not your standard for loop!)

  13. Lazy Evaluation
  14. Trees, streams, lazy evaluation.

I can’t say enough good things about this class. The material was interesting, the assignments were challenging, and I thoroughly enjoyed it.

This entry was posted in Software Development. Bookmark the permalink.