You are viewing a single comment's thread from:

RE: Getting Started with Functional Programming

in #programming7 years ago

In my understanding, OOP paradigms are inclusive of Imperative, Functional and Procedural methodologies. Behaviors of OOP objects can be coded in a way that alter the state or do not alter the state of the invoking program.

What I mean to say is that you appear to be describing OOP as something opposed to functional programming when it really is not. The OOP environment can contain procedural (state changing) and functional (non mutable state) concepts. And you do say this, but you do so with the implication that functional programming is somehow opposed to OOP.

A good example of Functional Programming in an OOP environment is F# which is a functional language purposefully encased in an OOP environment. I think (IMHO) that a better illustration of differences between programming paradigms would be procedural vs functional. :D.

Here's a link to a thesis on F# OOP programming: http://www.idt.mdh.se/kurser/DVA201/slides/oo.pdf

The rest of your thesis is on the money. Thank you for the treatise on Functional programming.

Sort:  

What I mean to say is that you appear to be describing OOP as something opposed to functional programming when it really is not.

Yes, I do believe that I oversimplified this a lot. In fact, languages like Erlang take an approach much closer to OOP in their design than many "OOP" languages. The main point I was trying to get across was that instead of relying on common object relationships ("I can mutate myself/my instance variables"), you can instead write code in a more functional style. If I had written a longer version of this article I probably would have gone more in-depth on OOP vs. procedural and functional vs. imperative instead of just calling it OOP vs. imperative.

Please don't get me wrong...I enjoyed the hell out of your excellent post.

You are right that FP and OO are not opposed BUT they are very different mind sets.

While F# might run on an OO platform it is still a full FP language based on ML/OCAML (It is missing higher kinded types but that was the .NET platform that caused that limitation). MS just bolted on syntax that allows it to interact with C# and the other languages hosted on .NET

Trying to do OO in F# actually causes a lot of limitations in the language. Things as basic as the pipeline operator failing to play nice once you start using "member" variables. Things just do not compose as well :(

Functional programming is really a complete mental shift from OO. No classes, just data and functions. Oh and functions are also data.

I have written a series called Functional programming for the OO developer, currently intro and 4 parts that explores the difference in mindset of the two style for OO people.