3 ms·
You can avoid using the GC by using malloc/free. You can also use -betterC and D will only need to be linked with the C standard library. > you will lose acces
by WalterBright 7y ago
You can avoid using the GC by using malloc/free. You can also use -betterC and D will only need to be linked with the C standard library.
> you will lose access to a lot of the standard library
This is incorrect. Not much of it needs the GC anymore.
- zerr 7y agoSince D has scope guards - any plans to add deterministic destructors? i.e. RAII a la C++.
- destructionator 7y agoThey've been there... I think since the beginning. If not since the beginning for at last ten years now.
- mhh__ 7y agoAlready there. P.S. click the link to see the spec...
- qznc 7y agoStruct destructors are always deterministic: https://dlang.org/spec/struct.html#struct-destructor https://dlang.org/spec/struct.html#struct-destructor Class destructors can be declared deterministic with the "scope" keyword: https://dlang.org/spec/attribute.html#scope https://dlang.org/spec/attribute.html#scope Scope guards are useful if you cannot change the data type itself.
- wyldfire 7y agoIt's my estimation that this misperception of D (that it requires GC) will take a while to unlearn/relearn.
- pjmlp 7y agoNot only of D, plenty of GC enabled languages (including .NET based ones) provide such capabilities, but for some reason many learn wrongly that having a GC means 100% heap usage with GC only allocations.
- p0nce 7y agoI think most of it comes down to not knowing how a GC works internally.
- pjmlp 7y agoI think it is a mixture. Your remark, additionally being taught programming on languages that indeed use the GC heap allocations for everything, and on those that allow fine grained control over resources it is usually left for "exercise to the reader", so many don't care and so aren't aware of what they are losing.