D programming language



         


programming languages called D during the history of computing. The one discussed in this article is that created by Walter Bright.

This language takes some features of C, C++ and a few other Algol syntax based programming languages, and drops other features.

D drops older C++ features like the preprocessor and forward declarations. It adds modern features like design by contract, unit testing, true modules, automatic memory management (garbage collection), first class arrays, closures, and a reengineered template syntax. D retains C++'s ability to do low level coding, and adds to it with support for an integrated inline assembler. C++ multiple inheritance is replaced by single inheritance with interfaces. D's declaration, statement and expression syntax closely matches C++.

The inline assembler is typical of the differentiation between D and application languages like Java and C#. An inline assembler allows a programmer to enter machine-specific assembly code alongside standard D code—a technique often used by systems programmers to access the low-level features of the microprocessor needed to run programs that interface directly with the underlying hardware, such as operating systems and device drivers.

Unlike Java, but like C++, D allows the programmer to overload operators. Like Java, D uses garbage collection, but it also allows the programmer to request that specific objects must be finalized immediately when they go out of scope.

D also includes an interface to C's standard library: routines and libraries written in C can be easily called from D, although there is no interface with C++. There are so many features to support version and platform checking while compiling programs, tasks that are often accomplished in an ad-hoc manner with C's pre-processor.

D is intended to be compiled directly into native code, and takes performance issues seriously. When implementing an application in D you usually get slightly increased memory allocation, and slightly decreased execution time, compared to the same application implemented in C++.

D is under heavy development: new features and fixes are appearing every month. Some of these changes could possibly break D programs written for older versions of the language and compiler. The official compiler by Walter Bright defines the language itself, and it is in continuous beta testing state.

[Top]

Example

// D program to print 'hello world' followed by its command line arguments import std.stdio; int main(char[][] args) { writefln("hello world"); foreach (int i, char[] arg; args) writefln("args[", i, "] = '", arg, "'"); return 0; }
[Top]




  View Live Article   This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License