News for hackers. Stuff that matters.
Re:Why is Zig so Cool? by scuff3d on Saturday November 08, 2025 @01:55PM (#45858985)
If they want to keep to the error/diagnostic pattern I think they're gonna have to adopt some kind of standard context object that gets passed around. Passing an allocator, an IO implementation, and a diagnostic object all over your code base is going to get really fucking old.
Re:Why is Zig so Cool? by throwawaymaths on Saturday November 08, 2025 @06:36PM (#45861201)
if it helps: it's pretty typical to attach the allocator to the object directly, so you dont have to pass it everywhere. for library consumers, just build a global allocator and use that. io will just "have to be passed the annoying way" in libraries (but a consumer can also also easily globalize that).
Re:Why is Zig so Cool? by scuff3d on Saturday November 08, 2025 @07:30PM (#45861670)
I'm assuming you're talking about the "managed" pattern you'd see in stuff like Hashmaps and ArrayLists. To my knowledge that style is falling out of favor, and I think the managed versions will be removed from the standard library.

I haven't seen anyone use a global allocator in the way you're talking about, and if you did I feel like it goes directly against the Zig ethos. Part of the benefit of allocators being passed around is that all allocation are explicit.

Re:Why is Zig so Cool? by throwawaymaths on Sunday November 09, 2025 @01:12AM (#45863358)
If you're a library writer, then don't make a global allocator. If you aren't, then do whatever you feel like.