Recs.
Updated
SpecsUpdate
Pros
Pro Provides a powerful data structure on top of C's arrays called slices
D provides a structure that builds on C's arrays called slices. A slice is a segment of an array that tracks the pointer and the length of the segment.
Slices are extremely powerful because they combine the protection of knowing the length of the data with the garbage collector that manages the memory backing that data, thus avoiding most memory corruption issues.
Pro Unit testing built-in
D provides unittest blocks to insert code that verifies functions preform their expected behavior and document edge cases. Since these are enabled with a compiler switch, there is no need to teach new programmers how to install new libraries and import modules, instead training on test driven design can start from the very first function.
Pro Offers rdmd for compiled scripting
Because of the very fast compilation, D can very convinietly be used for scripting, too. No need to switch to an other language for prototyping either.
Pro Easy and powerful module systems
Since source files have a one-to-one correspondence with modules, you don't have to #include
the text of a file of declarations, you only need to import the module.
This way, there's no need to worry about importing the same module several times and no need to wrap header files with #ifndef/#endif
.
Pro Automatic & manual memory Management
D uses a garbage collector to manage memory. This eliminates the error prone process of manually allocating memory in languages that don't have a garbage collector.
Despite this, the new
and delete
operations can be overridden for some classes to allow custom allocation.
Pro Provable purity and immutability
The compiler can check that functions don't have side effects, extremely important for functional programming in concurrent scenarios, and can check immutability.
Therefore, the compiler will prove that your programs are functionally pure and respect immutable data, if you want it to.
Pro Easy to integrate with C and C++
D practically has the same memory structure as C and C++; all D does it build a structure around that. The entire C standard library is accessible at no cost (syntactic or speed) and it's being worked on allowing the same for the C++ standard library.
Pro Great packaging and build system DUB
DUB simplifies compiling/building project of any complexity by specifying all project settings inside JSON build file, there you can list all source files and project folders, also list all necessary dependency packages and their versions. All public DUB packages are stored in DUB online registry (https://code.dlang.org/) and available for direct usage in your code.
Pro Has an improved C subset
With few exceptions, D will either compile C code to work exactly as when compiled as C, or it won't compile - it won't quietly change the semantics of C code and give unexpected results. This means that D contains an improved C, as it fails compilation where type safety is missing in C.
This allows learning the same machine operations available in C and other low-level languages.
Pro Doesn't force you to deal with memory management
When you're just starting out, dealing with manual memory management and its bugs is a huge pain! D is garbage collected by default, which removes a huge class of things that could go wrong. And later on, if you decide you don't want or need the GC, you can turn it off.
Pro Supports calling functions from types in an object-oriented manner.
if (exists(file)) {}
may be written as if (file.exists) {}.
writeln(file);
may be written as file.writeln();
isDivisibleBy(10, 2);
may be written as 10.isDivisibleBy(2);
writeln(isEven(add(5, 5)));
may be written as 5.add(5).isEven().writeln();
Pro Static with type inference
For a new user adding types can feel tedious, and takes focus off the meaning of the code, but they are also important for checking logic. D provides static types, and a good system to infer types, so types are checked when calling functions, but do not need to be specified everywhere, making it feel more dynamic.
Cons
Con All the downsides of garbage collection without any of its benefits
When D decided to implement garbage collection it instantly alienated a large community of developers (C and C++ programmers). For them, the official policy has been: "Don't want garbage collection? Use D with RAII or manual management style!".
While true, it's also absolutely pointless because there's little to none support for alternate memory management styles in the standard library, which means that a new user will have to start with a language that is stripped down of the core infrastructure.
On the other hand, for those people who want to use garbage collection, the implementation of it is lackluster.
However, with the latest versions of the D compilers, you can now directly use C++ standard library classes like std::vector and std::queue in your D code.
Con Poor adoption even after many years of existence
There's a widely accepted perception of D as a language that has been poorly adopted. Since adoption is driven by perception this becomes a fact. So managers and engineers start becoming nervous in adopting a language that has such a perception among the community and that has been so unsuccessful for so long.
Con Reference implementation is now open source
Part of the reference compiler DMD was made at Symantec, and is now open-source and available for everyone to use freely.
Con Garbage Collected
While optional, this uses a garbage collected runtime.
Recommendations
Comments
Flagged Pros + Cons
Pro Bultin package manager and build system DUB
Hundreds of very useful libraries you can install and link with one command. Npm/pip/gem for system language C++ developers wandered their whole life. You can see the libraries here.