Questions tagged [d]

D is a systems programming language developed by Walter Bright and since 2006 Andrei Alexandrescu. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of concurrency, reliability, documentation, quality assurance, management and portability.

Overview

D is a systems programming language developed by Walter Bright and since 2006 Andrei Alexandrescu. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of concurrency, reliability, documentation, quality assurance, management and portability.

The D language is statically typed and compiles directly to machine code. It supports many programming styles: imperative, object oriented, functional, and metaprogramming. It's a member of the C syntax family, and its appearance is very similar to that of C++.

There are currently two versions of D:

Version 1 achieved stable status in 2007 and was discontinued on December 31, 2012.

Version 2, a non-backwards compatible successor is feature complete and currently in the final stages of development.

Hello world in D

import std.stdio;

void main()
{
    writeln("Hello, world!");
}

Design Goals of D

  1. Make it easier to write code that is portable from compiler to compiler, machine to machine, and operating system to operating system.
  2. Eliminate undefined and implementation defined behaviors as much as practical.
  3. Provide syntactic and semantic constructs that eliminate or at least reduce common mistakes.
  4. Reduce or even eliminate the need for third party static code checkers.
  5. Support memory safe programming.
  6. Support multi-paradigm programming, i.e. at a minimum support imperative, structured, object oriented, generic and even functional programming paradigms.
  7. Make doing things the right way easier than the wrong way.
  8. Have a short learning curve for programmers comfortable with programming in C, C++, Java or C#.
  9. Provide low level bare metal access as required.
  10. Provide a means for the advanced programmer to escape checking as necessary.
  11. Be compatible with the local C application binary interface.
  12. Have a context-free grammar, i.e. successful parsing must not require semantic analysis.
  13. Easily support writing internationalized applications.
  14. Incorporate Contract Programming and Unit Testing methodology.
  15. Be able to build lightweight, standalone programs.
  16. Reduce the costs of creating documentation.

External Resources

7 questions
134
votes
8 answers

What does C++ do better than D?

I have recently been learning D and am starting to get some sort of familiarity with the language. I know what it offers, I don't yet know how to use everything, and I don't know much about D idioms and so on, but I am learning. I like D. It is a…
Anto
  • 11,157
  • 13
  • 67
  • 103
41
votes
8 answers

Can modern OO languages compete with C++'s array store performance?

I just noticed that every modern OO programming language that I am at least somewhat familiar with (which is basically just Java, C# and D) allows covariant arrays. That is, a string array is an object array: Object[] arr = new String[2]; // Java,…
fredoverflow
  • 6,854
  • 8
  • 39
  • 46
24
votes
6 answers

Why did the team at LMAX use Java and design the architecture to avoid GC at all cost?

Why did the team at LMAX design the LMAX Disruptor in Java but all their design points to minimizing GC use? If one does not want to have GC run then why use a garbage collected language? Their optimizations, the level of hardware knowledge and the…
user4626
21
votes
5 answers

Why C++ cannot adopt D's approach for its concept implementation?

As many of you guys know, concepts, C++'s approach for constraining possible types for a template argument has failed to be included in C++11. I learned that the D programming language 2.0 has a similar feature for its generic programming. Its…
jj1
  • 313
  • 1
  • 7
7
votes
4 answers

what is the object oriented counterpart to haskell / coq

I have detailed information on the latest developments in functional programming. I think haskell is quite an advanced and high level programming language. With coq and agda this gets even more complex and advanced. With "advanced" and "high level"…
mrsteve
  • 450
  • 3
  • 10
0
votes
1 answer

How should templates be named?

In D I can create templates like this: template Foo(A) { A add(A a, A b) { ... } A multiply(A a, A b) { ... } A concatenate(A a, A b) { ... } } What should a template be named ideally? What conventions exist out there? I'm looking to…
Jeroen
  • 613
  • 1
  • 7
  • 13
-3
votes
2 answers

How do you hash 4 doubles into a size_t?

I have bounding boxes the key type. Box { double mins[2]; double maxs[2]; } And I want to have Box as the key type in the D programming language, so I have to implement: size_t toHash() const @safe pure nothrow { size_t hash; for(size_t…