4 ms·
D's standard lib is also a lot more mature than Zig's, obviously because of its age. I'd recommend D above Zig unless you want to contribute bug fixes to Zig.
by speps 4y ago
D's standard lib is also a lot more mature than Zig's, obviously because of its age. I'd recommend D above Zig unless you want to contribute bug fixes to Zig.
- cyber_kinetist 4y agoBut isn’t most of the D standard library unusable with BetterC mode (without GC)?
- Shadonototra 4y agoBetterC is not no GC mode, BetterC was made to make sharing D code easier with C GC only exist if you call ``new MyThing`` Just use your allocators with malloc/free, that is what i do (you do the same in zig, allocators) if you want to enforce no GC use in your APIs, there is the @nogc attribute you can use
- OskarS 4y ago> Just use your allocators with malloc/free, that is what i do (you do the same in zig, allocators) If you do that, is it RAII like C++/Rust? Objects get destructed at end of scope, and members get destructed recursively? Or do you have to manually call `free()` on everything? (which, granted, is significantly easier in languages with `defer` mechanisms)
- nicwilson 4y agoRAII, though there is also `scope(exit)`
- WalterBright 4y agoYes, it is RAII and RAII is fully implemented in D.
- alphaglosined 4y agoBut only for structs. We really need to get actual reference counting into the language to cover classes properly as well. It has been on my todo list to write a DIP for this for a while now. ~rikki.
- ntrel 4y agoClass instances can go on the stack too using `scope`: scope obj = new Object; ... // destroyed at end of scope
- Shadonototra 4y agoD has defer scope(exit): scope(failure): scope(success): https://tour.dlang.org/tour/en/gems/scope-guards https://tour.dlang.org/tour/en/gems/scope-guards You can do RAII with D too, it's your choice, based on your use case
- mhh__ 4y agoBetterC is a hack designed to make it easier to migrate C code to D. It turns off everything that requires a runtime not just the GC