New D language pumps up programmer productivity

140

Author: Nikolai Sivertsen

Is it possible to have the performance of C and C++ and the programmer productivity of modern programming languages such as Ruby and Python in a single language? That is the question Walter Bright, the author of the Zortech C++ compiler and the Digital Mars C/C++ compiler, asked himself when creating a successor to C++: Digital Mars D, a practical programming language first released exactly one year ago that helps you get the job done quickly.

Why create a new programming language? Because C++ is complicated and expensive to implement. Most C++ programmers get accustomed to using certain feature sets and never touch any others, because it is too hard to remember them all. This is not a problem for the compiler, but for other programmers trying to read the code it can be, because they might be used to other feature sets. D avoids this problem, because it was hugely simplified without removing important features. But that is not the only benefit D has.

One goal of D is to reduce software development costs by at least 10% by adding productivity-enhancing features and adjusting the language to eliminate time-consuming bugs. D supports imperative, structured, object-oriented, and generic programming paradigms. It should be relatively easy for C and C++ programmers to learn D, because it is very similar to C/C++. D is compatible with the local C application binary interface, which means that you can call C functions such as printf in D, but D is not compatible with C or C++ source code. D retains C++’s ability to do low-level coding, which is necessary for writing device drivers and operating systems. D has adopted a large number of helpful features from Java and C#, such as a garbage collector (although manual memory management is still possible).

A few months ago, when I began thinking about learning D, I thought it would take me a long time to learn, but I was wrong. Before learning D I did a little bit of Java programming, and found D to be similar. However, one problem about learning D today is a lack of good tutorials for people who have never programmed in C or C++.

There are two compilers for D: DMD and GDC. The former is the official compiler, and is 100% true to the standard of the D language and has a proprietary back end that converts the code to assembly code. The latter, GDC, uses the free front end of D and the back end of the GNU Compiler Collection (GCC). It is, unlike DMD, not yet 100% true to the standard, because the GDC developers have to catch up every time DMD gets new features. GDC runs on Linux, Mac OS X, Cygwin, FreeBSD, AIX, and MinGW. To make it compatible with other operating systems, the developers have to modify D’s garbage collector to support those systems. This is not a lot of work and only has to be done once for each system, but so far it has been done only for the abovementioned operating systems.

On DSource, which is similar to SourceForge.net but only for D programs, you can already find several open source D projects, ranging from system libraries to GUI libraries to server programs and normal applications. For anyone wanting to help out with an open source D project, this is the place to look. The site also has a few tutorials and a forum for every D project on the site, where you can ask for help and talk to project leaders.

Several integrated development environments (IDE) support D, including Anjuta, Codeblocks, and Eclipse. You can find D plugins for text editors and IDEs on either DSource or Prowiki.

My favourite editor/IDE for D is leds, a “light editor for D.” Leds is written in D, and its source code can be found on DSource. It features syntax highlighting, a syntax error checker, and build support from inside leds. I have not been able to build the latest version from source, because I always get core dumps and other errors, so I use the precompiled version, which sadly is quite old and does not have all the new features.

If you plan to write GUI programs in D, I advise you to use GtkD, a D language binding for GTK+. It works with Glade, a visual GUI designer for GTK+, which is a big bonus for me, as it makes GUI creation much easier and faster than writing the code by hand. Other GUI libraries, such as a port of the Java/Eclipse library SWT, a binding for wxWidgets, and some more, are available on DSource.

On the down side, due to the fact that D has been around for such a short time, there is a lack of tutorials and support.

Overall, D is a great new language. I hope it will become what it was intended to be — a successor of C++. For anyone thinking about learning a new programming language, I would seriously recommend D, although it is advisable for people with no prior programming experience to start learning programming with another, easier language, such as Delphi or Java.

Category:

  • Programming