4 ms·
Rust and Zig brought new ideas for memory management that Haskell, OCaml, Erlang sidestep having garbage control. its honestly amazing to me that they managed t
by cultofmetatron 5mo ago
Rust and Zig brought new ideas for memory management that Haskell, OCaml, Erlang sidestep having garbage control. its honestly amazing to me that they managed to get the adoption they have while being so innovative. I say this as a fulltime elixir dev.
- ShalokShalom 5mo agoYou would be surprised to see, how OCaml and the BEAM specifically think about memory.
- unclad5968 5mo agoWhat new ideas did Zig bring to memory management?
- lenkite 5mo agoPluggable allocators. Allocators are passed to functions as arguments, the caller decides exactly how memory is managed. Maybe not "new" in idea, but "new" in being consistently applied everywhere in language & libraries.
- pjmlp 5mo agoAlready Turbo Pascal for MS-DOS had a custom allocator API for its runtime. All modern C++ collection types have allocators as type parameters, and this was already a thing in the compiler frameworks like OWL during the 90's.
- lenkite 5mo agoZig makes allocation an explicit runtime concern: var list = std.ArrayList(i32).init(allocator); where allocator is a runtime value implementing the allocator interface. fn parseJson(allocator: Allocator, input: []const u8) !JsonValue Zig forces the caller to decide since allocator is part of the function contract. And this is consistent everywhere in Zig. Effectively speaking, this is universal, explicit & mandated dependency injection for memory management as opposed to to classic C++ STL allocators. Sorry sir, I have a nostalgic fondness for C++ - it was my first language, but it just doesn't compare for flexible allocation convenience compared to Zig.
- pjmlp 5mo agoFact remains it wasn't the first, and it remains to be seen how market relevant Zig will ever turn out be, especially after AI driven coding became mainstream. The irony to argue about manual memory management ergonomic, when code is written by agents.
- pjmlp 5mo agoZig is Modula-2, Ada 83 with a curly brackets, what new ideas?