3 ms·
90s-style Java OOP showed everyone that heavy use of multiple inheritance is the worst thing since 80s-style BASIC where ever third line was a GOTO. Imagine on
by copx 2y ago
90s-style Java OOP showed everyone that heavy use of multiple inheritance is the worst thing since 80s-style BASIC where ever third line was a GOTO.
Imagine one class inheriting from 50 other classes through multiple inheritance..
People really used to construct classes like:
"Iron Sword inherits from Iron which inherits from Metal which inherits from Meltable (which inherits from Temperature) and Material. But of course it also inherits from Sword which inherits from Weapon and Edged. Meanwhile Weapon inherits from Equipment which inherits from Ownable and Item which.." and so on.
Basically you make every aspect and attribute of an entity a class and then create your entity's class by mushing together all those classes through multiple inheritance. The results are..not pretty.
Such code quickly becomes very hard to comprehend and maintain.
- mikepurvis 2y agoYup. No amount of generated documentation or static analysis can make up for the cognitive load required to reason about where a particular method is actually being dispatched to under those conditions.
- deleted 2y ago[deleted]
- Jtsummers 2y ago90s Java did not have multiple inheritance (nor does today's Java). It did have multiple interfaces, but they only carried a spec of the interface and no implementation details beyond that. C++ was the one with multiple inheritance, if you are trying to reference a popular 90s OO language.
- anthk 2y agoOOP would work fine for a text adventure, such as Inform6 against the Z-Machine, which pretty much the gameplay rooms->objects it's perfect for this. For everything else... well... maybe just CLOS it's usable enough.
- cess11 2y agoThe MUD-family of games are usually built in a C-like OOP-language, LPC. I think it's rather nice.
- anthk 2y agoUnder Inform6 the inheritance and OOP features are literally that, objects have attributes and you can create in-game objects (rooms are objects too) which are instances of defined ones. Such as always 'lighted' rooms, a furniture class by defining as object as 'scenery' (you can't take it). That's an elegant example on coding Inform6 which transpiles against the Z Machine, but overall I won't use OOP outside gaming.
- cess11 2y agoRather similar, then. I've come across GUI and a database where I thought object orientation was nice, and I'm also fond of contemporary Smalltalk-like languages. I've made peace with Java, but if I have a choice I'll be in something Lisp-like or logic programming. Racket, Elixir, Scryer, that sort of thing.
- anthk 2y agoIndeed, yes. You can create a text adventure with very little logic in place, by setting the winning flag when very few conditions match. Everything else it's predefined with objects with attributes. But, OFC, some small logic it's done to add realism to the game. Such as a TV showing messages upon entering a room, and so on. But compared to any other language, Inform6 makes that almost like editing a config file.
- bitwize 2y ago90s Java didn't do that because Java doesn't support multiple class inheritance. 90s C++, however, did. Funny you should cite a game example. I once read about how the developers of StarCraft[0] ran into the same Goddamn inheritance problems I did when trying to build a custom game engine and a game with that engine. Adding behaviors via inheritance seemed like a good idea at the time (mid-late 90s), especially given all the propaganda we read from our C++ compiler manuals and such. But it turned into a situation where you either accepted multiple inheritance with all of its complexity and suck, including "which of the multiple base classes that implement 'foo' do I want when I call derived::foo()?" -- or resorting to delegates or other methods of composing behavior. Me, for gaming, I became an ECS convert and haven't looked back. There are some pain points when writing a game in ECS style... but the advantages pay for the relatively minor pain many times over. [0] https://www.codeofhonor.com/blog/tough-times-on-the-road-to-starcraft https://www.codeofhonor.com/blog/tough-times-on-the-road-to-... CFlingy is a particle spawner. Why does that have to be in the inheritance chain, instead of a trait you add to an object?
- hprotagonist 2y agothe canonical blog post series:https://ericlippert.com/2015/04/27/wizards-and-warriors-part-one/ https://ericlippert.com/2015/04/27/wizards-and-warriors-part...
- lll-o-lll 2y agoWhy “canonical”? From what I can see, Entity-Component-System (ECS), long pre-date this blog series by Eric, and he doesn’t even reference the term. I did enjoy the read however! My own programming has evolved towards data oriented design over the years.
- fargle 2y agowow! that is a great reference. i've only found it summited a few times and only with comments here: https://news.ycombinator.com/item?id=10567360 https://news.ycombinator.com/item?id=10567360. not a lot of comments and i suspect somewhat missing the point because this submission started with part 5, which intentionally is only part of the series exposing the pros/cons, limitations, etc. of various approaches.