News for hackers. Stuff that matters.
Re:Data-oriented design or why you might shoot yourself in t... by duped on Monday June 28, 2021 @11:41AM (#27663328)
I don't agree with this, and I'm personally an anti-OOP militant.

Inheritance isn't the root of all evil, dynamic dispatch is. It's a remarkably powerful implementation detail but one with enormous cost, regardless of whether you're using an AoT/JIT compiled or interpreted language.

Re:Data-oriented design or why you might shoot yourself in t... by bccdee on Monday June 28, 2021 @01:00PM (#27664403)
What enormous cost — slightly slower function calls? That's a pretty minor cost, and dynamic dispatch can be extremely useful sometimes.
Re:Data-oriented design or why you might shoot yourself in t... by duped on Monday June 28, 2021 @01:19PM (#27664630)
Enormously slower function calls and zero inlining without advanced dynamic compilation, which has a number of pitfalls.
Re:Data-oriented design or why you might shoot yourself in t... by kaba0 on Monday June 28, 2021 @05:37PM (#27668522)
As opposed to passing function pointers everywhere, callback hell and friends? Or which language does it well in your opinion? The fact is, dynamic dispatch is needed, because not everything can be known at compile time. And as in a recent thread a HNer rightly noted (could not find it where I read it), the actually expensive thing in programming is flexibility.
Re:Data-oriented design or why you might shoot yourself in t... by throwaway894345 on Monday June 28, 2021 @02:07PM (#27665345)
Devirtualization optimizations can turn semantically "dynamic" dispatches into static dispatches, but sometimes you really just need a dynamic dispatch. Note that a dynamic dispatch doesn't have to be anything more than a branch. Further, sometimes devirtualizing everything leads to enormous binaries and compile times. Runtime performance isn't everything, and it's typically better to opt-into devirtualization rather than to opt-out of it.
Re:Data-oriented design or why you might shoot yourself in t... by bccdee on Monday June 28, 2021 @03:59PM (#27667079)
You must have absurd standards if you find dynamic dispatch to be unacceptably slow. Also, yeah, not every function call needs to be inlined. One level of indirection on top of jumping into a new function isn't really much overhead at all, unless you're doing it for literally every function call.
Re:Data-oriented design or why you might shoot yourself in t... by AdieuToLogic on Monday June 28, 2021 @10:35PM (#27671071)
> Inheritance isn't the root of all evil, dynamic dispatch is. It's a remarkably powerful implementation detail but one with enormous cost ...

Dynamic dispatching typically costs one pointer lookup in a vtable[0]. By "typically", I specifically mean "in any production quality run-time environment." This is not an "enormous cost" by any reasonable definition.

0 - https://en.wikipedia.org/wiki/Virtual_method_table

Re:Data-oriented design or why you might shoot yourself in t... by throwaway894345 on Monday June 28, 2021 @02:03PM (#27665279)
Disagree. Go and Rust both have dynamic dispatch and neither have the problems that inheritance has. Even in C which lacks dynamic dispatch, people will either try to build it at the expense of type safety or they will try to manage an impossibly complex implicit state machine (I've seen this in a lot of critical real time systems).
Re:Data-oriented design or why you might shoot yourself in t... by kaba0 on Monday June 28, 2021 @05:39PM (#27668537)
I would wager that in most ordinary C programs it is worse. You can’t even reason about code anymore with all the callbacks.