4 ms·
I can get what the author is trying to say. But the article missed the most important point - OO for dynamically typed languages like Python/Ruby/JavaScript is
by namelosw 6y ago
I can get what the author is trying to say. But the article missed the most important point - OO for dynamically typed languages like Python/Ruby/JavaScript is for polymorphism, so that you can write a function accept an object that has print() method without knowing what it is.
Languages extensively use the 'bag-of-functions' style usually have a way to dispatch functions based on type, so that people can extend packages without having to modify the source code. It could be multi-methods in Clojure, protocols in Elixir, polymorphic modules in OCaml, or even powerful ones like type classes in Haskell.
But yeah, I agree 'bag-of-functions' is generally a net win in terms of language design - if the polymorphism counterpart exists.
- TristanBall 6y agoCouldn't agree more. I'm a sysadmin living in a powershell world right now, and the ability to abstract away "things that mostly behave like filesystems, but aren't” behind some classes with standard interfaces is extremely useful, as it clarifies the actual logic of the code a lot, and means I can support different backends usually with just a new class I absolutely could have done it without classes, in fact I did that first, until it clicked that I really was doing things the dumb way. Everything else is a bag of functions.. its only a couple of thousand lines of code, but limited OO was still very useful, and to me, more elegant