Menu Categories Author

Nubis Novem

Consulting On Cloud Nine

ProgFun is back

ProgFunIn about a month, on April 25, 2014, the next iteration of Functional Programming Principles read by Prof. Martin Odersky starts on Coursera. Regular college or university students contemplating participation should by all means follow their mentors’ advice. Mine is for those among seasoned and mature programmers, both professionals and amateurs, who have missed the opportunity to master functional thinking in their good time but are sharp enough to see their peers—who have had the chance—running circles around them intellectually.

Text-books and full- and part-time training programs targeting elements of functional programming galore nowadays also as canned audio and video courses. (Among the latter, I would point out Profs. Hal Abelson’s and Gerald Jay Sussman’s Structure and Interpretation of Computer Programs (SICP), an “adult” version of their all-time-classic introductory course with MIT and their textbook by the same name). Nevertheless the course by Prof. Odersky remains the one-off, to the best of my knowledge, endeavor to introduce mass students to functional programming in the format of a massive open online course (MOOC). So if one aspires to study the subject matter—but dreads the boredom of solitary self-study while lack of time or other resources exclude classroom attendance—this may easily be the last and only chance this season!

The course arrangements may (and do) somewhat vary with iterations, but hopefully my reference to the latest one may prove of some help. “At least one year programming experience” requirement set out as a prerequisite would probably underestimate the challenge, as in my assessment most of those whose experience in programming is literally restricted to one year would have hard time coping with the course, and it would take a prodigy to master it with this meager background given the estimated 5 to 7 hours × 7 weeks. On the other hand, good though imperative-only practice coupled with expertise in studying new languages would cut down the hours by half for half of units, mere residual reminiscences of a standard e. g. Lisp course will easily give one the benefit of a 50 per cent reduction of the entire time estimated.

Prof. Martin OderskyThe study plan goes from defining and using functions, concepts of recursion and of termination and non-termination to higher-order functions, to functional objects, to pattern matching, and to the concept of strict (greedy) and lazy evaluations. The entire course is somewhat of an open ball to be closured (pun intended or not) by the first two lectures read by the same professor in another Coursera piece, Principles of Reactive Programming, and I still wonder why the topics were not covered in the first Principles. These encompass (on top of the first course summary) the introduction to a very important concept of monad as well as demonstrate some truly amazing techniques combining functional declarations with rather imperative and sentential organization of the process flow. I would definitely recommend the first two lectures even to those enrollees of the first course who are not planning to last through the second one.

Each week offers ~1½ hours of lecture space, a quiz on Coursera platform and an automatically assessed programming assignment. Compared to self-study, the distinctive feature of a MOOC is its online forum. In “my” iteration of the course, Professor paid little to no attention to the forum (unlike the first iteration of the second course) but teacher assistants and community experts performed brilliantly with no questions disregarded or unanswered.

Why Scala? While most classical introductory textbooks in functional programming (like the above-mentioned SICP or Prof. Matthias Felleisen’s et al. How to Design Programs (HtDP)) employ one of Lisp dialects, many recent books prefer Haskel if not an even more highbrow alternative. Prof. Odersky’s course features Scala, the language of many trade-offs, industrial no less than academic. As to its industrial scope, one may search for “Scala vs your-language-of-choice” (plunging into the habitual atmosphere of language wars), and praising its academic merits, I would restrict myself to calling it scientifically informed (Martin Odersky being Prof. Niklaus Wirth’s student) and I would also add that for each not apparent language design decision I did find some justifications.

It may be less obvious to claim that Scala meets the need for a language facilitating spontaneous, ad-hoc computing.

But at least I found Scala REPL funny enough to replace the Python window once used as a “desktop calculator” to solve everyday problems. Here are some of its features enabling my casual programming by making it more intelligent and math-intense (i. e. ultimately more fun):

1) Pure “objectness”, operations over “primitives” and application of methods being synonymous.

2) “Type safety” with inference of types and possibility to omit any declarations.

3) “Functionality” with functions of any order as both arguments and results of functions and immutable collections library.

3) “Imperativeness” with its assignments, loops (and capability to define the exotic ones), mutable collections library.

4) Means to construct abstract types with multiple inheritance from abstract classes and traits.

5) Arbitrary “laziness/strictness” (greed) of computations and ability to process infinite streams.

6) Pattern-matching of anything constructed.

7) Some extras like Unicode anywhere or XML as a predefined data structure.

Hooked up? Free Coursera courses are lavishly complemented with commercial courses and vast and growing number of books. A comprehensive review of the latter to follow.

Comments

(1)

Leave a Reply

Your email address will not be published. Required fields are marked *