助听器什么牌子最好| 为什么男人喜欢邓文迪| 下午6点半是什么时辰| 夏至要吃什么| 隐翅虫咬了用什么药膏| 塔罗牌是什么意思| 什么是色弱| 不耐受和过敏有什么区别| 姘头是什么意思| 雷诺综合症是什么病| 六月八日是什么星座| 成人自考本科需要什么条件| 晨尿浑浊是什么原因| 胆毒是什么原因引起的| 神经性头痛吃什么药| 流清水鼻涕吃什么药| 淋巴结看什么科| sd是什么| 银为什么会变黑| 皮肤一块白一块白的是什么原因| 奇花异草的异什么意思| 水痘擦什么药膏好得快| 丛生是什么意思| 无所不用其极是什么意思| 上海松江有什么好玩的地方| 什么叫发物| 永垂不朽是什么意思| 上面一个处下面一个日是什么字| 经期适合什么运动| 同人小说是什么| 人参补什么| 盐茶是什么茶| 糖尿病人吃什么水果好| ofd是什么意思| 鸡枞是什么| 敦促的意思是什么| 处暑的处是什么意思| 天上火是什么意思| 慢性结肠炎是什么症状| 痣长在什么地方不好| 铁锈用什么能洗掉| 什么是香港脚| 茶叶里面含有什么成分| 什么蛇没毒| 四面受敌是什么动物| 皇太后是皇上的什么人| 经常吃豆腐有什么好处和坏处| 肝病不能吃什么| 阴虱用什么药物| 白芷泡水喝有什么功效| 医学影像技术是干什么的| 耳鸣挂什么科| 胸膜增厚吃什么药| 平板支撑是什么| 前什么后仰| 气短心悸是什么意思| 边界感是什么意思| 心理学是什么| 长期低血糖对人体有什么危害| 什么是权力| 喝苦荞茶对身体有什么好处| 孤魂野鬼是什么生肖| 送护士女朋友什么礼物| 3.30是什么星座| 为什么越睡越困越疲惫| 面红耳赤是什么生肖| 15点是什么时辰| 时尚是什么意思| 蜂蜜喝了有什么好处| 宵夜吃什么好| 天蝎是什么象星座| 9月28号什么星座| 例假推迟是什么原因引起的| 审美疲劳是什么意思| 害怕的近义词是什么| 到底为了什么| 双侧上颌窦炎是什么病| 属马与什么属相最配| 总是感觉有尿意是什么原因| 眼力见是什么意思| 睡觉腿麻是什么原因引起| 为什么精液是黄色的| 心跳过快用什么药| 70年是什么婚| 什么是猝死| 月经量少吃什么好| 月经期可以吃什么水果| 眼睛发炎用什么眼药水| 淋病有什么症状| 茉莉花茶有什么作用| 老年人吃饭老是噎着是什么原因| 什么样的人不适合吃人参| 为什么老是放屁| 尿葡萄糖高是什么原因| 左小腿麻木是什么原因| 映山红是什么花| 哦多桑是什么意思| 河豚为什么有毒| 肩胛骨疼痛是什么原因| 吃什么水果可以护肝| 吃牛油果有什么好处| 叶芽是什么| 牙龈肿痛用什么药好得快| 阿姨的老公叫什么| 女人小便疼是什么原因| vd是什么意思| omega3是什么| 什么是岩茶| 澳门什么时候回归的| 作践自己是什么意思| 4月4日什么星座| 牙疼吃什么食物好得快| 鱼完念什么| 河南属于什么平原| 梦到女鬼是什么意思| 充气娃娃什么感觉| 女生不来大姨妈是什么原因| 小肚子疼是什么原因引起的| 回南天是什么意思| 幽门杆菌吃什么药| 木石念什么| 孕晚期呕吐是什么原因| 6.22什么星座| 晒单是什么意思| 可什么意思| dm是什么| 三克油是什么意思| 似曾相识是什么意思| 女人跑马是什么意思| 心腹是什么意思| 心慌手抖是什么原因| 排斥一个人什么意思| 养精蓄锐是什么意思| 真情流露是什么意思| 护士最高职称是什么| 十月30号是什么星座| 脾胃不好有什么症状表现| 沙弗莱是什么宝石| 丝状疣是什么| 丘比特是什么意思| 慈禧属什么生肖| 杨梅和什么不能一起吃| 农历八月十三是什么星座| 什么叫有格局的人| zhr是什么牌子的鞋| 什么是尿频| 蒸馏水是什么| 吃饭快了有什么坏处| 大拇指发麻是什么原因| 孕妇梦见坟墓是什么预兆| 温吞是什么意思| 右侧卵巢囊性回声什么意思| 喝水经常呛到是什么原因| 挚友是什么意思| 脑供血不足吃什么食物好| 番薯是什么意思| 什么颜色招财并聚财| 月经期间同房有什么危害| 一命呜呼是什么意思| 布谷鸟长什么样| 什么不足| 什么样的人容易垂体瘤| 红薯开花预示着什么| 坚果都有什么| 桃花什么时候开| 花生不能和什么一起吃| 手足口挂什么科| 生育酚乙酸酯是什么| 皮蛋吃了有什么好处和坏处| 蛋糕裙搭配什么上衣| 7月初7是什么节日| 没有是什么意思| 宫颈纳氏囊肿是什么意思严重吗| 茄子有什么营养| 辛辣是什么意思| 遇人不淑是什么意思| 福祸相依什么意思| 人参有什么作用| 腋臭去医院挂什么科| 肛门瘙痒用什么药膏| 1998年五行属什么| 血压有点低是什么原因| 早孕期间吃什么最营养| 什么是靶向治疗| 青榄配什么煲汤止咳做法| 奥美拉唑什么时候吃最好| mcn是什么意思| 身份证带x是什么意思| 甲状腺和甲亢有什么区别| 榴莲什么季节成熟| 什么的水洼| 十月十六号是什么星座| 吃稀饭配什么菜好吃| 胆固醇高应注意什么| 守岁是什么意思| 脖子上长疣是什么原因| 高尿酸有什么症状| 脚旁边骨头突出叫什么| 肉瘤是什么样子图片| 省管干部是什么级别| 4月2号什么星座| 大姨妈期间同房有什么影响| 胃不舒服吃什么| robinhood是什么牌子| 前庭神经炎挂什么科| 早上吃什么减肥| 一笑泯恩仇什么意思| 七月初七是什么星座| 女人为什么会宫外怀孕| 圣贤是什么意思| 耳膜炎是什么症状| 我们都没错只是不适合是什么歌| 番石榴是什么| 吃什么治疗便秘| 梦见剪头发预示什么| 双肺纹理增多什么意思| 脚气涂什么药膏| neighborhood是什么意思| 领衔是什么意思| 日久生情是什么意思| 蛆长什么样| 无常是什么意思| 来苏水又叫什么名字| 为什么咳嗽一直不好| 粥米是什么米| 释然是什么意思| 杏花是什么生肖| 什么原因导致有幽门杆菌| 八月13号是什么星座| 肝炎吃什么药好| 虐恋是什么意思啊| 里正是什么官| 两个人在一起的意义是什么| 酉读什么| 股骨长径是指胎儿什么| 墨绿色是什么颜色| 请人帮忙用什么词| 然五行属性是什么| 肾精亏虚吃什么中成药| 杜牧字什么号什么| 宫内暗区是什么意思| 膝关节置换后最怕什么| 子宫切除对女人有什么影响| 总是耳鸣是什么原因| cp什么意思网络用语| 胎盘分级0级什么意思| 红鸾是什么意思| 麻了是什么意思| 西安香烟有什么牌子| 非洲人吃什么主食| 潜水是什么意思| 梦见筷子是什么预兆| 异卵双胞胎什么意思| 蔓越莓有什么功效| 涉嫌是什么意思| 坐月子吃什么下奶最快最多最有效| 孩子是ab型父母是什么血型| 吃什么解油腻| 前列腺钙化灶是什么意思| 大什么小什么| 更年期吃什么药调理| 心存善念是什么意思| 西泮片是什么药| 下午6点是什么时辰| 百度
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
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. If you'd like to make larger changes you may want to consider using a local clone.

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.


