D Programming Language

Published: (February 12, 2026 at 12:18 AM EST)
4 min read

Source: Hacker News

Report a bug

Report a bug – If you spot a problem with this page, click here to create a Bugzilla issue.

Improve this page

Improve this page – Quickly fork, edit online, and submit a pull request for this page. Requires a signed‑in GitHub account. This works well for small changes; for larger changes consider using a local clone.

About D

D is a general‑purpose programming language with static typing, systems‑level access, and C‑like syntax. With the D Programming Language, write fast, read fast, and run fast.

Fast code, fast.

Submit your code

Your code here – Got a brief example illustrating D? Submit your code to the digitalmars.D forum specifying “[your code here]” in the subject. Upon approval it will be showcased here on a random schedule.

Support the D language

D is made possible through the hard work and dedication of many volunteers, with the coordination and outreach of the D Language Foundation, a 501(c)(3) non‑profit organization. You can help further the development of the D language and grow our community by supporting the Foundation.

Companies using D

Netflix
eBay
Funkwerk
Symmetry
Auburn Sounds
Weka

Run

Configure linting, formatting, or completion for your favorite:

Or use the online playground run.dlang.io to play and experiment with D code.

Fast code, fast

Write Fast

D lets you write large code fragments without repeatedly specifying types—just like a dynamic language—while its static inference still deduces types and other properties, giving you the best of both worlds.

import std.stdio;

void main()
{
    // Heterogeneous array; the compiler infers the element type.
    auto arr = [1, 2, 3.14, 5.1, 6];

    // Associative array (dictionary).
    auto dictionary = ["one": 1, "two": 2, "three": 3];

    // Generic min function works on any comparable types.
    auto x = min(arr[0], dictionary["two"]);
    writeln("min = ", x);
}

// Generic min that works with any two comparable types.
auto min(T1, T2)(T1 lhs, T2 rhs)
{
    return rhs  sum += l.length)   // accumulate total length
        .walkLength;                  // count lines

    writeln("Average line length: ",
            count ? sum / count : 0);
}

Read Fast

D provides many paradigms without forcing you to sacrifice others. You get classic polymorphism, value semantics, functional style, generics, generative programming, contract programming, and more—all integrated seamlessly.

interface Printable
{
    void print(uint level)
        in { assert(level > 0); }
}

class Widget : Printable
{
    void print(uint level)
        in { }   // pre‑condition
        do { }   // body
}

class ExtendedWidget : Widget
{
    override void print(uint level)
        in { }   // pre‑condition
        do
        {
            // extended behaviour
        }
}
immutable string programName = "demo";
int    perThread = 42;
shared int perApp = 5;

struct BigNum
{
    this(this) { }   // post‑blit
    ~this() { }      // destructor
}

D’s concurrency model emphasizes immutable data, message passing, no sharing by default, and controlled mutable sharing across threads.
Read more about D’s concurrency model.

From tiny scripts to large projects, D scales with any application’s needs: unit testing, information hiding, refined modularity, fast compilation, and precise interfaces.
Read more about D’s ecosystem.


Run Fast

D compiles directly to efficient native code. Most “obvious” code is both fast and safe. When ultimate speed or low‑level control is required, D provides:

  • native pointers,
  • explicit casts,
  • direct calls to C functions,
  • manual memory management,
  • custom allocators,
  • inline assembly.
import core.stdc.stdlib;

void livingDangerously()
{
    enum bytes = float.sizeof * 1024 * 1024;
    auto buf = malloc(bytes);
    scope(exit) free(buf);

    // reinterpret the allocated memory as a float array
    auto floats = cast(float[]) buf[0 .. bytes];

    // stack allocation (C alloca)
    auto moreBuf = alloca(4096 * 100);
}
uint checked_multiply(uint x, uint y)
{
    uint result;
    version (D_InlineAsm_X86)
    {
        asm
        {
            mov     EAX, x;
            mul     EAX, y;
            mov     result, EAX;
            jc      Loverflow;
        }
        return result;
    }
    else
    {
        result = x * y;
        if (!y || x <= uint.max / y)
            return result;          // no overflow
    }

Loverflow:
    throw new Exception("multiply overflow");
}

The @safe, @trusted, and @system function attributes let you decide the safety‑efficiency trade‑offs for each part of your program, with the compiler enforcing consistency.
Read more about memory‑safe D.


© 1999‑2026 by the D Language Foundation – page generated by Ddoc on Thu Jan 15 22:48:15 2026.

0 views
Back to Blog

Related posts

Read more »

shadcn & ai give me superpower....

While working on the frontend of my project, I used shadcn/ui, and it has been a great experience. The components are clean, stable, and highly customizable. Si...

Partial Indexes in PostgreSQL

Partial indexes are refined indexes that target specific access patterns. Instead of indexing every row in a table, they only index the rows that match a condit...