Live data from Hacker News

Introduction to Data-Oriented Design [pdf]

gamedevs.org

51–60 of 83 posts

Re: Introduction to Data-Oriented Design [pdf]

#51
post #17

Earlier quoted context omitted.

My experience with ECS is that you shouldn't use an "ECS system". You should just do ECS. Have an array of all your particles and then update all the positions according to the velocities. Don't use a framework where you do something like get_all_entities_with (). Just have struct particles {vector positions, velocities;}. Well, managing those parallel arrays gets pretty annoying, but you solve that with a parallel-a…

But why? This looks like the mother of all boilerplates. And for what purpose? Also: just having stuff in an array or vector invites you to the ABA problem. You need a generation counter in there too, or else the array indice may get reused if something is deleted and another thing is reinserted at the same index. But that's yet another boilerplate that would easily be overlooked if you had to do everything manually.…

> You need a generation counter in there too, or else the array indice may get reused if something is deleted and another thing is reinserted at the same index.

It's really sounding like you're pretending not to know what your program does, which is one of the core OOP ideas that DOD refutes. In OOP you have an array of Shape and you pretend not to know which shapes your program implements, so the only way to draw them is to call ->draw() on each one. And you pretend you don't know anything about the lifetime of a shape so you use smart pointers everywhere to extend it as long as needed. In DOD you assert that you do know what shapes are available and what their lifetimes are.

Re: Introduction to Data-Oriented Design [pdf]

#52
post #28

Earlier quoted context omitted.

Often you don't have runtime composition and don't need it. By prematurely generalizing you're venturing close to OOP territory.

“Prematurely generalizing” is now an OOP thing? Are we just using OOP as a term for anything bad now? Ooh here is a controversial one. DOD is premature optimization. Most programs don’t have enough data where the storage and access is a factor for performance. In fact it might be slower to use DOD.

I don't think that's all that controversial. DOD comes out of the field of video games where people were frustrated by only being able to process ten thousand things sixty times per second and wanted to process ten million things sixty times per second. While it's also been used to speed up things like the Zig compiler, it's definitely not necessary for all software.

One of the ideas in OOP that DOD is explicitly refuting is pretending not to know what your program does. You know which subtypes exist in your program and you shouldn't treat them generically as supertype instances except when that is actually optimal. On this axis, both ECS ideology and OOP ideology are opposite to DOD ideology. ECS happens to align with DOD in that it prefers big linear arrays, but it does not align in pretending not to know what combinations of arrays are used, which is similar to pretending not to know what subtypes of Shape exist.

Re: Introduction to Data-Oriented Design [pdf]

#53
post #17

Earlier quoted context omitted.

My experience with ECS is that you shouldn't use an "ECS system". You should just do ECS. Have an array of all your particles and then update all the positions according to the velocities. Don't use a framework where you do something like get_all_entities_with (). Just have struct particles {vector positions, velocities;}. Well, managing those parallel arrays gets pretty annoying, but you solve that with a parallel-a…

But why? This looks like the mother of all boilerplates. And for what purpose? Also: just having stuff in an array or vector invites you to the ABA problem. You need a generation counter in there too, or else the array indice may get reused if something is deleted and another thing is reinserted at the same index. But that's yet another boilerplate that would easily be overlooked if you had to do everything manually.…

> This looks like the mother of all boilerplates. And for what purpose?

Isn't most programming? Isn't struct Particle {vec3 position, velocity;} also the mother of all boilerplates?

Re: Introduction to Data-Oriented Design [pdf]

#54
post #28

Earlier quoted context omitted.

Often you don't have runtime composition and don't need it. By prematurely generalizing you're venturing close to OOP territory.

“Prematurely generalizing” is now an OOP thing? Are we just using OOP as a term for anything bad now? Ooh here is a controversial one. DOD is premature optimization. Most programs don’t have enough data where the storage and access is a factor for performance. In fact it might be slower to use DOD.

> Are we just using OOP as a term for anything bad now?

