4 ms·
Without a garbage collector? A garbage collector is a gift, not a restriction. A garbage collector is a fallback for when other mechanisms fail, and a helpful t
by crazypython 6y ago
Without a garbage collector? A garbage collector is a gift, not a restriction. A garbage collector is a fallback for when other mechanisms fail, and a helpful tool for prototyping.
A garbage collector is a function that frees memory through tracing. It doesn't stop you from freeing memory another way. D's GC isn't a Java or JavaScript or Go GC, it doesn't have overhead-inducing write barriers.
- fluffything 6y agoIf my software could afford a garbage collector, I would write it in Python or a JVM language, not in D. My software that can afford a garbage collector typically doesn't need a high level of safety either. If it fails, I restarted, and if it gets compromised, so be it. > D's GC isn't a Java or JavaScript or Go GC, it doesn't have overhead-inducing write barriers. I wouldn't use D for any application. If my application requires high-performance and/or correctness, I'd use Rust or C++. D buys you memory safety with a garbage collector, but it doesn't buy you thread safety, so from the safety POV, it is not enough. It also isn't free. If you disable it, you can't use most libraries. And if you enable it, you pay for a big runtime. Also the performance that D does buy you comes with the cost of being a language at the same level of complexity of C++. Rust gets you much better safety than D, no run-time by default and all libraries support this, better meta-programming than D, etc. all at a lower complexity cost than D. Sure D is better at prototyping than Rust, but Python and many other languages are much better at prototyping than D. If I need to write a prototype, I'll use python. And if I need to make my prototype fast, I'll just write that part in Rust and call it from python. Gives me the best of both worlds. Picking D would mean picking something that's not bad but not great at anything either.