First impressions of programming in D


For the past three years, it's been a bit of a tradition here at No Time To Play to review programming languages. Too bad my last two forays didn't work out so well, driving me back to more popular options. Lately however I've been in an experimental mood again. After circling for a while, I decided to finally give D a try. Conveniently, the official website at now has a Linux archive I could install without fuss.

D is one of those that set out to fix C++, only without throwing the baby out with the bathwater like Java did. For the longest time, I was dismissive of the idea, especially as D has failed to get much traction in the 17 years since it was created. Guess it's not easy to be noticed from the crowd when your competitors are standing on piles of corporate money. In retrospect, D has something better, or rather someone: Andrei Alexandrescu, a leading computer scientist of the 21st century, who also contributed much to C++. And the latter turned out very well indeed.

Unlike more fashionable alternatives, D is also very pragmatic: there's no fancy new syntax, and no attempt to reinvent error handling, objects or threads. It also doesn't provide easy cross-compilation (bummer), or any killer library nobody else has. Web app frameworks are a dime a dozen these days. So why bother?

That's a good question actually. C++ borrowed many features from D back in 2011, and is even more vendor-independent; also a lot more portable. Most other languages come with a built-in garbage collector (though few allow you to disable it entirely if you need to). And frankly, most of the time I need the expressiveness of a dynamic language much more than the performance of a compiled one.

When I do need the performance, however, D is a lot easier to understand and remember than C++. The syntax and semantics for, say, associative arrays just make sense. Iterators are a lot simpler. And the rules for modules are a breath of fresh air.

Otherwise, it's a modern programming language with built-in support for unit tests and documentation (handled by the compiler, no less), an official build tool and package manager, support for common file formats in the standard library, the works. Speaking of the standard library, it ships as source code in the package; how's that for openness!

As of this writing, I'm yet to complete a working piece of software in D, or for that matter run any benchmarks on the executables it produces. In any event, they seem average in size; stripping them saves less space than I'm used to seeing.

Last but not least, how best to make use of it is an open question. A few released games were supposedly written in D, so I guess this at least makes it on topic here. And hey, sometimes the usefulness of a new tool in the toolbox doesn't become apparent until later. So give it a chance.