Skimmers Guide for Week 11 of Functional Programming for the Object-Oriented Programme

20 Jun

Skimmers Guide for Week 11 of Functional Programming for the Object-Oriented Programme

8JUN

“A function that can close over external values is called a closure. I mention that because now you know why Clojure is called ‘Clojure’.  It’s a portmanteau word combining ‘closure’ and ‘Java’.

Higher Order FunctionsWhat did we read about?

This was our eleventh week of ‘Functional Programming for the Object-Oriented Programmer‘ by Brian Manick.

We began on Page 108, at the start of chapter 9 “Functions That Make Functions”. We read through to Page 114, leaving the exercises for next week.

We learn all about closures, and the important role they play in functional programming.  First of all we looked at how repetition can be avoided by creating a partial function, and the Clojure partial function.

We then read about lifting functions to a higher order.  Higher order functions are functions that act on other functions rather than plain values.

Then we looked at point free, or parameter-free, functions and took the Clojure comp function as an example.

To finish there was  a mild rant about style, looking at the different stylistic choices that are available.

What stood out?

  • This week we started to look at what really makes Functional programming different.  You may be familiar with the idea of a factory method creating objects, but functional programming takes it to a whole other level.  Personally I found it necessary to keep rereading paragraphs while I tried to understand what the author was trying to tell me.  Hopefully next weeks exercises will help to complete my understanding.
  • We also caught glimpses of the concepts that underpin functional programming.  The author makes light of the strange expressions in little asides like “No doubt the term ‘closing’ seemed perfectly apt to someone somewhere” and “no doubt the analogy of formal parameters to geometrical points seemed perfectly apt to someone somewhere.”  Personally I’d like to know more about the thinking behind these names.
  • The mild rant on style is revealing.  In Java we are used to having conventions that are followed by everybody so that there is a consistant style.  In Clojure there are so many ways of doing something it is no wonder that functional code can be so incomprehensible.

If you read nothing else this week…

  • If you already understand higher order functions then you can skip this week.  You may find the mild rant on style interesting.
  • If you are new to functional programming then you have to read all of it.  There are a lot of big concepts being introduced.

Leave a comment