Hacker News new | ask | show | jobs
by tchow 3487 days ago
He mentioned a lie of:

Code should be designed around a model of the world

but I didn't hear any reason why not to? The Key/Value pair being the only reason, but besides that being a optimization / preoptimization in high performance applications, is there any reason to not design code around a model of the world?

Seems to me it makes things easier to think about.

5 comments

I am trying to make a game that follows Mike Acton ideas.

Basically: When you try too hard to fit the real world into code, you end with OOP.

It has one great advantage: it is easy to translate real world into "computer".

but one great big distvantage: a computer is a computer, not real world, OOP translates to complexity (think "Architecture Astronauts", and spaghetti of pointers/references/virtual/inheritance) and things done in a way that harms performance (not a problem for smaller problems, but if your problem is not small...)

His idea is that you should instead fit the world into your DATA, not your code, think about what data your program needs from the real world (do you really need all tiny details for example?), what is your inputs and outputs, and THEN you code to make that work, you code around your data structures, file formats, etc... not the other way around.

Apologies, haven't watched the video, but there are some pitfalls when designing around a 'model of the world', especially in OO.

I think Wizards and Warriors by Eric Lippert is a perfect illustration of how our initial assumptions and models aren't often the right ones (although it's not so much about data in this case) https://ericlippert.com/2015/04/27/wizards-and-warriors-part...

Just read through those 5 posts - absolutely fantastic, thanks for the link.
I can't (won't) watch YouTube at work, but don't two of the lies contradict? If code is not more important than data, doesn't it make sense to model the code around that data? Or am I conflating data in lie #3 with "the world" in lie #2?
Well, you could argue that Acton instead argues that the data should be designed around a model of the world, and the code around that data. Although I concede that sounds like a nitpick.
If i'm not misunderstanding you.. (as i didn't watch most of the videos there)

See data-oriented programming (not to be confused with data-driven). In the end code just processes data.