Clojure Gazette 194: OOP: Why the bashing?
OOP: Why the bashing?
Issue 194 - October 10, 2016
Hello, functional friends, Why do I sometimes take a cheap shot at object oriented programming, even when it seems like it's unrelated to the topic? It's a really good question, and I've been thinking about it lately. It's just a manifestation of a bad writing habit I have. When I'm talking about FP, I'll bring up a contrasting example, which more often than not is OOP. When I'm talking about Clojure, I'll bring up Haskell. When I'm talking about cats, I'll bring up dogs. The thing is, I do have a deep connection between the things in my mind, but I am not a good enough writer to either clarify it or get rid of it. It's such a bad rhetorical technique I can see how it comes off as unnecessary, even if the things I say are true to my experience. And for that I apologize. I am trying to kick the habit. And the habit is a shame, because I have a deep respect for a lot of aspects of object oriented programming and that often doesn't come through. Object-orientation holds a very neat and elegant idea: that each object is a little computer on a network. Each computer has a small memory and can respond to certain messages. It's a brilliant insight by Alan Kay and company, because if you're going to have multiple computers on a network anyway, you might as well divide each computer up into tiny computers and push the abstraction to the limit. In theory, you don't even need to know what computer your object is running on. Erlang makes this theory practical and is now the standard for building reliable distributed systems. Smalltalk also invented a whole suite of amazing features that should fall under OOP, but most languages do not implement them. But if the OO model is so brilliant, why aren't other languages that we call OO considered good at distributed systems, let alone multithreaded programming? Why are the systems so enormous with code while Smalltalk was an entire operating system, which included the hardware drivers, a GUI system, memory management, the compiler, a WYSIWIG word processor, bitmapped fonts, sound, music, and video codecs? Smalltalk is a wonderful example of a beautiful idea and a skillful execution. Truly it is a shining example of what OO could be. But this is not OO as is practiced in most of the industry . I don't want to point fingers. When I disrespect OO, it's the reality of OO as we see written by millions of programmers, and that Alan Kay himself regrets is called OO. I wish there were another name for OO that defined just this majority subset of OO. But it doesn't matter. I'll stop bashing OO and so I won't need the name. Meanwhile I'm trying to make tools that ensure that the average functional code is better than average OOP code. I don't think that FP is immune to the same problems that befell OO. The danger grows as functional ideas gain more acceptance. I hope to talk about the process I'm working on in the next issue. Rock on! PS Wish me luck for the Clojure/conj CFP. It should be announced this week. At PurelyFunctional.tv we believe that better techniques make better software. We're building a library of lessons to teach you those techniques, centered squarely on good functional programming principles. If you're interested in functional programming, consider signing up for unlimited access .