|Functional And Dysfunctional Programming
|Written by Mike James
|Thursday, 15 November 2018
Page 3 of 3
Perhaps the most notorious of all functional programming mechanisms for getting things done that are natural in dysfunctional languages is the monad.
To explain the subtleties of the monad would take another article, but what you really need to know is that the monad puts the sequence of operations idea back into functional programming. Monads provide the facilities to implement side effects, I/O, variable assignment and so on in a way that looks static - unless you look very carefully that is.
So is all of this just magic for the dysfunctional programmer to worry about?
Well yes - and no.
It is sadly true that functional programmers have a tendency to use math - category theory in particular - to make simple ideas seem very much more sophisticated.
You need to always keep in mind that programming is essentially practical and hence cannot be as complicated as abstract mathematics.
However there are times when functional programming just seems right. There is also no doubt that some of the tools of functional programming are hard to give up once you have experienced their advantages.
For example, every programming language should have first class and higher functions - it just makes things so much simpler and so much more powerful. Every language should also have some of the handy toolkit of higher order functions that functional languages have - things like map, reduce, filter and so on, the sort of thing you find in say Ruby's functools.
When it comes to some types of computation then a functional approach does seem to work well but when it comes to needing side effects dysfunctional programming does the job. If you want to build a UI there is a lot to be said for object oriented procedural programming.
Finally - should you learn a functional programming language?
After all, what harm can it do and tail recursion would be your reward.
What Programmers Know
* Recently revised
or email your comment to: email@example.com
|Last Updated ( Monday, 26 November 2018 )