Learning D Part 1: IDE and Libraries

by Malte Skarupke

I am learning the D programming language.

I’m a C++ programmer, and like most C++ programmers I am rather annoyed with C++. It can be a pretty bad language. The problem is only that all other languages are even worse for the stuff that you’d want to use C++ for.

But D seems promising. Reading through the features of the language, you notice that it has many smart solutions for things which are cumbersome or error-prone in C++. I’ll go into benefits and problems of features one by one as I am using them. But the D overview page says under “Who D is for:”

  • Programmers who routinely use lint or similar code analysis tools to eliminate bugs before the code is even compiled.
  • People who compile with maximum warning levels turned on and who instruct the compiler to treat warnings as errors.

Which sounds like me, or at least sounds like the programmer I wish I was.

But to start, you just want a simple “Hello, World” on the screen. And that already is kinda complicated in D.

The code looks simple:

import std.stdio;

void main()
  writeln("Hello World!");

The problem is running this. D is a language that had a lot of excitement behind it a couple years ago, which is now much diminished. So just finding a compiler and IDE proves difficult. I wanted to use the LLVM D compiler, but that one is broken in the current version of Ubuntu (12.04). So I use DMD instead.
Next I want an IDE. You will find many dead or dying IDE’s. Many of them haven’t been updated in years or only support the old D version 1. After trying many different programs I ended up with Code::Blocks. It doesn’t work out of the box, but at least it has support for debugging, which others don’t.
I got myself the newest “nightly” build and created a D project. By default you can’t build, because the compiler is set up incorrectly. Yay. You have to go into the advanced options and explain to Code::Blocks how to use the current version of dmd.

But after that, I finally had a “Hello, World!” on the screen.

The next thing for me was to try to create an OpenGL context. I again had the problem of finding many dead or dying libraries, until I eventually came across Derelict, which gives easy access to the SDL and OpenGL.

With all of that, I can finally start building a real application. So I copy+paste some code from the Internet, and I have a yellow square on the screen.

This has taken much longer than it should have, mainly because the D community seems to be in a slow decline. Next time I will actually program something useful. Then I’ll see why so few people seem to stick with D. Hopefully the problem is just that the community is too small to grow properly, and not something with the language itself.