A large company can push a programming language into the proverbial limelight: just look at C#, Java, and Objective-C and Swift. But a few programming languages can punch above their weight without any help from prominent companies or developers.
While some of these languages achieved early success only to fall by the wayside (e.g., Delphi), one language that has quietly gained popularity is D, which now ranks 35 in the most recent Tiobe Index.
Inspired by C++, D is a general-purpose systems and applications language that’s similar to C and C++ in its syntax; it supports procedural, object-oriented, metaprogramming, concurrent and functional programming. D’s syntax is simpler and more readable than C++, mainly because D creator Walter Bright developed several C and C++ compilers and is familiar with the subtleties of both languages. D started development in 1999 and reached Release 1.0 in January 2007, with a newer version of D (D2) appearing in the same year. This is now the official version of D, with the original D now known as D1 and in maintenance.
In some respects D is old school, like C++. It compiles directly to machine code, then gets linked to an exe and runs directly (no virtual machines here). It’s handy for quick-and-dirty programming as well as for large projects. But the similarity with C++ only goes so far: D has modules instead of namespaces, a garbage collector, simpler templates, immutable types and data structures, Lambda functions, and closures (to name but a few). Some other points:
- The garbage collector means that explicit destructors aren’t needed, which simplifies memory management enormously. Destructors are available and can be used on structs, particularly for resource management. The downside of garbage collection is that care is needed with memory allocation to minimize the time spent collecting; read the Wiki for tips on memory management.
- Modules let you group functions, types, etc. in one file, which speeds up compilation—it’s much faster at compiling than C++. Classes in the same module have access to each other, rather than the explicitly declared friend functions in C++. A bunch of module source code files in the same directory form a package with the directory name used as the package name. When the compiler finds an import name, it looks in the directory for the module file.
- There’s a D package registry that currently lists over 400 third-party packages. If you’re looking for D database drivers and the like, this is the place to start. It’s busy as well, with over 20 updates in the first half of January.
D offers compilers for all three platforms (Windows, Mac and Linux) as well as FreeBSD. Take things down another level, though, and things get a bit complicated: In addition to the official DMD (Digital Mars D) compiler, there’s also GDC, which is front-end for the GCC back-end, as well as LDC, which is a DMD front-end plus an LLVM back-end. All of these compilers are free, although not all are open source.
There’s no official IDE as such, but on Windows there’s the Visual Studio plugin Visual-D, written in D, which includes project management, syntax highlighting and code coverage support. On Linux or Mac there’s DDT, an Eclipse-based IDE.
Direct Access to C APIs
In addition to having data types that correspond to C’s types, D provides direct access to C’s APIs, making it a straightforward task to use open-source code such as SDL, OpenAL, Bullet Physics engine and many more.
I like the D language: It’s well thought out and avoids many of the complexities you encounter with modern C++ programming. There are a lot of clever additions such as invariant blocks in functions, type properties, labels on loops and much more.
On the downside, I searched for D programming jobs and found just a couple. The name doesn’t help, as “D” matches too many terms in a typical search. (Perhaps they should call it dlang, similar to how Google began using “Golang” for Go, especially as the D website is dlang.org.)
If you are looking for a solid cross-platform development system, you could do a lot worse than D. It has great potential for game development and I expect it to continue to grow in popularity.
- Scripting Languages You May Not Know
- Is There a Future in Programming D?
- Is C Still Relevant in the 21st Century?