老觉得饿是什么原因| 北肖指什么生肖| 感冒不能吃什么水果| 周围神经炎是什么症状| 阁字五行属什么| 股票五行属什么| 无产阶级是什么意思| 九一八事变是什么意思| 飞鱼籽是什么鱼的籽| 左耳朵嗡嗡响是什么原因引起的| 女人喝什么茶叶好| 长智齿意味着什么| 越字五行属什么| 什么是跳蛋| 3.28是什么星座| 逝者已矣生者如斯是什么意思| 一什么沙发| a-l-岩藻糖苷酶偏高是什么原因| 2036年是什么年| 酒店尾房是什么意思| 行李是什么意思| 彩字五行属什么| ch是什么牌子| 血小板高是什么原因| 婕字五行属什么| 联字五行属什么| 甲状腺有什么症状| 甲状腺结节是什么症状| 来月经前有褐色分泌物是什么原因| 唯利是图是什么生肖| 吃什么补血小板| ab型和ab型生的孩子是什么血型| 甘薯是什么东西| 尿是褐色的是什么原因| 脚底长水泡是什么原因| 老年痴呆挂什么科| 献血前要注意什么| 腱鞘炎有什么治疗方法| 结节钙化是什么意思| 早上七八点是什么时辰| 吃饱了胃胀是什么原因| 做牛排用什么部位的牛肉| 腿抽筋用什么药| 牙龈翻瓣术是什么意思| 血糖高吃什么水果好能降糖| 婚托是什么意思| 做梦孩子死了什么预兆| 法院是什么机关| 二月底是什么星座| 猪肝有什么功效与作用| 为什么要做肠镜检查| 十一月七号是什么星座| 一什么天| 色盲是什么意思| 法国铁塔叫什么名字| 急性胃肠炎用什么抗生素| 血便是什么原因引起的| 慢性萎缩性胃炎吃什么食物好| 元旦唱什么歌| 眼珠子发黄是什么原因| 脊膜瘤是什么样的病| 出差什么意思| 梦见雨伞是什么意思| 为什么总是莫名其妙的想哭| 吃什么睡眠好| 发呆是什么意思| 梦到生儿子有什么预兆| 三月24号是什么星座的| 血氧饱和度什么意思| 黄芪不适合什么人吃| 然五行属性是什么| 大连机场叫什么| 身上湿气重吃什么药| 云南小黄姜和普通姜有什么区别| 车前草能治什么病| 马是什么牌子的车| 戌时右眼跳是什么预兆| cinderella是什么意思| 肚脐眼连接体内的什么器官| 锁骨下面的骨头叫什么| 什么水果清热去火| 紫外线过敏吃什么药| 月经不调看什么科室| bn是什么意思| 子宫彩超能检查出什么| 脚底板疼用什么药| 睡不着吃什么| 血钾查什么项目| 什么是护理| 两个c是什么牌子| 你为什么爱我| 三丧日是什么意思| 音序是什么意思| 早上不晨勃是什么原因| 数脉是什么意思| 吃什么补大脑| 哆啦a梦大结局是什么| 腿胖是什么原因引起的| 腹膜透析是什么意思| 23号来月经什么时候是排卵期| 疾厄宫是什么意思| 什么食物可以化解结石| 纵隔子宫是什么意思| 送礼送什么烟比较好| 什么汤清热解毒去火| 男性为什么长丝状疣| 什么时候排卵期| 为什么会脚臭| 肠镜挂什么科| 手到擒来是什么意思| 开五行属性是什么| rap是什么意思| 尿隐血3十是什么病| 阴茎发麻是什么原因| 看结石挂什么科室| 什么运动瘦肚子最快| 下午四五点是什么时辰| 鸡涌是什么意思| 水瓶座是什么象| 男人味是什么意思| 什么汗滴| 杨梅泡酒有什么功效和作用| ib是什么意思| 荡秋千有什么好处| 牙周炎吃什么药| 水果什么时间段吃最好| 古字五行属什么| 补办身份证需要什么| 嗣后是什么意思| 梦见人头是什么征兆| 北瓜是什么瓜| 痔疮看什么科| 为什么飞机起飞降落要打开遮光板| 什么是腺肌症| 港澳通行证签注是什么意思| 查转氨酶挂什么科| tf卡是什么| 红红的苹果像什么| 乳腺癌多发于什么年龄| 例假推迟是什么原因引起的| 邦字五行属什么| 牙龈上火肿痛吃什么药| 生石灰是什么| 尿黄是什么病| 墨池为什么不爱柔嘉了| 一年四季穿棉衣是什么生肖| 命犯桃花是什么意思| 17088a是什么尺码男装| 脑死亡是什么意思| ofs是什么意思| 怀二胎初期有什么症状| 奇货可居是什么意思| 下巴出汗多是什么原因| 宫颈炎吃什么药最好| 堃读什么| 黄皮不能和什么一起吃| 什么是透析| 顺位是什么意思| 哺乳期感冒了能吃什么药| 猪古代叫什么| 减肥适合吃什么| 人情味是什么意思| 肺结节吃什么水果好| 鮰鱼是什么鱼| 新西兰现在是什么季节| 这个季节吃什么水果最好| 惊恐发作是什么病| 伤口不愈合是什么原因| 梦见洗头发是什么意思| 脑梗吃什么食物| 什么节日吃饺子| 佛法的真谛是什么| 女人更年期吃什么药调理最好| g是什么单位| 拉出黑色的屎是什么原因| 胆囊萎缩是什么原因| 鹅口疮用什么药效果好| 略施小计是什么动物| 食古不化是什么意思| 血液病有什么症状| 乙肝两对半挂什么科| 学生是什么阶级| 肝脓肿是什么病严重吗| 王爷的儿子叫什么| 手麻是什么原因引起| emmm什么意思| 西瓜与什么食物相克| 乙肝病毒携带者有什么症状| 烧心吃什么药| 炸腮有什么症状| 八字伏吟是什么意思| 西柚是什么意思| 肖像是什么意思| 大臂疼痛怎么什么原因| 生产是什么意思| 红色加蓝色等于什么颜色| 煎服是什么意思| 嗔恨心是什么意思| 梦到孩子丢了是什么征兆| 补体c4偏低是什么意思| 小便有血尿是什么原因| 1924年属什么生肖| 为什么会有肾结石| 算五行缺什么免费测试| 6月23日什么星座| 谷旦是什么意思| 羊肉不放什么调料| 十月是什么月| 胃烧灼感是什么原因引起的| 贫血去医院挂什么科| 头发多剪什么发型好看| 报应是什么意思| 乳头突然疼痛什么原因| 鹿米念什么| 打篮球有什么好处| 细胞器是什么| 70大寿有什么讲究| 胃酸反流是什么原因造成| 什么马没有腿| 虎虎生风是什么意思| 6月份怀孕预产期是什么时候| 龙虾不能和什么一起吃| 氢化油是什么东西| 六味地黄丸有什么用| 下焦湿热吃什么中成药| 平动是什么意思| 舌头痒痒的是什么原因| 矫正视力是什么意思| 腹泻可以吃什么水果| 吃什么能拉肚子| 是什么样的| 为什么用英语怎么说| 亚麻是什么面料| 为什么挠脚心会痒| 梦见山体滑坡是什么意思| 五常大米是什么意思| 红枣和灰枣有什么区别| 基佬什么意思| 什么汤什么火| 拔罐后发痒是什么原因| 手抖挂什么科室| 美味佳肴是什么意思| 钟字五行属什么| 步摇是什么| ckd医学上是什么意思| 蔓越莓是什么水果| 手外科属于什么科| 7月去青海带什么衣服| 出家需要什么条件| 黑脸是什么意思| 空调风扇不转是什么原因| 什么是皮包公司| 梦见摘西红柿是什么意思| 吃什么菜对眼睛好| 霍乱是什么病| gmp是什么| 2009年五行属什么| 什么是跨域| 羟丁酸脱氢酶高是什么原因| 舌苔白有齿痕吃什么药| 单剂量给药是什么意思| 闭经和绝经有什么区别| 凌驾是什么意思| 苦胆是什么| 百度
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.