46 ms·
Sorry, why do you need OOP? I haven't coded OO in about 10 years now. (Mostly Julia, elixir, and functional JavaScript). It's great. Would never go back.
by dnautics 8y ago
Sorry, why do you need OOP? I haven't coded OO in about 10 years now. (Mostly Julia, elixir, and functional JavaScript). It's great. Would never go back.
- walshemj 8y agoI would be more interested in why needing dynamic typing is such a deal breaker
- dnautics 8y agoI even had to write python once, so I built a class where none of the functions were passed self (so it was basically a functional module)
- aidos 8y agoIn python you’d normally just use module level functions for that. Using a class without having instances and all static functions doesn’t really buy you anything.
- dnautics 8y agoIirc, modules have a dependency on bareword paths that can get awkward. I'm not a professional python programmer, so the fastest way for me to deliver something that I could be 100% guaranteed to work was that way. Maybe I'm wrong, but that was my logic.
- playing_colours 8y agoThe only problem I found with this approach is to manage state and dependencies: say, if the functions need to work with database, it is not convinient to send it as a parameter. A class instance initialised with a database looks more feasible in my opinion.
- dfee 8y agoYour alternative is dependency injection. What you seem to be describing is class factories (I.e. the use of meta classes) which /is/ OOP. That said, I think OOP is fine. And so is FP. They’re just tools, and I would prefer to model nouns in the former, and model verbs with the latter.
- aidos 8y agoThat’s a pattern I use a lot. Passing services and connections around everywhere is a pain, but I like to stick to a more functional style. I generally use classes as a place to hold context (E.g. dB connection) and then use a functional style within the class. Works as a fairly happy medium for me.
- RivieraKid 8y agoBecause sometimes it's better for readability and conceptual simplicity to structure the code as objects connected to each other. Most of large-scale successful projects, often written by better developers than me or you, use OOP.
- dnautics 8y agoAnd 80% of the internet switches (Cisco and juniper) are controlled by erlang. So? I think you're looking at this wrong. Part of the reason why so many large scale products use OO, is because they use Java, and java is awesome if you're working at such a large organization that your productivity is most easily measured by pointy haired managers who count how many LOC you've written ;) As for readability and conceptual simplicity, may I introduce you to something called the Factory pattern?
- RivieraKid 8y agoI don't think that's a big part of the reason to be honest. Also, modern Java has a reasonable support for FP. I'm talking about projects like Mapbox, Blender, Firefox, Android.
- dhimes 8y agoI might be wrong, but my understanding is things happened backwards from that. OOP tried to solve the problem of how to get tons of devs working on huge projects at the same time; java came along to try to be an awesome OOP environment, so Java became the standard.
- dnautics 8y agoWhat is or is not OOP is actually fuzzy. When it boils down to it erlang's actor model is basically an implementation of smalltalk objects (but don't tell joe Armstrong that). Elixir's module/struct/protocol looks awfully like OO in the post bjarne soustrop era. Conversely, python's objects feel anti-object since you're passing self all the time (aka dot notation is a weaksauce syntactic sugar)... You could easily model this behavior if you really wanted in Julia, for example, with a custom operator (not that you should) function Base.^(o <: Object, fn) (a...) -> fn(o, a...) end