Downloads Latest version: 2.111.0 – Changelog
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 help grow our community by supporting the Foundation.

Donate Learn More About The Foundation

Lots of to our sponsors and contributors.

Industry Proven

News

Stay updated with the latest posts in the Official D Blog from February 22, 2024: DMD Compiler as a Library: A Call to Arms by Razvan Nitu.

From October 2, 2023: Crafting Self-Evident Code with D by Walter Bright.

Learn

Take the Tour, explore major features in D, browse the quick overview, start with C or C++ background, and ask questions in the Learn forum.

For a deeper dive into D check out books or videos such as Ali ?ehreli's free book Programming in D.

Community

Discuss D on the forums, join the IRC channel, read our official Blog, or follow us on Twitter. Browse the wiki, where among other things you can find the high-level vision of the D Language Foundation.

Documentation

Refer to the language specification and the documentation of Phobos, D's standard library. The DMD manual tells you how to use the compiler. Read various articles to deepen your understanding.

Contribute

Report any bugs you find to our bug tracker. If you can fix an issue, make a pull request on GitHub. There are many other ways to help, too!

Packages

DUB is the package manager for D. Get started with DUB, and check out the available packages.

Run

Configure linting, formatting or completion for your favorite IDE, editor or use run.dlang.io to play and experiment with D code.

