← Back to context

Comment by pron

10 hours ago

But arenas have substantial benefits. They may be one of the few remaining reasons to use a low-level (or "systems programming") language in the first place. Most things are tradeoffs, and the question isn't what you're giving up, but whether you're getting the most for what you're paying.

Arenas are also available in languages with automatic memory management, e.g. D, C# and Swift, to use only modern languages as example.

Thus I don't consider that a reason good enough for using Zig, while throwing away the safety from modern languages.

  • First, Zig is more modern than any of the languages you mention. Second, I'm not aware that any of those languages offer arenas similar in their power and utility to Zig's while offering UAF-freedom at the same time. Note that "type-safe" arenas are neither as powerful as general purpose arenas nor fully offer UAF-freedom. I could be wrong (and if I am, I'd really love to see an arena that's both general and safe), but I believe that in all these languages you must compromise on either safety or the power of the arena (or both).

    • Not really modern, it is Object Pascal/Modula-2 repackaged in C like syntax.

      The only thing relatively modern would be compile time execution, if we forget about how long some languages have had reader macros, or similar capabilities like D's compile time metaprogramming.

      Also it is the wrong direction when the whole industry is moving into integrity by default on cyber security legislation.

      There are several examples around of doing arenas in said languages.

      https://dlang.org/phobos/std_experimental_allocator.html

      You can write your own approach with the low level primitives from Swift, or ping back into the trusty NSAutoreleasePool.

      One example for C#, https://github.com/Enichan/Arenas

      1 reply →

  • Wouldn't C# and Swift make it tough to integrate with other languages? Whereas something written in Zig (or Rust) can integrate with anything that can use the C ABI?