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
26
votes
3 answers

What is a "yield return" equivalent in the D programming language?

Here is a simple generator in C#. IEnumerable Foo() { int a = 1, b = 1; while(true) { yield return b; int temp = a + b; a = b; b = temp; } } How do I…
Lurkeroid
  • 603
  • 6
  • 8
25
votes
4 answers

Turning off the D garbage collector

I'm a C++ programmer thats considering using D for a personal project I want to play around with. I was wondering if there's a way to completely disable the garbage collector, and what the risks are of doing so. I know I can manage my own memory…
BigSandwich
  • 2,768
  • 2
  • 22
  • 26
25
votes
3 answers

Erlang style concurrency in the D programming language

I think Erlang-style concurrency is the answer to exponential growth of core count. You can kind of fake it with other main stream languages. But the solutions always leave me wanting. I am not willing to give up multi-paradigm programming…
deft_code
  • 57,255
  • 29
  • 141
  • 224
24
votes
9 answers

Improving raytracer performance

I'm writing a comparatively straightforward raytracer/path tracer in D (http://dsource.org/projects/stacy), but even with full optimization it still needs several thousand processor cycles per ray. Is there anything else I can do to speed it up?…
FeepingCreature
  • 3,648
  • 2
  • 26
  • 25
23
votes
1 answer

Pure functional programming in D

To my mind the power of functional purity is when deep code paths can be verified as side-effect free. What are people's experiences in the scale of the code tree that can be inside a pure specifier, and what of the level of code reuse? A few…
John
  • 405
  • 3
  • 6
22
votes
4 answers

pattern matching in D

I recently stumbled over the D programming Language and i really like it. You can programm really high-level while having full Hardware access like in C. coming from a rather functional background (Haskell,scala) I´m searching for a way to pattern…
KIMA
  • 1,077
  • 6
  • 14
22
votes
7 answers

GUI Libraries for D

What is the current status of GUI programming with D Language? Are the language developers planning include GUI in the standard library? The List (compiled from answers) DWT (SWT binding) GtkD (GTK binding) wxD (wxWidgets binding) QtD (Qt binding)
Imran
  • 87,203
  • 23
  • 98
  • 131
22
votes
12 answers

D Templates: Coolest Hack

What is the coolest somewhat practical metaprogramming hack you've done or seen done in the D programming language? Somewhat practical means excluding, for example, the compile-time raytracer.
dsimcha
  • 67,514
  • 53
  • 213
  • 334
22
votes
2 answers

Github incorrectly recognizes programming language used in the project

So I have a git repository that I wrote in C++, but github insists that I'm using D. Why is this and is there someway to correct it?
Loourr
  • 4,995
  • 10
  • 44
  • 68
22
votes
4 answers

What is the difference between const and immutable in D?

What is the difference between the const and immutable type qualifiers in D?
Johan Råde
  • 20,480
  • 21
  • 73
  • 110
21
votes
4 answers

Examples of what D’s templates can be used for

I hear that the D language has powerful metaprogramming features for executing functions at compile time. That sounds very exciting, but I find it difficult to think of practical examples of things that are hard to accomplish without them. Can…
Dimitri C.
  • 21,861
  • 21
  • 85
  • 101
21
votes
3 answers

Link compatibility between C++ and D

D easily interfaces with C. D just as easily interfaces with C++, but (and it's a big but) the C++ needs to be extremely trivial. The code cannot use: namespaces templates multiple inheritance mix virtual with non-virtual methods more? I…
deft_code
  • 57,255
  • 29
  • 141
  • 224
21
votes
10 answers

How to extract text from resonably sane HTML?

My question is sort of like this question but I have more constraints: I know the document's are reasonably sane they are very regular (they all came from the same source I want about 99% of the visible text about 99% of what is viable at all is…
BCS
  • 75,627
  • 68
  • 187
  • 294
20
votes
2 answers

Elegant operator overloading in D

For a while I was confused about the direction of D's operator overloading, but now I realize it's a beautiful system... if It would only work with core types (int, float, etc). Consider the follow code: struct Vector { float X, Y; void…
F i L
  • 760
  • 3
  • 12
20
votes
9 answers

Applications development with D language

For those who had developed applications with D, which libraries did you use to build your application? those libraries were good documented? did you use Tango? do you feel that D is ready to build big applications? which IDE did you use? Descent…
Jonathan Barbero
  • 2,504
  • 1
  • 26
  • 47