Dlang

Primer

Builtin Types

I like the fact that we can di­rectly ac­cess type prop­er­ties via (no pun in­tended) prop­er­ties.

The ba­sic types are pretty much sim­i­lar to C/C++ but with bet­ter con­sis­tency. For ex­am­ple, we have de­fault ini­tial­iza­tions, also de­ter­min­is­tic bit length of each type.

Data struc­tures

Arrays

Symbols Table

The syn­tax is sim­ple and ac­tu­ally sim­i­lar to Golang: valueType[keyType]. The lit­eral is dif­fer­ent though, and it’s sim­pler than Go coun­ter­part:

int[string] dict = ["a": 1, "b": 2];

In fact, I feel like Dlang syn­tax is more con­cise and eas­ier to read than Go.

For ex­am­ple, let de­fine a Trie struc­ture us­ing sym­bols table:

class Trie {
    Trie[dchar] children;
    bool isEnd;
    Trie opIndex(dchar c) => children.require(c, new Trie());
}

Resources