programming-languagesd

Is worth the effort to learn D?


Imagine you have 3 projects:

You have 3 choices:

Then, you ask to more wises programmers: Could D give me a significant advantages in this task, in the areas of: modularity, bug fixing, team work, and machine efficiency?


Solution

  • As I see it, D has the following advantages over more "traditional" statically typed languages:

    1. Insanely powerful compile time metaprogramming facilities. For example, check out std.algorithm or std.range in the D2 standard library. A std.parallelism module is likely to be included soon, and if/when it is, it will be another good example. These facilities are powerful enough that the language sometimes feels almost duck-typed, but with the performance of a statically typed language. Also see the SO question about D metaprogramming: Examples of what D’s templates can be used for

    2. The default D2 concurrency model is based on message passing. If you don't subvert the type system in obvious, greppable ways, there can be no implicit sharing of data between threads in D2. Of course, if you really want unchecked data sharing, you can break this with a cast. For example, the std.parallelism module that's currently in review does this to get pedal-to-the-metal multicore parallelism.

    3. D tends to make simple things a lot simpler than C++ or Java. (I'm not as sure about C#.) By simple things, I mean things like basic file I/O or the strategy pattern don't require nearly as much boilerplate. In fact, I feel like one of D's primary design goals was to banish boilerplate code from the face of the Earth, as avoiding the need for it is heavily emphasized in the design of both the language and the standard library.

    Relative to dynamic languages, D has:

    1. The performance of a natively compiled language while giving up much less convenience than you would expect, mostly because of the awesome metaprogramming facilities and their use in the design of the standard library.

    2. Static checking. Your program won't one day crash because you mistyped a variable name or tried to assign a string to an integer.

    3. The ability to do low-level work. For example, except for a few small pieces of inline assembler, D's garbage collector is written entirely in D.