An Introduction to D and Visual D

| by Jonathan Allen Follow 386 Followers on May 24, 2011. Estimated reading time: 2 minutes |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

D is a systems programming language from Digital Mars that focuses on “combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python.” While still being a statically typed language that compiles directly to native code, the syntax looks very much like Java or C# but it has some interesting advances.

Once such advance is explicit support for lazy arguments. When a parameter is tagged with the keyword “lazy” it indicates that the associated argument will be evaluated 0 or more times. This differs from languages such as Haskell which lazily evaluate arguments 0 or 1 times, but never more.

To assist in program correctness, especially in the realm of concurrency and multithreading, D supports both “immutable” and “const” as first-class concepts. Unlike C++, the immutable and const modifiers in D are transitive. If a variable is tagged with immutable, neither it nor anything you can access via it can be modified. The const keyword works the same way, though a given object may still be modified via a non-const reference.

D also combines many of the popular features from other languages. For example it has for-each loops, switches on strings, array slicing, closures, try-catch-finally blocks, and the separation between value types and reference types. At the same time it allows for direct memory access, 80-bit floats, struct member alignment control, and inline assembly.

Usually switching to native code comes with a high price in terms of safety. While C and C++ are the most well-known, most native languages are susceptible to coding errors such as buffer overflows. D prevents these by a combination of compile time and runtime array boundary checking. Likewise the contents of non-zero length arrays are auto-initialized to their default values.

In terms of memory management D is very much like .NET. By default reference types are stored in a garbage-collected heap and value types are stored either on the stack or inside other objects. D can also stack-allocate reference types so long as a pointer to them doesn’t escape. And like .NET you can also take pointers to unmanaged memory. Keeping these separate is important, as many of the operations that you can perform on an unmanaged pointer simply aren’t safe on a managed one.

For developers with access to a non-Express Visual Studio, there is a project called Visual D that offers Visual Studio plugins. Lloyd has an article showing how to setup your environment with Visual D.

There are currently four implementations of the D programming language. Digital Mars offers free compilers for Windows, Linux, OS X, and FreeBSD. There is also the Gnu D compiler, built on gcc. LLVM has a beta of their D compiler available, and finally there is the partial implementation for .NET.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

D by vic c

Love D! Best lang.

But with Visual Studio? A joke.

Love D! Best Language by Luís Carlos Moreira da Costa

use it for some years in my country it seems that only I have the interest ...

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you