Thursday, August 16, 2012

A view on joining OO and FP

I've done some work lately on CoffeeScript and Node.js. One question that frequently comes into mind in this environment is how to join OO and Functional paradigms.

The whole idea of asynchronous JavaScript of course presents a clear way to do a lot of stuff. Event based message passing system of Node.js makes a clear alternative for using anonymous function spaghetti in a traditional JavaScript way. And this raises again the question of how to join these two very different Paradigms.

Another place i have recently encountered one way to combine the power of these two ideas is the Microsoft LINQ. It presents a quite elegant way to enter queries to a OO program by using a combination of FP and OO techniques.

Today i read an interesting article on one way to resolve this. A blog post by Michael Feathers from march. In the Post Feather suggests that OO seems to be more about telling objects to do stuff. FP in contrast is about asking functions for something. He suggests that it might be a good idea to combine these on an System so that the upper most layers of the system are composed of objects that are told what to do and lower levels of functions that these Objects use. Sounds plausible, although i have to admit that the FP side of my soul is crying in pain on the idea of being bossed around by a bunch of mutable state entities...

What do you think?

No comments:

Post a Comment