Different paradigms come with different pathological cases. I've had to deal with Scala programmers whose notion of FP is making everything generic on the Monad it abstracts over, even when it'll only ever be instantiated on the one effect system the team uses. Nonsensical levels of generality is one of the classic OOP pathologies, and is the reason why we have aberrations like the AbstractSingletonProxyFactoryBean[0].

0. https://docs.spring.io/spring-framework/docs/current/javadoc...

Re: Introduction to Data-Oriented Design [pdf]

#56
post #51

Earlier quoted context omitted.

But why? This looks like the mother of all boilerplates. And for what purpose? Also: just having stuff in an array or vector invites you to the ABA problem. You need a generation counter in there too, or else the array indice may get reused if something is deleted and another thing is reinserted at the same index. But that's yet another boilerplate that would easily be overlooked if you had to do everything manually.…

> You need a generation counter in there too, or else the array indice may get reused if something is deleted and another thing is reinserted at the same index. It's really sounding like you're pretending not to know what your program does, which is one of the core OOP ideas that DOD refutes. In OOP you have an array of Shape and you pretend not to know which shapes your program implements, so the only way to draw th…

I certainly don't know "what my program does" if it's a game where, at every frame of the simulation, thousands of entities might or might not be created, deleted and recycled depending on player inputs.

Can you describe a superior replacement for generation counters?

Re: Introduction to Data-Oriented Design [pdf]

#57
post #52

Earlier quoted context omitted.

“Prematurely generalizing” is now an OOP thing? Are we just using OOP as a term for anything bad now? Ooh here is a controversial one. DOD is premature optimization. Most programs don’t have enough data where the storage and access is a factor for performance. In fact it might be slower to use DOD.

I don't think that's all that controversial. DOD comes out of the field of video games where people were frustrated by only being able to process ten thousand things sixty times per second and wanted to process ten million things sixty times per second. While it's also been used to speed up things like the Zig compiler, it's definitely not necessary for all software. One of the ideas in OOP that DOD is explicitly ref…

No amount of ideology can fill L1 cache.

Re: Introduction to Data-Oriented Design [pdf]

#58
post #54

Earlier quoted context omitted.

“Prematurely generalizing” is now an OOP thing? Are we just using OOP as a term for anything bad now? Ooh here is a controversial one. DOD is premature optimization. Most programs don’t have enough data where the storage and access is a factor for performance. In fact it might be slower to use DOD.

> Are we just using OOP as a term for anything bad now? Different paradigms come with different pathological cases. I've had to deal with Scala programmers whose notion of FP is making everything generic on the Monad it abstracts over, even when it'll only ever be instantiated on the one effect system the team uses. Nonsensical levels of generality is one of the classic OOP pathologies, and is the reason why we have…

>"Nonsensical levels of generality is one of the classic OOP pathologies"

I think it has nothing to do with OOP which I find very convenient for some domains and not so much or even opposite for others. These "Nonsensical levels" of anything is a disease which is called Architecture Astronauts Syndrome and victims apply it to any paradigm

Re: Introduction to Data-Oriented Design [pdf]

#60
post #19

I personally love the idea of DoD but from my experience it rarely works well in practice since one of the key assumptions of understanding ur problem is often not given as new requirements pop up and change all the time. At work we are rewriting and reengineering system from scratch and its crazy because the limitations of the old system are now gone we get the most insane feature requests that are even accepted by…

DoD may be a good idea for a business context where one of your main priorities is getting the most efficient use out of memory bandwidth & cache. E.g. if your job is writing game engines or middleware used by AAA games with fancy graphics to run on consumer hardware, getting the most efficient use out of the players' limited memory bandwidth may be very important. For many (most?) arbitrary commercial software proje…

I have business oriented C++ backend where I use mostly OOP but also use DoD in few critical places that do a lot of calculations over big chunks of data. It is simpler than for games since I only need high average performance, not real time 60 or whatever FPS with no jitter.
Post reply on HN