On 2 January 2007, after years of waiting, the first stable version of a revolutionary programming language called D appeared. It has been designed as the real successor of C. Its designer, Walther Bright, which is the author of the first native C++ compiler, created an epic language that I enjoyed since the first time I found it. In this post, I would like to see, where the language is after three years of existence.
What is D?
As I mentioned, Walter Bright created the first native C++ compiler, and currently works in Digital Mars. Years ago he arrived at a conclusion that C++ is one big mess that should never be created and decided to create something better, a real successor of C, which itself comes from B. The name for the new language was obvious then: D. He aimed to create a modern, well-designed language without all the C++ drawbacks, workarounds etc. such as extremely complicated grammar, worthless standard library or C rubbish. He threw away all the achievements of Bjarne Stroustrup and started from scratch by breaking the source code compatiblity with C, the main reason why C++ is so messy, in favour of simple, context-free grammar, very easy to parse. The other feature are:
- No patological multiple inheritance in favour of interfaces and mixins.
- Built-in garbage collector.
- Contract programming support.
- Built-in support for unit testing.
- Built-in language documentation system.
- Built-in collections, such as associative array or vector.
- Closures, anonymous functions.
- Real modules.
- Lazy evaluation.
- Nested functions and classes.
- Completely redesigned template system.
- Concurrent programming support.
- New data types that match the current needs and hardware design, such as complex numbers.
- Binary-level compatibility with C.
Programmers got a language so powerful, as C++, and so easy, as Java, with all the advantages of the compilation to the machine code. What is more, this was not the last word of Walter Bright. Soon, the works on D 2.0 started. The new version extends the list of features with the new toys:
- Support for fully safe closures.
- Real functional programming support thanks to the appearance of pure functions.
- Vector operations, such as
c = a + b
- Iteration over a slice of a collection.
- Partial binary compatibility with C++.
D after three years
After three years, using D in bigger projects still encounters enormous problems. The biggest one, which is a paradox itself, is the lack of... good, multiplatform compiler. Digital Mars releases a model compiler called dmd, and the front-end source code is available under the artistic license, but that's it. And to be honest - the quality and features of the default compiler do not impress. It is available only for 32-bit versions of Windows, Linux, MacOS and FreeBSD, but still this is the biggest variety of platforms.
In January of this year, I decided to get back to D after a while and solve a problem for concurrent programming at University. I got stucked almost immediately: damn, I have a 64-bit Linux so how the hell am I going to compile it? GCC port was abandoned in 2007, and reactivated not so long ago in so primitive way that I did not want to deal with it. I was saved by LLVM compiler which aims to be the successor of GCC platform. Here, we can use much more advanced port called LDC which is the only available that can generate a native 64-bit binary for Linux. Unfortunately, this port still cannot be used for real software, because Linux is actually the only well-supported platform, and officially it is still in the beta phase. More exotic platforms suffer from the lack of maintainers, and there are open issues that are several months old.
Another problem is the standard library, because... there are two of them: official Phobos and community-made Tango created, because the community claimed that Phobos is too primitive. The Tango project really impresses - the goals can be compared with the achievements of Boost for C++, but again the organization is not the strongest part of this project. It had a break in the development, too, so the programmers had to use trunk version, and the authors woke up not so long ago that it would be nice to release some new version (0.99.9). Another problem is the compatibility. Basically, in your project you cannot mix pieces of code that use both Tango and Phobos, because they use different garbage collectors and some other basic subsystems. It is going to be fixed in D 2.0 which will introduce a common platform for them. Phobos is the official standard library of dmd, whereas Tango - in LDC.
As we can see, even the most brilliant project can fail because of the lack of good tools. Digital Mars is so focused on the language itself that it hasn't got enough strenght or simply does not want to continue and develop an official, well-designed programming environment, with good compiler, IDE, debuggers and other tools. The language is a brilliant starting point for the successful business, because there are many programmers and companies that look for something better than dominating C++ for the tasks, where for some reasons Java cannot be used. Instead, we have a vicious circle: the "best" tools are still in beta phase and developed in the open-source model which has little changes for donations and bigger programmer interest, because the lack of good tools that would bring them to the project. A typical company will not invest in something like this, because it won't simply have enough resources to deal with all the issues. Let's take a look at the case study: an open-source clone of Morrowind game, which had to be rewritten from D to C++ due to the lack of good tools, and the problem it was creating.
However, is there still any chance for D? The history shows that yes. There were some languages that gained a high popularity long after they appeared for the first time (i.e. Ruby). If there is any mad person that will sacrifice his or her life for the world, everything is possible. Walter Bright announces that D 2.0 will have an official 64-bit compiler, so the first step will be made. Of course, a popular, multiplatform project written in D would also help the language, being a force to speed up the development of other compilers and tools.
Some marketing would help D, too. I think that there are many people that would enjoy it, if only they had a chance to hear about it. I know it from my studies. On my fourth semester, I had a subject called operating systems. I was presenting one of my home works, and I started a small discussion with the doctor about sockets. He said that they are a very nice tool and recommended me to read more about them. I replied that I had been actually playing with them for a while, writing a small FTP server in D. The doctor was surprised and said he had never heard of such a language, so I made a small demonstration (on the other hand, my colleagues were frightened to the death, what the hell he does to me for more than 50 minutes ). I also managed to finish in D the homework from the concurrent programming mentioned above. Although I didn't hear any questions when I was referring it, but from the doctor's face I could read that he also heard about this language for the first time.
Small update: on 7 September 2010, GNU Debugger became the first debugger with D language support.
I think that without PHP and Open Power Template, I would probably help developing D. Inspite of all these problems, I consequently refuse to use C++ right now in favour of C and D, when it is possible. Meanwhile, I added LDC and Tango to my stack on Ohloh - this is the best I can do for now. I hope that one day D will become a really usable language.