ページの改善
いますぐフォークしてオンライン編集し、このページのプルリクエストを送信します。 Github へのログインが必要です。 これは小さな変更に適しています。 大きな変更を加えたい場合は、通常の cloneの使用をお勧めします。
日本語版について
個人的な学習のために、dlang.orgを翻訳したサイトです。 翻訳に際して、様々なサイトを参考にしています。

D言語 は汎用プログラミング言語で、 静的型付け、システムレベルのアクセス、 Cライクな構文などの特徴を備えています。
D言語なら、軽快にコードの読み書きや実行ができます。

Fast code, fast.


Downloads 最新バージョン: 2.101.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.

D言語をサポートする

D言語は、多くのボランティアの努力と献身、501(c)(3)非営利団体である D言語財団の支援を受けて、開発を進めています。
財団を支援することで、D言語の開発を促進し、コミュニティの成長を支援することができます。

寄付について D言語財団とは

私たちの スポンサー貢献している方々に、たくさんの を。

企業での利用実績

ニュース

Stay updated with the latest posts in the Official D Blog from October 8, 2022: DIP1000: Memory Safety in a Modern Systems Programming Language Part 2 by Ate Eskola.

From June 21, 2022: DIP1000: Memory Safety in a Modern Systems Programming Language Part 1 by Ate Eskola.

学ぶ

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.

コミュニティ

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.

ドキュメント

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.

貢献

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!

パッケージ

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

実行する

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

探る

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.