Whyfore Art Thou Functional vs. OO

John Cook had an interesting post here: http://www.johndcook.com/blog/2010/11/03/object-oriented-vs-functional-programming

I think the Functional vs. Object Oriented argument is largely made up. It’s basically arguments over code style and syntax. Which, of course, are the fiercest arguments in our stupid industry. It’s just a matter of how you want to divvy up your code. Either you use little functions with complicated arguments, or complicated objects with functions with smaller arguments. There are good points in either style of programming about which is easier to code and validate.

…And on top of that, there are the structural guys who never really got over the idea of a large global function. They just roll their big functions into objects, usually Singletons or as static methods, or as Singletons with static methods, and then go off to lunch, whistling.

…completely unaware of the harm they are doing to the world. Notably, to me.

You can do functional programming in Java, even without Java 8. And you can do object-oriented programming in the functional or procedural languages. All languages provide a way to bundle data and functions, even if it’s just a map (or dict for the pythonneers). It’s just that the compiler says, “I’m not going to let you do that easily, because I think it’s dangerous.”

It’s like the old joke: A PASCAL programmer, a Java programmer, and a Scheme programmer walk into a bar … oh wait its all the same guy.

The more fundamental problem is the difference between imperative and declarative thinking. When developers first walk into the declarative realm, they are just flummoxed when they discover they can’t change the value of a variable they’ve assigned. In the declarative world, you have to think about how to build the answer piece by piece instead of just updating the pieces. That can be really hard if you’re not used to it.

I spend time thinking about declarative programming, and a lot of time thinking about OO, of course. But I always find the declarative problems more fundamentally alien to my usual way of thinking.

Advertisements

Leave a comment

Filed under computer industry, computer OOD, opinionizing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s