Friday, May 17, 2013

Coursera's Scala course

Coursera run an excellent Scala course which I just had the opportunity of participating in. The course duration is seven weeks. Each week consists of about 1.5 hours of lectures and then an assignment which can take anything between an hour to about 5 hours.  The course syllabus  is outlined here.  So personal opinion time...

Was it worth it?  Absolutely.  Unless you are a complete pro in Scala and Functional Programming you will learn something from this course - most importantly a deeper understanding of the FP paradigm.  

I remember many eons ago when I first started learning OO, like many noobs I thought I understood OO when I understood polymorphism, inheritance, encapsulation and could name check a few design patterns.  It took me a while to really realise the difference between good and bad abstractions and how dependencies that look benign can drastically increase software entropy in a project.  Similarly many people might approach FP thinking it is just all about function literals,  2nd order functions, inner functions and closures.   Well the first important point to make about this course is that it does a super job of emphasising the importance of smart and clever usage of recursion in FP.  This was not apparent to me before the course.  The reason why recursion is a big deal in FP is of course because immutable state is a big deal in FP. That is easier to achieve when you pass data between iterations as in recursion than an imperative style loop which can usually mean some object(s) is being changed across iterations. 

Now, I hope that made some sense. Because the real brain tease is when you are given a problem that you could do with one arm tied behind your back using a for loop and told to do it with recursion.  It takes a lot of practise to get really good at recursion and it is something I still have to practise more myself but the course really made me think about it much much much more than I ever did previously.

So what else did I learn?
  1. Buzz words - exact difference between function application and function type
  2. Left association for function application and right association for function type.
  3. Passing functions around anonymously - you should only be rarely using def for functions that are being passed
  4. The Art of DRY (Don’t repeat yourself) in FP.  Functions should always be short and if it makes sense to abstract out common parts do so
  5. Difference between val, lazy val, def evaluation times (evaluated once, evaluated lazily and evaluated every time respectively
  6. The power of pattern matching, especially when using it with recursion
  7. Streams – lazy lists and the memorization potential
  8. It is extremely difficult doing a Scala course when you have two very young children.
Overall a great course. I hope to elaborate on some of  ideas and topics in future posts.


No comments:

Post a Comment