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
35
votes
10 answers

Do getters and setters impact performance in C++/D/Java?

This is a rather old topic: Are setters and getters good or evil? My question here is: do compilers in C++ / D / Java inline the getters and setter? To which extent do the getters/setters impact performance (function call, stack frame) compared to a…
alvatar
  • 3,340
  • 6
  • 38
  • 50
31
votes
8 answers

What are all the syntax problems introduced by the usage of angle brackets in C++ templates?

In C++ templates are instantiated with angle brackets vector and the Java and C# languages have adopted the same syntax for their generics. The creators of D, however, have been quite vocal about the problems that angle brackets bring and they…
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
31
votes
5 answers

Does D have something akin to C++0x's move semantics?

A problem of "value types" with external resources (like std::vector or std::string) is that copying them tends to be quite expensive, and copies are created implicitly in various contexts, so this tends to be a performance concern. C++0x's…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
31
votes
2 answers

Usage preference between a struct and a class in D language

When should I define a type as a struct or as a class? I know that struct are value types while classes are reference types. So I wonder, for example, should I define a stack as a struct or a class?
Fred
  • 417
  • 6
  • 14
30
votes
2 answers

vim: associate extension with language

I have gvim 7.2, it recognizes .d files and highlights it correctly according to the syntax of the D programming language. However, .di files are not recognized as D files, and no highlighting is present. How do I let vim highlight .di files…
hasen
  • 161,647
  • 65
  • 194
  • 231
30
votes
3 answers

Exclamation operator?

I'm learning D and have seen a lot of code like this: ushort x = to!ushort(args[1]); I assume this casts args[1] to ushort, but what's the difference between this and cast(ushort)? EDIT: And what other uses does the exclamation mark operator have?
thwd
  • 23,956
  • 8
  • 74
  • 108
30
votes
3 answers

Is D2 language ready for production?

I've been eagerly learning D language these last days. It looks like a dream for me as a supporter of several millions lines of C++ code. We support heavy performance low latency system and it is clear that C++ was the only option in the last ten…
Stas
  • 11,571
  • 9
  • 40
  • 58
30
votes
14 answers

What next generation low level language is the best bet when migrating a code base?

Let's say you have a company running a lot of C/C++, and you want to start planning migration to new technologies so you don't end up like COBOL companies 15 years ago. For now, C/C++ runs more than fine and there is plenty dev on the market for…
Bite code
  • 578,959
  • 113
  • 301
  • 329
29
votes
6 answers

How to create/write a simple XML parser from scratch?

How to create/write a simple XML parser from scratch? Rather than code samples, I want to know what are the simplified, basic steps in English. How is a good parser designed? I understand that regex should not be used in a parser, but how much is…
XP1
  • 6,910
  • 8
  • 54
  • 61
29
votes
7 answers

Where to find algorithms for standard math functions?

I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
27
votes
3 answers

nginx, fastcgi and open sockets

I'm experimenting using fastcgi on nginx, but I've run into some problems. Nginx doesn't reuse connections, it gives 0 in BeginRequest flags, so the application should close the connection after the request has finished. I have the following code…
simendsjo
  • 4,739
  • 2
  • 25
  • 53
27
votes
6 answers

C++ vs. D , Ada and Eiffel (horrible error messages with templates)

One of the problems of C++ are horrible error messages that we are getting from code which intensively uses templates and template metaprogramming. The concepts are designed to solve this problem, but unfortunately they will not be in the next…
UmmaGumma
  • 5,633
  • 1
  • 31
  • 45
27
votes
6 answers

Is worth the effort to learn D?

Imagine you have 3 projects: A text editor for programmers a compiler and a search engine library for at least 3 types of files: html, .xls and pdf. You have 3 choices: C++ Java and C# or you could explore the alternative of doing it with D.…
Nisanio
  • 4,056
  • 5
  • 34
  • 46
27
votes
3 answers

Getting Embedded with D (the programming language)

I like a lot of what I've read about D. Unified Documentation (That would make my job a lot easier.) Testing capability built in to the language. Debug code support in the language. Forward Declarations. (I always thought it was stupid to declare…
NoMoreZealots
  • 5,274
  • 7
  • 39
  • 56
26
votes
8 answers

Should I use Phobos or Tango?

I've decided to learn D, and I'm wondering which standard library I should use. Should I use Phobos or Tango? What are the pros and cons of each?
Zifre
  • 26,504
  • 11
  • 85
  • 105