4 ms·
What does it bring over modern C++? Why would you want to use it?
by joelthelion 9y ago
What does it bring over modern C++? Why would you want to use it?
- ComputerGuru 9y agoI don't view it's counterpart to be C++ these days; dlang is a GC'd language, so it's actually probably fairer to compare it to Go instead.
- pjmlp 9y agoOberon, Modula-3 and System C# among many others would beg to differ.
- mhh__ 9y agoIt is a clear alternative to C++. The GC is optional.
- mehrdadn 9y agoIs it? Last time I checked a few years ago there were huge caveats to allocation Objects on the stack (I forget what they were) so unless something's drastically changed this doesn't seem like an honest assessment.
- destructionator 9y agoThe pitfalls aren't really any different than C++... either use some kind of smart pointer, or use caution not to escape references to stack memory (very easy mistake to make in D) or slice up the object by value (very difficult to do in D) and you'll be fine. The built-in `scope` syntax is deprecated (though making a comeback recently as more stuff gets implemented around it), but you can also do a library type fairly easily, just slightly heavier in syntax (you need to prepare the memory and construct the object in two separate lines) or prep work (write a struct which does both).
- mhh__ 9y agoIf you want to allocate an object on the stack, then use std.conv : emplace and alloca. This(https://wiki.dlang.org/Memory_Management#Allocating_Class_Instances_On_The_Stack https://wiki.dlang.org/Memory_Management#Allocating_Class_In...) method also exists but is on the road to deprecation
- VHRanger 9y ago- Nearly instant compile times - GC by default, manual memory management where and when you need it with no loss of efficiency - Better metaprogramming - Does not compromise on things a C++ coder would care about (speed, efficiency, deterministic behavior, etc.) The language is led by Andrei Alecsandrescu and Walter Bright, two C++ core language veterans
- mhh__ 9y agoModules (Alone would be enough imo)
- p0nce 9y agohttp://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17 http://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17?