Hacker News new | past | comments | ask | show | jobs | submit login

The SoA transformation makes sense to me and is quite general. The EoA transformation on the other hand feels like a rare special case though it seems perhaps less rare for the OP.

Either way, these types of optimizations are typically marginal in the context of end to end performance of most programs. It's good to have some knowledge of these kinds of techniques, but most of the time it makes sense to do the thing that is most straightforward to implement and optimize later once the program is already working. Of course if the problem maps neatly onto EoA then that should be preferred in the initial implementation. I though in my 30+ years of programming cannot think of a particular problem that I have solved that would have been enhanced by this.




It's an alternative to OOP. You can get there via a series of transformations:

1. Start with OOP (heap-allocated objects with shared base structs)

2. Transform to using tagged unions instead

3. Transform to the approach outlined in the OP (I call it the "encoding" approach in this talk: https://vimeo.com/649009599)

It's handy because you get to use an index to refer to an object, and you get serialization benefits. The zig compiler uses this pattern in quite a few places:

* https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5...

* https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5...

* https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5...

* https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5...


I'll tell you my experience with Zig. I don't have any. I saw maybe Primagen talking about it and I see your post here. I watched 10 minutes of your vimeo video. I see it has 30k+ stars on github. So now I have to try to understand it in a nutshell.

First like any language, I go to indeed.com and put in "Zig" to see if there are any jobs listed which use it. I don't see any.

Then I click to https://ziglang.org/ and it describes Zig as "robust, optimal and reusable". Well that doesn't really say much of anything.

I read the example listed, which appears to be a test case, and I wonder how the 'try' mechanism works without a 'catch'

Then I go to https://ziglang.org/documentation/master/ and see that it says: Robust Behavior is correct even for edge cases such as out of memory.

I wonder how that works, but there are no links to support this claim.

I read a little more then move on.

This isn't to say anything one way or another about Zig, its just my 30 minutes of reading about Zig.


I spent 2 seconds clicking on your bio and saw this account was created 4 hours ago.

Makes me wonder why you felt the need to create a burner account.

This isn't to say anything one way or another about you, its just my 2 second of reading about you.


> First like any language, I go to indeed.com and put in "Zig" to see if there are any jobs listed which use it. I don't see any.

What does that have to do with anything? Zig is still in beta and they explicitly do not recommend that you use it in production yet unless you're ok with frequent breaking changes. Of course there will be very few jobs (though it's being used by a few notable projects already, including Tigerbeetle - authors of the post we're discussing - and Bun, the JS runtime).


I’d like to unsubscribe from your blog


I disagree. My blog is quite robust and optimal


What a random and untimely user report.


> I though in my 30+ years of programming cannot think of a particular problem that I have solved that would have been enhanced by this.

One example that I frequently deal with that can benefit from this is compiler data structures.


Isn't performance and memory usage generally enhanced by this?

So why not simply default to this instead of defaulting to Interfaces/traits doing dynamic polymorphism?

Makes everyone a bit more happy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: