Pages

Sunday, 7 October 2012

The debate over Functional Programming

Yesterday, I attended the "Centenary of Turing Talks" Talk[4] at Persistent/Pune. After introducing Robert Milner's work, the objective was to decide whether _every_ programmer should learn functional programming. The debate, as with all human debates, digressed quite a bit. However the question remained unanswered. I am just giving an ardent attempt to answer this.

Details of the event are available at the following link:
http://www.persistentsys.com/About/Turing100.aspx

Summarizing the discussion and the points that were raised:
  1. Functional programming is a better abstraction and helps in thinking more about what 'needs to be' or what will be 'what is' ('is-ness' as Prof.Modi mentioned.)
  2. The best place to start learning Functional Programming would be Erlang or Haskell'98 (as Dr.Anuradha mentioned.)
  3. Starting out with monads and trying to run away from 'typed' variants is not recommended for those who are first stepping out into functional programming. (Dr. Anuradha) - (I have done this mistake, so I know this is true.)
  4. You could opt to write 'C Programs' with functional abstractions and Object-Oriented concepts like polymorphism. You could even do this with Assembly language - but that would be too cumbersome if a functional programming language already exists. (Prof. Modi) 

Everyone on the panel or otherwise knew functional programming and also knew that it doesn't get used in production.
  1. The reason functional programming gets lesser attention is the lack of digital infrastructure to support it.
  2. The "Harvard Architecture" in the market essentially assumes sequential code execution, thanks to Alan Turing's early papers. Hence concurrency is also another blocker as the architecture hasn't been rewritten to help that happen - not entirely mathematically despite the fact we have parallel processing, multicore computing happening.
  3. People start learning an "Imperative" language like "C" or "Pascal" or "Fortran" to begin with. Hence they get fewer opportunities that coax them to try out or spend time on functional programming.
  4. The switch usually has to be made at the cost of non-office times for a professional programmer, which leaves a shorter percent of time allocated towards it which is another factor that discourages people.
  5. Most people without a strong theoretical background in computer-science find it difficult to understand Object-Oriented Programming ... making Functional Programming more fringe. 
  6. Deterministic problems are seldom solved (in general practice) with functional programming as Structured programs are easier to verify and prove to be theoretically correct.

Thanks to more discouraging infrastructure factors to the more recent ideas of Functional Programming, Object-Orientation fused with Functional Programming; the 1967 creation of K&R lives on even today in production.

Recommended Reading

For Programmers you can find companies like:
http://www.janestreet.com/
http://www.helpshift.com/
who have a motto to do all their work exclusively on functional programming.

1 comment:

  1. And this point: the most popular `data structures and algorithms' literature views things in a way that is hard to be functionally solved. For example, the `depth-first search' graph algorithm can hardly be coded in a purely functional style---you always need to maintain a global stack by marking nodes `visited' or similar stuffs.

    ReplyDelete

You're welcome to comment. As long as you leave your ideas or opinions, please feel free.