It is indeed a beautiful language, what makes the GC such a no-no? Hard to work with in embedded systems?
Opposition to GC is mostly people being fooled by GC-ed languages tending to be higher level and thus generating more garbage.
> Embedded systems
In the embedded work I've done I barely allocate at all, so it matters not GC or otherwise.
Swift doesn't have garbage collection.
Re:Crafting Self-Evident Code with D
by RcouF1uZ4gsC on Tuesday October 03, 2023 @02:07PM
(#37755463)
Refcounting is a form of garbage collection. While C++ and Rust also have refcounting, it is the default memory management mode in Swift in a way that it is not in C++ and Rust (where the defaults are more using stack based or unique_ptr/Box before reaching for refcounting).
No, it's not. Refcounting CAN be a garbage collection algorithm, but in Swift it's deterministic and done at compile time. Not to mention recently added support for non-copyable types that enforces unique ownership: https://github.com/apple/swift-evolution/blob/main/proposals...
Re:Crafting Self-Evident Code with D
by WalterBright on Tuesday October 03, 2023 @02:40PM
(#37755856)
> you lose access to most of the standard library
That's simply not true. Only one of the algorithms in std.algorithm, for example, uses the GC.
The GC also enables much better compile time function execution.
It's worth noting many (A majority as I understand) AAA game studios end up writing their own STL. I'm willing to bet many industries where performance is the primary concern also write much of their core libraries from scratch.
D lets user opt-out of collector as needed which is quite nice. D has been used in AAA game development for what it's worth as well.
A lot of games have GCs...
Absolutely! Any game in C#, Java, or even C++ Unreal Engine games.
However, its embrace in the 1990's of garbage collection has proved its Achilles heel. Before anyone says you can write D without the garbage collection, yes you can but then you lose access to most of the standard library, and likely most third party libraries. Rust and C++ allow you not to have to use garbage collection but still use the standard library and 3rd party libraries.
With garbage collection, D is not directly competing not with C++ but with Java, Swift, Go, C# which have far more support across the industry.