I agree. Perhaps also known as "data-oriented design". Decompose entities into components by modelling the data in a normalised way, as is done when modelling for relational databases. Group together similar data as records in homogeneous arrays, and batch process it without need for OOP polymorphic branching etc.
Further reading/viewing, somewhat gamedev oriented (as is the author of this articl
Andrew Kelley(ziglang 负责人)曾在 Twitter 上推荐过《Data-Oriented Design》(想想:Mechanical Sympathy)[0]。我读了前几章,觉得相当不错 [1]。
另外,《JavaScript: The Good Parts》仍然是我读过的最好的编程书之一(急需出新版)。
[0] https://archive.is/199Eo
[1] 书:http://www.dataorienteddesign.com/dodbook/dodmain.html /
Andrew Kelley (ziglang lead) recommended Data-Oriented Design (think: Mechanical Sympathy) on twitter once [0]. I read the first few chapters and found it to be pretty neat [1].
Besides, JavaScript: The Good Parts remains one of the best programming books I've read (direly in need of a new edition).
[0] https://archive.is/199Eo
[1] book: http://www.dataorienteddesign.com/dodbook/dodmain.html /
This may be a useful example for a different approach: http://www.dataorienteddesign.com/dodbook/
Particularly the chapter "Relational Databases" which compares to programming with sets in databases. This book doesn't tell you to program as if you worked with SQL, but draws inspiration from it and makes a comparison.
See also: Richard Fabian's "Data-Oriented Design" book. The fourth chapter is about component-based objects, and the preceding chapters about relational databases and existential processing are relevant.
http://www.dataorienteddesign.com/dodbook/
Prior HN discussion: https://news.ycombinator.com/item?id=20380397
>However, there are certain situations where I cannot imagine working without OOP. (...) Similarly, a computer game, having an EnemyDemon inherit from Enemy, so that it has .kill(), .damage(), and properties for health, speed etc.?
You'd be surprised. This is much cleaner, and more efficient too:
https://medium.com/ingeniouslysimple/entities-components-and...
more in depth:
https://www.dataorie
This has been a recognized problem for game devs for a while and recently Unity introduced DOTS to gain performance. From what I understand, doing traditional OOP means going through a lot of pointers to find information. If you put everything into arrays instead, you reduce the time spent looking up things.
https://unity.com/dots
IIRC, this is the textbook that unity pulls from if you want to l
我同意。也许也被称为「面向数据的设计」。像为关系数据库建模那样,以规范化的方式对数据建模,将实体分解为组件。把相似的数据作为记录分组到同构数组中,批量处理,无需 OOP 多态分支等。 进一步阅读/观看,有点偏游戏开发(这篇文章的作者也是……
I agree. Perhaps also known as "data-oriented design". Decompose entities into components by modelling the data in a normalised way, as is done when modelling for relational databases. Group together similar data as records in homogeneous arrays, and batch process it without need for OOP polymorphic branching etc. Further reading/viewing, somewhat gamedev oriented (as is the author of this articl
Andrew Kelley(ziglang 负责人)曾在 Twitter 上推荐过《Data-Oriented Design》(想想:Mechanical Sympathy)[0]。我读了前几章,觉得相当不错 [1]。 另外,《JavaScript: The Good Parts》仍然是我读过的最好的编程书之一(急需出新版)。 [0] https://archive.is/199Eo [1] 书:http://www.dataorienteddesign.com/dodbook/dodmain.html /
Andrew Kelley (ziglang lead) recommended Data-Oriented Design (think: Mechanical Sympathy) on twitter once [0]. I read the first few chapters and found it to be pretty neat [1]. Besides, JavaScript: The Good Parts remains one of the best programming books I've read (direly in need of a new edition). [0] https://archive.is/199Eo [1] book: http://www.dataorienteddesign.com/dodbook/dodmain.html /
这可能是一个有用的例子,展示了一种不同的方法:http://www.dataorienteddesign.com/dodbook/ 特别是“关系数据库”那一章,它对比了数据库中的集合式编程。这本书并没有让你像使用 SQL 那样编程,而是从中汲取灵感并进行了比较。
This may be a useful example for a different approach: http://www.dataorienteddesign.com/dodbook/ Particularly the chapter "Relational Databases" which compares to programming with sets in databases. This book doesn't tell you to program as if you worked with SQL, but draws inspiration from it and makes a comparison.
另见:Richard Fabian 的《Data-Oriented Design》一书。第四章是关于基于组件的对象,而前面关于关系数据库和存在处理的章节也相关。 http://www.dataorienteddesign.com/dodbook/ 之前的 HN 讨论:https://news.ycombinator.com/item?id=20380397
See also: Richard Fabian's "Data-Oriented Design" book. The fourth chapter is about component-based objects, and the preceding chapters about relational databases and existential processing are relevant. http://www.dataorienteddesign.com/dodbook/ Prior HN discussion: https://news.ycombinator.com/item?id=20380397
>然而,在某些情况下,我无法想象没有 OOP 该如何工作。(...) 同样,一个电脑游戏,让 EnemyDemon 继承自 Enemy,这样它就有 .kill()、.damage(),以及生命值、速度等属性? 你会感到惊讶的。这种方式更清晰,也更高效: https://medium.com/ingeniouslysimple/entities-components-and... 更深入的: https://www.dataorie
>However, there are certain situations where I cannot imagine working without OOP. (...) Similarly, a computer game, having an EnemyDemon inherit from Enemy, so that it has .kill(), .damage(), and properties for health, speed etc.? You'd be surprised. This is much cleaner, and more efficient too: https://medium.com/ingeniouslysimple/entities-components-and... more in depth: https://www.dataorie
这对游戏开发者来说是一个早已被认识到的问题,最近 Unity 引入了 DOTS 来提升性能。据我所知,传统的 OOP 意味着要通过大量指针来查找信息。如果你把所有东西都放进数组里,就能减少查找所花的时间。 https://unity.com/dots 如果我没记错的话,如果你想了解……这就是 Unity 借鉴的那本教科书。
This has been a recognized problem for game devs for a while and recently Unity introduced DOTS to gain performance. From what I understand, doing traditional OOP means going through a lot of pointers to find information. If you put everything into arrays instead, you reduce the time spent looking up things. https://unity.com/dots IIRC, this is the textbook that unity pulls from if you want to l