• D is a high level programming language for applications and systems programming.
• D is a compiled language like C/C++, no byte code like in Java, no interpreter like in Perl.
• D is targeted to iron out several design flaws of C/C++. You can think of D as an upgraded
D is a general purpose systems and applications programming language. It is a higher level language than C++, but retains the ability to write high performance code and interface directly with the operating system API's and with hardware. D is well suited to writing medium to large scale million line programs with teams of developers. D is easy to learn, provides many capabilities to aid the programmer, and is well suited to aggressive compiler optimization Technology’s is not a scripting language, nor an interpreted language. It doesn't
come with a VM, a religion, or an overriding philosophy. It's a practical language for practical programmers who need to get the job done quickly, reliably, and leave behind maintainable, easy to understand code.
D is the culmination of decades of experience implementing compilers for many diverse languages, and attempting to construct large projects using those languages. D draws inspiration from those other languages (most especially C++) and tempers it with experience and real world practicality.
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.
• Programming managers who are forced to rely on programming style guidelines to avoid common C bugs.
• Those who decide the promise of C++ object oriented programming is not fulfilled due to the complexity of it.
• Programmers who enjoy the expressive power of C++ but are frustrated by the need to expend much effort explicitly managing memory and finding pointer bugs.
• Projects that need built-in testing and verification.
• Teams who write apps with a million lines of code in it.
• Programmers who think the language should provide enough features to obviate the continual necessity to manipulate pointers directly.
• Numerical programmers. D has many features to directly support features needed by numeric’s programmers, like direct support for the complex data type and defined behavior for NaN's and infinities. (These are added in the new C99 standard, but not in C++.)
• D's lexical analyzer and parser are totally independent of each other and of the semantic analyzer. This means it is easy to write simple tools to manipulate D source perfectly without having to build a full compiler. It also means that source code can be transmitted in tokenized form for specialized applications.
Who D is not for?
• Realistically, nobody is going to convert million line C or C++ programs into D, and since D does not compile unmodified C/C++ source code, D is not for legacy apps. (However, D supports legacy C API's very well.)
• Very small programs - a scripting or interpreted language like Python, DMDScript, or Perl is likely more suitable.
• As a first programming language - Basic or Java is more suitable for beginners. D makes an excellent second language for intermediate to advanced programmers. The D Programming Language
• Language purists. D is a practical language, and each feature of it is evaluated in that light, rather than by an ideal. For example, D has constructs and semantics that virtually eliminate the need for pointers for ordinary tasks. But pointers are still there, because sometimes the rules need to be broken. Similarly, casts are still there for those times when the typing system needs to be overridden.
D is being designed with lessons learned from practical C++ usage rather than from a theoretical perspective. Even though it uses many C/C++ concepts it also discards some, and as such is not compatible with C/C++ source code. It adds to the functionality of C++ by also implementing design by contract, unit testing, true modules, garbage collection, first class arrays, associative arrays, dynamic arrays, array slicing, nested functions, inner classes, closures, anonymous functions, compile time function execution, lazy evaluation and has 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 Java style single inheritance with interfaces and mixings. D's declaration, statement and expression syntax closely matches that of C++.
The inline assembler typifies the differences between D and application languages like Java and C#. An inline assembler lets programmers enter machine-specific assembly code within standard D code—a technique often used by system programmers to access the low-level features of the processor needed to run programs that interface directly with the underlying hardware, such as operating systems and device drivers.
D has built-in support for documentation comments, allowing automatic documentation generation.
D supports three main programming paradigms—imperative, object-oriented, and metaprogramming.
D 2.0 adds two programming paradigms - functional, concurrent (Actor model)
Imperative programming in D is almost identical to C. Functions, data, statements, declarations and expressions work just as in C, and the C runtime library can be accessed directly. Some notable differences between D and C in the area of imperative programming include D's
foreachloop construct, which allows looping over a collection, and nested functions, which are functions that are declared inside of another and may access the enclosing function's local variables.
Object oriented programming in D is based on a single inheritance hierarchy, with all classes derived from class Object. D does not support multiple inheritance; instead, it uses Java-style interfaces, which are comparable to C++ pure abstract classes, and mixins, which allow separating common functionality out of the inheritance hierarchy. Additionally, D 2.0 allows declaring static and final (non-virtual) methods in interfaces.
Metaprogramming is supported by a combination of templates, compile time function execution, tuples, and string mixins. Templates in D can be written in a more function-like style than those in C++.
Memory is usually managed with garbage collection, but specific objects can be finalized immediately when they go out of scope. Explicit memory management is possible using the overloaded operators
delete, and by simply calling C's malloc and free directly. Garbage collection can be controlled: programmers can add and exclude memory ranges from being observed by the collector, can disable and enable the collector and force a generational or a full collection cycle. The manual gives many examples of how to implement different highly optimized memory management schemes for when garbage collection is inadequate in a program.
Interaction with other systems
C's application binary interface (ABI) is supported as well as all of C's fundamental and derived types, enabling direct access to existing C code and libraries. C's standard library is part of standard D. Without very explicit namespaces it can be somewhat messy to access, as it is spread throughout the D modules that use it—but the pure D standard library is usually sufficient unless interfacing with C code.
C++'s ABI is not fully supported, although D can access C++ code that is written to the C ABI. The D parser understands an extern (C++) calling convention for limited linking to C++ objects, but it is only implemented in D 2.0.
On Microsoft Windows, D can access COM (Component Object Model) code.
The D programming language exists in two versions: 1.0 and 2.0. D 1.0 became stable with the release of D 2.0, on June 17, 2007, and further additions to the language have since been added to 2.0. The release of Andrei Alexandrescu's book The D Programming Language on June 12, 2010 marked the stabilization of D 2.0.
Version 1.00 of the Digital Mars D compiler was released on Jan 2, 2007. Since the release of D 2.0, D 1.0 and its DigitalMars implementation only received bugfixes and insignificant features which did not affect backwards compatibility.
D 2.0 introduced multiple new features, some of which broke compatibility with D 1.0 code. Some of these features are:
- Support for enforcing const-correctness:
- D differentiates between mutable references to immutable data,
constreferences to mutable data, and combinations thereof
immutablekeywords are transitive.
- Limited support for linking with code written in C++.
- Iteration with
foreachover defined range only.
- Support for "real" closures. Previously closures couldn't be safely returned from functions, because stack-allocated variables would become inaccessible.
- Support for pure functions which can only access immutable data and call other pure functions. This ensures a pure function has no side effects (the same stack inputs always result in the same outputs and outputs exist only through return values). Together with real closure support this allows Functional Programming in D and also opens theoretical paths for safe automatic threading.
- "safe" subset (SafeD), which can't directly access memory not belonging to process (only limited set of casts and pointer arithmetic is possible in such code).
- Vector operations, i.e.
a = b + c(element-wise summation of two dynamic/static arrays), or
a *= 3(multiply by 3 each element of array).
- Classic global storage defaults to Thread Local Storage.
- Changes to standard Phobos library, including metaprogramming and functional programming additions.
Most current D implementations compile directly into machine code for efficient execution.
The Digital Mars D compiler is the official D compiler by Walter Bright. The compiler front-end is licensed under both the Artistic License and the GNU GPL; the source code for the front-end is distributed along with the compiler binaries. The compiler back-end source code is available but not under an open source license.
A front-end for the GCC back-end, built using the open DMD compiler source code. Development snapshots also support D version 2.0.
A compiler based on the DMD front-end that uses LLVM as its compiler back-end. The first release quality version was published on January 9, 2009.
D Compiler for .NET
A back-end for the D 2.0 Programming Language Compiler. It compiles the code to CIL bytecode rather than to machine code. The CIL can then be run via a CLR virtual machine.
Editors and IDEs supporting D include Eclipse, Microsoft Visual Studio, SlickEdit, emacs, vim, SciTE, Smultron, TextMate, Zeus, and Geany among others.
- There are two Eclipse plug-ins for D, Descent and DDT.
- Visual Studio integration is provided by VisualD.
- Vim supports both syntax highlighting and code completion (through patched ctags).
- A bundle is available for TextMate, and the Code::Blocks IDE includes partial support for the language. However, standard IDE features such as code completion or refactoring are not yet available, though they do work partially in Code::Blocks (due to D's similarity to C).
- A plugin for XCode is available, D for Xcode, that enables D-based projects and development.
Additionally, there are open source D IDEs (some written in the D language itself), such as Poseidon, D-IDE, and Entice Designer. There is also a commercial IDE available, BITPROX Development Environment.
D applications can be debugged using any C/C++ debugger, like GDB or WinDbg, although support for various D-specific language features is extremely limited. On Windows, D programs can be debugged using Ddbg, or Microsoft debugging tools (WinDBG and Visual Studio), after having converted the debug information using cv2pdb. The commercial ZeroBUGS debugger for Linux has experimental support for the D language. Ddbg can be used with various IDEs or from the command line; ZeroBUGS has its own GUI.
PROBLEMS AND CONTROVERSIES:
Division concerning the standard library
The standard library in D is called Phobos. Some members of the D community had thought that Phobos was too simplistic and that it had numerous quirks and other issues, and a replacement of the library called Tango was written. However, in the D 1.0 branch, Tango and Phobos are incompatible due to different runtime support APIs (the garbage collector, threading support, etc). The existence of two libraries, both widely in use, has led to significant problems where some packages use Phobos and others use Tango.
This problem is being addressed in the D 2.0 branch by creating a stand-alone runtime called druntime, and porting both Phobos and Tango to druntime. As of October, 2008, Phobos has been ported to druntime in the newest alpha version of the Digital Mars compiler. Tango is in the process of being ported to D 2.0, and is expected to eventually run on top of druntime. For the foreseeable future, D will have two competing runtime libraries, but in the D 2.0 branch, they will be compatible and usable side-by-side in the same codebase.
Unfinished support for shared/dynamic libraries
UNIX’s ELF shared libraries are supported to an extent using the GDC compiler.
On Windows systems, DLLs are supported and allow D's garbage collector-allocated objects to be safely passed to C functions, since the garbage collector scans the stack for pointers. However, there are still limitations with DLLs in D including the fact that run-time type information of classes defined in the DLL is incompatible with those defined in the executable, and that any object created from within the DLL must be finalized before the DLL is unloaded.
The language has three distinct character types (
dchar) and three string aliases (
dstring, which are simply dynamic arrays of the former) which represent UTF-8, UTF-16 and UTF-32 code units and strings respectively. For performance reasons, string slicing and the
lengthproperty operate on code units rather than code points (characters), which frequently confuses developers. Since UTF-8 and UTF-16 are variable-length character encodings, access by code point index in constant time is not possible without maintaining additional lookup tables. Code that needs fast random access to code points should convert strings to UTF-32 first, or use lookup tables. However, this is also true for other programming languages supporting Unicode, like Java and C# that use UTF-16, thus may need surrogate pairs to represent some code points.