Ddoc $(COMMUNITY $(D) vs Other Languages, $(BLOCKQUOTE To D, or not to D. -- Willeam NerdSpeare ) $(P This table is a quick and rough list of various features of $(D) that can be used to compare with other languages. While many capabilities are available with standard libraries, this table is for features built in to the core language itself. $(LINK2 builtin.html, Rationale). ) $(TR ) $(TR $(TD Garbage Collection) $(YES1 garbage.html) ) $(TR ) $(TR $(TD Function delegates) $(YES1 type.html#delegates) ) $(TR $(TD Function overloading) $(YES1 function.html#overload) ) $(TR $(TD Out function parameters) $(YES1 function.html#parameters) ) $(TR $(TD Nested functions) $(YES1 function.html#nested) ) $(TR $(TD Function literals) $(YES1 expression.html#FunctionLiteral) ) $(TR $(V1 $(TD Dynamic closures)) $(V2 $(TD Closures)) $(YES1 function.html#closures) ) $(TR $(TD Typesafe variadic arguments) $(YES1 function.html#variadic) ) $(TR $(TD Lazy function argument evaluation) $(YES1 lazy-evaluation.html) ) $(TR $(TD Compile time function evaluation) $(YES1 function.html#interpretation) ) $(TR ) $(TR $(TD Lightweight arrays) $(YES1 arrays.html) ) $(TR $(TD Resizeable arrays) $(YES1 arrays.html#resize) ) $(TR $(TD Built-in strings) $(YES1 arrays.html#strings) ) $(TR $(TD Array slicing) $(YES1 arrays.html#slicing) ) $(TR $(TD Array bounds checking) $(YES1 arrays.html#bounds) ) $(TR $(TD Array literals) $(YES1 expression.html#ArrayLiteral) ) $(TR $(TD Associative arrays) $(YES1 arrays.html#associative) ) $(TR $(TD Strong typedefs) $(YES1 declaration.html#typedef) ) $(TR $(TD String switches) $(YES1 statement.html#SwitchStatement) ) $(TR $(TD Aliases) $(YES1 declaration.html#alias) ) $(TR ) $(TR $(TD Object Oriented) $(YES) ) $(TR $(TD Multiple Inheritance) $(NO) ) $(TR $(TD Interfaces) $(YES1 interface.html) ) $(TR $(TD Operator overloading) $(YES1 operatoroverloading.html) ) $(TR $(TD Modules) $(YES1 module.html) ) $(TR $(TD Dynamic class loading) $(NO) ) $(TR $(TD Nested classes) $(YES1 class.html#nested) ) $(TR $(TD Inner (adaptor) classes) $(YES1 class.html#nested) ) $(TR $(TD Covariant return types) $(YES1 function.html) ) $(TR $(TD Properties) $(YES1 property.html#classproperties) ) $(TR ) $(TR $(TD Inline assembler) $(YES1 iasm.html) ) $(TR $(TD Direct access to hardware) $(YES) ) $(TR $(TD Lightweight objects) $(YES1 struct.html) ) $(TR $(TD Explicit memory allocation control) $(YES1 memory.html) ) $(TR $(TD Independent of VM) $(YES) ) $(TR $(TD Direct native code gen) $(YES) ) $(TR ) $(TR $(TD Class Templates) $(YES1 template.html) ) $(TR $(TD Function Templates) $(YES1 template.html) ) $(TR $(TD Implicit Function Template Instantiation) $(YES1 template.html) ) $(TR $(TD Partial and Explicit Specialization) $(YES1 template.html) ) $(TR $(TD Value Template Parameters) $(YES1 template.html) ) $(TR $(TD Template Template Parameters) $(YES1 template.html) ) $(TR $(TD Variadic Template Parameters) $(YES1 template.html) ) $(V2 $(TR $(TD Template Constraints) $(YES1 concepts.html) ) ) $(TR $(TD Mixins) $(YES1 template-mixin.html) ) $(TR $(TD static if) $(YES1 version.html#staticif) ) $(TR $(TD is expressions) $(YES1 expression.html#IsExpression) ) $(TR $(TD typeof) $(YES1 declaration.html#Typeof) ) $(TR $(TD foreach) $(YES1 statement.html#ForeachStatement) ) $(TR $(TD Implicit Type Inference) $(YES1 declaration.html#AutoDeclaration) ) $(TR ) $(TR $(TD Contract Programming) $(YES1 dbc.html) ) $(TR $(TD Unit testing) $(YES1 unittest.html#unittest) ) $(TR $(TD Static construction order) $(YES1 module.html#staticorder) ) $(TR $(TD Guaranteed initialization) $(YES1 statement.html#DeclarationStatement) ) $(TR $(TD RAII (automatic destructors)) $(YES1 memory.html#raii) ) $(TR $(TD Exception handling) $(YES1 statement.html#TryStatement) ) $(TR $(TD Scope guards) $(YES1 statement.html#ScopeGuardStatement) ) $(TR $(TD try-catch-finally blocks) $(YES1 statement.html#TryStatement) ) $(TR $(TD Thread synchronization primitives) $(YES1 statement.html#SynchronizedStatement) ) $(TR ) $(TR $(TD C-style syntax) $(YES) ) $(TR $(TD Enumerated types) $(YES1 enum.html) ) $(TR $(TD Support all C types) $(YES1 type.html) ) $(TR $(TD 80 bit floating point) $(YES1 type.html) ) $(TR $(TD Complex and Imaginary) $(YES1 type.html) ) $(TR $(TD Direct access to C) $(YES1 attribute.html#linkage) ) $(TR $(TD Use existing debuggers) $(YES) ) $(TR $(TD Struct member alignment control) $(YES1 attribute.html#align) ) $(TR $(TD Generates standard object files) $(YES) ) $(TR $(TD Macro text preprocessor) $(NO1 pretod.html) ) $(TR ) $(TR $(TD Conditional compilation) $(YES1 version.html) ) $(TR $(TD Unicode source text) $(YES1 lex.html) ) $(TR $(TD Documentation comments) $(YES1 ddoc.html) )
D Language Feature Comparison Table
Feature $(D)
Functions Arrays OOP Performance Generic Programming Reliability Compatibility Other
$(SECTION2 Notes,
Object Oriented
This means support for classes, member functions, inheritance, and virtual function dispatch.

Inline assembler
Many C and C++ compilers support an inline assembler, but this is not a standard part of the language, and implementations vary widely in syntax and quality.

Interfaces
Support in C++ for interfaces is weak enough that an IDL (Interface Description Language) was invented to compensate.

Modules
Many correctly argue that C++ doesn't really have modules. But C++ namespaces coupled with header files share many features with modules.

Garbage Collection
The Hans-Boehm garbage collector can be successfully used with C and C++, but it is not a standard part of the language.

Implicit Type Inference
This refers to the ability to pick up the type of a declaration from its initializer.

Contract Programming
The Digital Mars C++ compiler supports Contract Programming as an extension. Compare some C++ techniques for doing Contract Programming with D.

Resizeable arrays
Part of the standard library for C++ implements resizeable arrays, however, they are not part of the core language. A conforming freestanding implementation of C++ (C++98 17.4.1.3) does not need to provide these libraries.

Built-in Strings
Part of the standard library for C++ implements strings, however, they are not part of the core language. A conforming freestanding implementation of C++ (C++98 17.4.1.3) does not need to provide these libraries. Here's a comparison of C++ strings and D built-in strings.

Strong typedefs
Strong typedefs can be emulated in C/C++ by wrapping a type in a struct. Getting this to work right requires much tedious programming, and so is considered as not supported.

Use existing debuggers
By this is meant using common debuggers that can operate using debug data in common formats embedded in the executable. A specialized debugger useful only with that language is not required.

Struct member alignment control
Although many C/C++ compilers contain pragmas to specify struct alignment, these are nonstandard and incompatible from compiler to compiler.
The C# standard ECMA-334 25.5.8 says only this about struct member alignment: $(I "The order in which members are packed into a struct is unspecified. For alignment purposes, there may be unnamed padding at the beginning of a struct, within a struct, and at the end of the struct. The contents of the bits used as padding are indeterminate.") Therefore, although Microsoft may have extensions to support specific member alignment, they are not an official part of standard C#.

Support all C types
C99 adds many new types not supported by C++.

80 bit floating point
While the standards for C and C++ specify long doubles, few compilers (besides Digital Mars C/C++) actually implement 80 bit (or longer) floating point types.

Mixins
Mixins have many different meanings in different programming languages. D mixins mean taking an arbitrary sequence of declarations and inserting (mixing) them into the current scope. Mixins can be done at the global, class, struct, or local level.

C++ Mixins
C++ mixins refer to a couple different techniques. The first is analogous to D's interface classes. The second is to create a template of the form: $(CPPCODE template <class Base> class Mixin : public Base { ... mixin body ... } ) D mixins are different.

Static If
The C and C++ preprocessor directive #if would appear to be equivalent to the D static if. But there are major and crucial differences - the #if does not have access to any of the constants, types, or symbols of the program. It can only access preprocessor macros. See this example.

Is Expressions
$(I Is expressions) enable conditional compilation based on the characteristics of a type. This is done after a fashion in C++ using template parameter pattern matching. See this example for a comparison of the different approaches.

Comparison with Ada
James S. Rogers has written a comparison chart with Ada.

Inner (adaptor) classes
A $(I nested class) is one whose definition is within the scope of another class. An $(I inner class) is a nested class that can also reference the members and fields of the lexically enclosing class; one can think of it as if it contained a 'this' pointer to the enclosing class.

Documentation comments
Documentation comments refer to a standardized way to produce documentation from the source code file using specialized comments.
) $(SECTION2 Errors, $(P If I've made any errors in this table, please contact me so I can correct them. ) ) ) Macros: TITLE=Comparison WIKI=Comparison NO=No NO1=No YES=Yes YES1=Yes