4 ms·
One thing I like about Odin is that you can use any allocator with any existing function, without wiring that function to specifically do that. It just comes fo
by verdagon 4y ago
One thing I like about Odin is that you can use any allocator with any existing function, without wiring that function to specifically do that. It just comes for free. In a way, it completely decouples the code from the allocator choice. It's especially nice because we can use any allocator with any third party code.
I think this kind of decoupling is a big step in the right direction. The more concerns we can decouple from each other, the simpler and more flexible our codebases become and the less time we have to spend infectiously refactoring.
- tialaramex 4y ago> It just comes for free To be fair, specifically the price is a hidden context passed to every function. Hiding it means the programmer needn't expend effort thinking about it as they would if you did this by hand, but in performance terms this isn't really free.
- astrange 4y agoThis can be implemented many different ways without losing a register (/ other parameter storage). It’s called dynamic scoping or thread local variables.
- _0w8t 4y agoThread-local variables are implemented using a reserved register. Essentially thread-locals in C++ are the hidden context.
- astrange 4y agoThat doesn't "lose" a register because the program already wasn't using it.
- LegionMammal978 4y agoTo be fair, they're implemented with one of the segment registers, at least on x86-64. So there isn't much else that programs could have used it for, since it takes a syscall just to set the value.
- cyber_kinetist 4y agoI remember first seeing this idea from Jai (https://youtu.be/ciGQCP6HgqI https://youtu.be/ciGQCP6HgqI), and I'm happy it's landing in other languages. Zig went another direction and requires you to specify the allocator explicitly via a function parameter, which is understandable given the language's goal to make everything explicit.
- Tozen 4y agoOdin pulls a lot from and is influenced by Jai. Regardless of how people can feel about that, Odin is open to the public, to be used and tested by anyone.