Functional Programming - SICP - Clojure

September 4, 2012 . coding learning . Comments
Tags: sicp clojure github


About this topic

Short blurb of FP, SICP and Clojure


Topic buzz

What others are thinking. Add to the conversation and generate some chatter.


Read later

Save this article for a later read or point of reference. +Instapaper


Functional Programming

Functional Programming is hard. Especially for experienced folks who have been working with Object oriented concepts all these years. More-over universities are including Java as the mainstream language in the course curriculum and moving away from C or Lisp completely. Check this fantastic article by Joel Spolsky - who highlights the adverse effect of such a shift.  He writes how important it is to understand the concept of pointers and functional programming constructs. Agreed that pointers are no more used in any production code these days and neither functional languages are widely adopted - but these are required to understand the very fundamentals of computer programming and how to build complex software. He writes ".....You can't understand a line of code in Linux, or, indeed, any operating system, without really understanding pointers. Without understanding functional programming, you can't invent MapReduce, the algorithm that makes Google so massively scalable. The terms Map and Reduce come from Lisp and functional programming..."

The greatest benefit of functional programming is that - Systems built with FP are concurrency ready without any modifications. This is because functions (and functions of functions and so on :) ) in functional programming are stateless - absolutely no mutable state. No piece of data in a FP is modified twice by the same thread, let alone by two different threads - a very important fact.


SICP

There is no better way to learn the concepts of functional and recursive programming - other than from excellent course created by the best university in the world - MIT. SICP is a textbook published by MIT Press and it was formerly used to teach introductory programming class for students at MIT and other various universities.  MIT has set a very high bar and the course material is hard. Fortunately there are about 20 actual video lectures shot at MIT are available online which help in digesting some of the tough concepts. Plus there are study-groups, stackoverflow to help crack some tough nuts.

SICP book cover image

The eval-apply loop on the above front cover show the relationship between data and code and the lambda emphasizing that functions are indeed type of data. Thinking functions as first-class objects helps in understanding the important concept of abstraction and building large scale complex systems greatly benefits from this understanding - which is missing in languages like Java & C


Clojure

Lisp is one of the oldest programming language as has a very long history. This language never dies - and it has come back as Clojure on JVM. Clojure is a recent dialect of Lisp created by Rich Hickey. Rich calls Clojure as a modern Lisp.

Read more about Clojure and the rationale of building another list dialect on the official site - http://clojure.org


SICP + Clojure

SICP using Clojure is a dream combination with pure functional constructs on the very powerful JVM platform - what more a developer can ask for. I have ordered and bought and book on SICP and started learning it - solving the exercises using Clojure. An Indian edition is available on here for purchase. I'll be pushing the solutions to the exercises on the git. It is an uphill task but it helps in the long run to become a better programmer :).

 

Comments Section

Feel free to comment on the post but keep it clean and on topic.

blog comments powered by Disqus