Explore

Learn about pragmatic D, the DStyle, common D idioms and templates, See what's coming upcoming with next version, explore D Improvement Proposals, and don't fear D's garbage collection.

Fast code, fast.

Write Fast

D allows writing large code fragments without redundantly specifying types, like dynamic languages do. On the other hand, static inference deduces types and other code properties, giving the best of both the static and the dynamic worlds.

void main()
{
    // Define an array of numbers, double[].
    // Compiler recognizes the common
    // type of all initializers.
    auto arr = [ 1, 2, 3.14, 5.1, 6 ];
    // Dictionary that maps string to int,
    // type is spelled int[string]
    auto dictionary = [ "one" : 1, "two" : 2,
        "three" : 3 ];
    // Calls the min function defined below
    auto x = min(arr[0], dictionary["two"]);
}
// Type deduction works for function results.
// This is important for generic functions,
// such as min below, which works correctly
// for all comparable types.
auto min(T1, T2)(T1 lhs, T2 rhs)
{
    return rhs < lhs ? rhs : lhs;
}

Automatic memory management makes for safe, simple, and robust code. D also supports scoped resource management (aka the RAII idiom) and scope statements for deterministic transactional code that is easy to write and read.

import std.stdio;

class Widget { }

void main()
{
    // Automatically managed.
    auto w = new Widget;
    // Code is executed in any case upon scope exit.
    scope(exit) { writeln("Exiting main."); }
    // File is closed deterministically at scope's end.
    foreach (line; File(__FILE_FULL_PATH__).byLine())
    {
        writeln(line);
    }
    writeln();
}

Built-in linear and associative arrays, slices, and ranges make daily programming simple and pleasant for tasks, both small and large.

The D programming language Modern convenience. Modeling power. Native efficiency.
// Compute average line length for stdin
void main()
{
    import std.range, std.stdio;

    auto sum = 0.0;
    auto count = stdin.byLine
        .tee!(l => sum += l.length).walkLength;

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

Read Fast

The best paradigm is to not impose something at the expense of others. D offers classic polymorphism, value semantics, functional style, generics, generative programming, contract programming, and more—all harmoniously integrated.

// Interfaces and classes
interface Printable
{
   void print(uint level)
   // contract is part of the interface
   in { assert(level > 0); }
}

// Interface implementation
class Widget : Printable
{
   void print(uint level)
   in{ }
   do{ }
}

// Single inheritance of state
class ExtendedWidget : Widget
{
   override void print(uint level)
   in { /* weakening precondition is okay */  }
   do
   {
       //... level may be 0 here ...
   }
}

// Immutable data shared across threads
immutable string programName = "demo";
// Mutable data is thread-local
int perThread = 42;
// Explicitly shared data
shared int perApp = 5;

// Structs have value semantics
struct BigNum
{
    // intercept copying
    this(this) { }
    // intercept destructor
    ~this() { }
}

void main()
{
    // ...
}

D offers an innovative approach to concurrency, featuring true immutable data, message passing, no sharing by default, and controlled mutable sharing across threads. Read more.

From simple scripts to large projects, D has the breadth to scale with any application's needs: unit testing, information hiding, refined modularity, fast compilation, precise interfaces. Read more.

Run Fast

D compiles naturally to efficient native code.

D is designed such that most "obvious" code is fast and safe. On occasion a function might need to escape the confines of type safety for ultimate speed and control. For such rare cases D offers native pointers, type casts, access to any C function without any intervening translation, manual memory management, custom allocators and even inline assembly code.

import core.stdc.stdlib;

void livingDangerously()
{
    // Access to C's malloc and free primitives
    enum bytes = float.sizeof * 1024 * 1024;
    auto buf = malloc(bytes);
    // free automatically upon scope exit
    scope(exit) free(buf);
    // Interprets memory as an array of floats
    auto floats = cast(float[]) buf[0 .. bytes];
    // Even stack allocation is possible
    auto moreBuf = alloca(4096 * 100);
    //...
}

// Using inline asm for extra speed on x86
uint checked_multiply(uint x, uint y)
{
    uint result;
    version (D_InlineAsm_X86)
    {
        // Inline assembler "sees" D variables and labels.
        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;
   }
Loverflow:
   throw new Exception("multiply overflow");
}

void main()
{
    // ...
}

The @safe, @trusted, and @system function attributes allow the programmer to best decide the safety-efficiency tradeoffs of an application, and have the compiler check for consistency. Read more.