News for hackers. Stuff that matters.
Re:Enum of Arrays by AndyKelley on Saturday December 21, 2024 @06:30PM (#42483190)
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...

Re:Enum of Arrays by midnightchair on Sunday December 22, 2024 @04:02AM (#42485223)
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.

Re:Enum of Arrays by brabel on Sunday December 22, 2024 @05:01AM (#42485432)
> 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).

Re:Enum of Arrays by keybored on Sunday December 22, 2024 @07:03AM (#42485859)
What a random and untimely user report.
Re:Enum of Arrays by matdehaast on Sunday December 22, 2024 @08:29AM (#42486169)
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.

Re:Enum of Arrays by marxisttemp on Sunday December 22, 2024 @08:54AM (#42486323)
I’d like to unsubscribe from your blog
Re:Enum of Arrays by midnightchair on Wednesday December 25, 2024 @05:12AM (#42508012)
I disagree. My blog is quite robust and optimal