4 ms·
> how do you think D compares with Zig? Disclaimer, I've never used Zig, so the following are not comparative. > Is it able to produce as efficient and small
by nicwilson 4y ago
> how do you think D compares with Zig?
Disclaimer, I've never used Zig, so the following are not comparative.
> Is it able to produce as efficient and small binaries,
There are compiler flags to disable linking to the D standard library and D runtime if you need small binaries (you can still use templates that end up in you binary) though most of the time that is more of a loss than gain (in terms of productivity), its not bloated unless you abuse templates a lot as would happen in C++.
As for speed of execution, don't use DMD if you care about the it. LDC (the LLVM D Compiler) and GDC (which is part of the GCC) are both strong optimisers.
cross-compile to most platforms,
Yes, use LDC. GDC, like GCC, is not a cross compiler by default though you can build it to be, DMD is X86(64) only.
> metaprogramming etc?
Oh, yes. Compile time function evaluation (referred to usually as CTFE) in combination with mixins (interpret string as code), `static foreach`, `static if` and (much safer than C++) templates makes for a very potent package.
- cyber_kinetist 4y agoIf I want to use D as a scripting language, I would like to have access to at least the core parts of the standard library (strings, lists, hashmaps, etc.), which I can’t without GC. I really don’t have time and energy to implement my own data structures when trying to prototyping gameplay code.
- bachmeier 4y ago> If I want to use D as a scripting language, I would like to have access to at least the core parts of the standard library (strings, lists, hashmaps, etc.), which I can’t without GC. How is it a "scripting language" if you don't want a GC? I use D for the vast majority of my scripting these days, but it would be odd for me to avoid the GC. I would not even think about using it if I had to deal with that.
- cyber_kinetist 4y agoI wasn’t talking about GC in general, but the GC in Dlang. With the GC turned off in D you can’t use most of the standard library. You can certainly use the std without relying on GC in languages like Rust, Swift, etc, but the important thing is that you can’t in D. I’m sure it can be technically done, but nobody has actually put the effort to do it.
- Shadonototra 4y agoThe plan is to finish https://dlang.org/phobos/std_experimental_allocator.html https://dlang.org/phobos/std_experimental_allocator.html Once finished, everything in the std will be able to make use of it If you can't wait, you can use this package already with the allocators: https://github.com/dlang-community/containers https://github.com/dlang-community/containers
- cyber_kinetist 4y agoOk, I’ll try it out after the feature stabilizes.
- WalterBright 4y agoAll the scripting languages I know of rely totally on the GC.
- mhh__ 4y agoHow much ram does your script use? Note that many game engines do use garbage collection for this purpose