Questions tagged [d]

D is a multi-paradigm systems programming language developed by Walter Bright and, since 2006, Andrei Alexandrescu. Now, D is an open source collaboration.

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 and functional, and offers tools for disciplined template-based metaprogramming. It's a member of the C syntax family.

The current version of D (technically D2), a non-backwards compatible successor, is feature complete and has become the official version under support.

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

Tag usage

When posting questions about D programming, please make sure to include target system and compiler information. This includes the compiler name (eg. dmd, ldc, gdc), version and settings used to compile.

  • Use as a generic tag to refer to the language as a whole, or version 2 specifically.
  • Use to refer to the abandoned version 1 specifically.
2639 questions
165
votes
13 answers

Is D a credible alternative to Java and C++?

Is the D language a credible alternative to Java and C++? What will it take to become a credible alternative? Should I bother learning it? Does it deserve evangelizing? The main reason I ask is that with the new C++ standard (c++0x) almost here,…
Mark Kegel
  • 4,476
  • 3
  • 21
  • 21
141
votes
20 answers

D Programming Language in the real world?

Is anyone out there using D for real world applications? If so, what are you using it for? I can't seem to find anything big on the web written in D. Despite the lack of known big users, D seems like a very promissing language to me, and according…
wvdschel
  • 11,800
  • 14
  • 41
  • 45
138
votes
8 answers

How fast is D compared to C++?

I like some features of D, but would be interested if they come with a runtime penalty? To compare, I implemented a simple program that computes scalar products of many short vectors both in C++ and in D. The result is surprising: D: 18.9 s …
Lars
  • 2,616
  • 3
  • 21
  • 18
104
votes
3 answers

What are the differences between concepts and template constraints?

I want to know what are the semantic differences between the C++ full concepts proposal and template constraints (for instance, constraints as appeared in Dlang or the new concepts-lite proposal for C++1y). What are full-fledged concepts capable of…
Rayniery
  • 1,557
  • 2
  • 12
  • 17
75
votes
3 answers

Why 0.1 + 0.2 == 0.3 in D?

assert(0.1 + 0.2 != 0.3); // shall be true is my favorite check that a language uses native floating point arithmetic. C++ #include int main() { printf("%d\n", (0.1 + 0.2 != 0.3)); return…
Stas
  • 11,571
  • 9
  • 40
  • 58
70
votes
10 answers

To GC or Not To GC

I've recently seen two really nice and educating languages talks: This first one by Herb Sutter, presents all the nice and cool features of C++0x, why C++'s future seems brighter than ever, and how M$ is said to be a good guy in this game. The talk…
Nordlöw
  • 11,838
  • 10
  • 52
  • 99
65
votes
10 answers

Metaprogramming in C++ and in D

The template mechanism in C++ only accidentally became useful for template metaprogramming. On the other hand, D's was designed specifically to facilitate this. And apparently it's even easier to understand (or so I've heard). I've no experience…
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
64
votes
7 answers

Is D's grammar really context-free?

I've posted this on the D newsgroup some months ago, but for some reason, the answer never really convinced me, so I thought I'd ask it here. The grammar of D is apparently context-free. The grammar of C++, however, isn't (even without macros).…
user541686
  • 205,094
  • 128
  • 528
  • 886
58
votes
3 answers

DMD vs. GDC vs. LDC

What are the Pros/Cons of the different D Compilers? How is the performance and the standard compliance/D2 support? How well are debuggers supported? How good are the Error messages and is the IDE integration? How good is the 64 bit support? My…
Fritz
  • 750
  • 1
  • 5
  • 8
55
votes
10 answers

The D Programming Language for Game Development

Recently I've been bothered because I reached a point in which C++ (even 0x) felt very limited, so I started looking for alternatives. Forget Java, C#, Python or Ruby. I still like the low-level nature of C++ and I'm not fond of virtual machines.…
Gui Prá
  • 5,559
  • 4
  • 34
  • 59
51
votes
4 answers

Automatically executed functions when loading shared libraries

When loading shared libraries in Windows, LoadLibrary() call causes DllMain in library to execute for each new process and thread library attaches to, and for each process and thread library deattaches from. Is there similar mechanism for Mac OS X,…
toriningen
  • 7,196
  • 3
  • 46
  • 68
45
votes
6 answers

Does the D language have multiple standard libraries and issues with GC?

I'm wondering how mature and stable D is, and if it might be a good replacement for C/C++. I know that there are currently two standard libraries (Phobos and Tango). Is it still the case that there is no unified standard library? Additionally I…
soc
  • 27,983
  • 20
  • 111
  • 215
41
votes
7 answers

D programming without the garbage collector

I've been looking at D today and on the surface it looks quite amazing. I like how it includes many higher level constructs directly in the language so silly hacks or terse methods don't have to be used. One thing that really worries me if the GC. I…
AbstractDissonance
  • 1
  • 2
  • 16
  • 31
40
votes
4 answers

Can a compiler automatically detect pure functions without the type information about purity?

So I'm arguing with my friend who claims that a compiler like GCC can detect a pure function automatically without any type information. I doubt that. Languages like D or Haskell have purity in their type systems and a programmer explicitly defines…
Christian Zeller
  • 659
  • 1
  • 7
  • 9
39
votes
6 answers

Why is thread local storage so slow?

I'm working on a custom mark-release style memory allocator for the D programming language that works by allocating from thread-local regions. It seems that the thread local storage bottleneck is causing a huge (~50%) slowdown in allocating memory…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
1
2 3
99 100