www.digitalmars.com [Home] [Search] [D]
Last modified May 30, 2003.

D vs Other Languages

This table is a quick and rough comparison of various features of D with other languages it is frequently compared with. While many capabilities are available with libraries, this table is for features built in to the language itself.

Feature D C C++ C# Java
Garbage Collection Yes No No Yes Yes
Functions
Function delegates Yes No No Yes No
Function overloading Yes No Yes Yes Yes
Out function parameters Yes Yes Yes Yes No
Nested functions Yes No No No No
Function literals Yes No No No No
Dynamic closures Yes No No No No
Arrays
Lightweight arrays Yes Yes Yes No No
Resizeable arrays Yes No No No No
Arrays of bits Yes No No No No
Built-in strings Yes No No Yes Yes
Array slicing Yes No No No No
Array bounds checking Yes No No Yes Yes
Associative arrays Yes No No No No
Strong typedefs Yes No No No No
String switches Yes No No Yes Yes
Aliases Yes Yes Yes No No
OOP
Object Oriented Yes No Yes Yes Yes
Multiple Inheritance No No Yes No No
Interfaces Yes No Yes Yes Yes
Operator overloading Yes No Yes Yes No
Modules Yes No Yes Yes Yes
Dynamic class loading No No No No Yes
Inner classes No No No No Yes
Covariant return types Yes No Yes No No
Performance
Inline assembler Yes Yes Yes No No
Direct access to hardware Yes Yes Yes No No
Lightweight objects Yes Yes Yes Yes No
Explicit memory allocation control Yes Yes Yes No No
Independent of VM Yes Yes Yes No No
Direct native code gen Yes Yes Yes No No
Templates Yes No Yes No No
Reliability
Design by Contract Yes No No No No
Unit testing Yes No No No No
Static construction order Yes No No Yes Yes
Guaranteed initialization Yes No No Yes Yes
RAII Yes No Yes Yes No
Exception handling Yes No Yes Yes Yes
try-catch-finally blocks Yes No No Yes Yes
Thread synchronization primitives Yes No No Yes Yes
Compatibility
Algol-style syntax Yes Yes Yes Yes Yes
Enumerated types Yes Yes Yes Yes No
Support all C types Yes Yes No No No
Long double floating point Yes Yes Yes No No
Complex and Imaginary Yes Yes No No No
Direct access to C Yes Yes Yes No No
Use existing debuggers Yes Yes Yes No No
Struct member alignment control Yes No No No No
Generates standard object files Yes Yes Yes No No
Macro preprocessor No Yes Yes No No
Other
Conditional compilation Yes Yes Yes Yes No

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.

Design by Contract
The Digital Mars C++ compiler supports Design by Contract as an extension.

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.

Struct member alignment control
Although many C/C++ compilers contain pragmas to specify struct alignment, these are nonstandard and incompatible from compiler to compiler.

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

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

Errors

If I've made any errors in this table, please contact me so I can correct them:

Copyright (c) 2003 by Digital Mars, All Rights Reserved