Just A Function
2018 03 17
One of my favourite quotes is by John Carmack:
"Sometimes the most elegant implementation is just a function. Not a method, not a class. Not a framework. Just a function"
I've been thinking about it a bunch recently. I got a new job last month, and the codebase is the most Object Oriented that I've worked on (after coming from the most Functional), and it's been a fascinating experience. This isn't a case of "I wish everything was done the way I'd do it". I don't roll like that. In fact, Carmack's quote cuts both ways. Sometimes an Object-with-a-capital-O is the most graceful representation - even in a functional codebase. Depending on your language, this might be less true - but typeclasses in Haskell or Protocols in clojure aren't a million miles off.
A good way to see it is that everything is just another tool in your bag, there's no need for a turf war. Personally, mutation and inheritence still terrify me, I find them so hard to follow and genuinely believe in their alternatives. But I'm always open to seeing new ways of implementing things, and I love working my way through different approaches. This whole train of thought started before even the new job, when looking through the implementation of Folktale, which is all about those prototypes. I'm still wrestling this whole thing, but it's another internal triumph for pragmatism.