Live data from Hacker News

OOP Is Dead, Long Live OOP

gamedev.net

71–80 of 357 posts

Re: OOP Is Dead, Long Live OOP

#72
post #22

OOP is just a mental model. Deep down everything is made of bits. The church of OOP has failed but if something looks like a duck, walks like a duck and talks like a duck it probably is useful to make a duck class. We're now down to fighting for nuances. You can do most things with OOP or without OOP but each path has some upsides and downsides and most of the time it's good to use some things it provides where it ma…

How has the church of OOP failed? Nearly every used language is based almost entirely on OOP. OOP makes organizing software and code reuse incredibly easy. The only real downsides to OOP is that its arguably slower and has more overhead. But that's only a problem in niche applications (ie. embedded apps).

> OOP makes organizing software and code reuse incredibly easy.

That is the big promise and the big lie of OOP. It, in fact, accomplishes the opposite.

The medium used across systems today is data, not objects. Your objects are not compatible with systems across the wire, they need to be converted to data (JSON, XML, ...). They're not compatible with your data base, they need to be converted to data (SQL, ...). And if you want to use other people's objects (say from a library) you first have to make a layer that translates them for your own objects, since objects from other systems won't directly fit the model of your own object system, they always need to be engineered in. And if the objects are encapsulating data that you actually need, but doesn't offer ways to get it (private methods), you often have to jump through hoops to get it.

Not to mention the fact that OOP often entails immutability which leads to problems while doing multithreaded processing.

Clearly the answer is to use a more data-oriented perspective and use a programming language focused around data. Clojure gets it right and that's what I use. It's all concise functional code that skips all that class creation OOP loves, instead operating directly on immutable data (numbers, strings, maps, vectors, sets).

I recommend watching some talks by Rich Hickey (the guy who made Clojure). They're almost all excellent.

Re: OOP Is Dead, Long Live OOP

#74
post #63

I think OOP is fine as long as it's the only thing you are doing and as long as it is single-threaded. Problems will occur if you need to convert the innards of your objects to data (i.e. JSON etc.), if you need to materialize objects from data (i.e. ORM) or if you need to write multi-threading safe code. If you expose things as data, just be honest about it and treat it as such. It's already out in the open, why hid…

> if you need to convert the innards of your objects to data

Not to mention: when you need to make objects correspond to a database.

Re: OOP Is Dead, Long Live OOP

#75
Software developers are systematisers by default. We tend to value complexity for it’s own sake, hence the over-engineering common to software projects. The methodologies we use fall victim to the same tendency. We build complex, rigid rule sets that are claimed to improve software or development speed or whatever else, without any actual empirical evidence that these claims are true.

All you can really do is try to be knowledgeable about the methodologies, use the right tool for the right job, and try to keep things as simple as possible. And don’t subscribe to anybody’s dogma.

Re: OOP Is Dead, Long Live OOP

#76
post #48

I don't understand why this article is so angry? ECS is a great subset of OOP. Both are helpful tools where they make sense.

ECS as they are using it in this blog is about Data Oriented Design. It's not just OOP plus favoring composition over inheritance. DOD explicitly advocates separating data from behavior, and is strongly opposed to OOP in general.

Just so I understand you right: they're advocating global functions to operate on predictably similar data structures? If that's the case, it seems like you'd want some of them to be object-oriented, and some not.

Re: OOP Is Dead, Long Live OOP

#77
post #63

I think OOP is fine as long as it's the only thing you are doing and as long as it is single-threaded. Problems will occur if you need to convert the innards of your objects to data (i.e. JSON etc.), if you need to materialize objects from data (i.e. ORM) or if you need to write multi-threading safe code. If you expose things as data, just be honest about it and treat it as such. It's already out in the open, why hid…

OOP with threads is fine. Mutability is orthogonal to OOP anyways.

Re: OOP Is Dead, Long Live OOP

#78
post #9

If we just had made inheritance as something to be avoided unless absolutely needed then OOP would have probably never got such a bad reputation. All the other concepts make perfect sense.

Inheritance can be so randomly abused as just a code saving hack.

Look how I abused inheritance in this assembler (for a Lisp virtual machine):

http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib/asm.tl

The object system is used to define opcodes. Methods on these objects (which get instantiated as singletons) then handle assembling and disassembling.

There is a macro defopcode-derived which defines an opcode similar to another one, using inheritance.

There is no reason for the relationship to go one way or the other; it's just "this thing is like that thing, except for this slight difference". The inheritance could basically go in either direction.

Note that defopcode-derived doesn't even have provision in its syntax to specify behavior; the code is 100% re-used. The only thing different about the derived opcode is the instruction mnemonic and the opcode bits. Inheritance is used just to override a number and symbol which are static slots.

Re: OOP Is Dead, Long Live OOP

#79

Took me a long time to grok OOP and OOD (was introduced to OOP in '91). At first I thought I knew it, and then realized I didn't. Plane into the side of the mountain, no survivors, call off the search. Which is when I really started to learn (around '96/97). And now I love it. Until I come across people who always start by defining an interface first and then think about what might follow. And dependency injection. H…

DI is bad, what? So how are you writing tests then.

I always though dependency injection was an inevitable product of over zealous testing. As soon as someone says we need to test 100% of the code in our UI that is where you end up.

Re: OOP Is Dead, Long Live OOP

#80

Took me a long time to grok OOP and OOD (was introduced to OOP in '91). At first I thought I knew it, and then realized I didn't. Plane into the side of the mountain, no survivors, call off the search. Which is when I really started to learn (around '96/97). And now I love it. Until I come across people who always start by defining an interface first and then think about what might follow. And dependency injection. H…

DI is bad, what? So how are you writing tests then.

Like in procedural languages I write my own harnesses as needed. Because DI adds complexity. And for testing all DI does is make testing easier. You end up shipping all that complexity or you refactor your ship code. To be fair that might be acceptable to many in a typical corporate environment.
Post reply on HN