We are still actively working on the spam issue.

D

From InstallGentoo Wiki
Revision as of 04:31, 1 August 2019 by Se7en1 (talk | contribs) (replace author's note of TODO with a stub template)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

D (aka Dlang) is the language C++ could ever dream to be.

You probably have not heard of D being mentioned a lot, because there are not a lot of projects written in it. Despite that, it's a very comfy low level language with the luxury of some higher level languages (cough cough Python). It features a pretty mature standard library for amd64, a reference compiler with two other major implementations and clear, consistent documentation.

Because of its small traction, the community is small and friendly. Despite that, it is actively being used by large corporations such as Netflix and ebay.

The language is mainly written by Walter Bright, a smart mf who has written six C/++ compilers throughout his life, one of which was the first C++ compiler to native code. On his site, he claims to have the fastest Java compiler and one of the fastest C++ compilers out there, though this information may be a bit dated.

Features

  • Fast as fuck reference compiler (dmd)
    • Since a while also supported by the GNU compiler collection and LVM (gdc and ldc, respectively)
  • Syntax similar to C, short learning curve
  • Consistent, descriptive types which actually make sense (e.g. uint16_t is always a ushort in D)
  • OOP and FP
  • Many quality-of-life improvements with regards to C++, the standard library is quite neat because it doesn't have to deal with the massive legacy backpack C/++ has to deal with.
  • Pretty decent GC (garbage collector). Can be turned off completely where needed.
  • Inline assembly which is a major improvement on the absolute brain cancer in C/++
  • Nearly completely compatible with C, and C++ to some extent
    • Direct access to C API
    • Support for all C datatypes
    • There is a nice funded effort called dpp which seeks to literally import existing C codebases, and they are quite getting there
  • OS exception handling
  • Templating
  • A dependency manager (dub)
  • Small tools such as what clang has to offer (dcd, dfmt, ...)
  • You can run D code like it's a script (vaguely resembling that cool thing you can do with TCC)
  • a whole bunch more which I haven't used much given my personal scope of field using D.

Just show me what makes it special

No messing around with the preprocessor

Modules

First of all, no more bullshitting around with #pragma once or in fact any preprocessor at all. Modules are defined with module foo; (which btw is finally introduced in C++20), and can be imported in other files with import foo; Like in Python, it is possible to reference the package name and import just parts of the module/package.

Pragmas

I haven't used these as much in C++ but you also have pragmas and compile-time checks like in C++, by using static if and pragma if I'm not mistaken?

Criticism

  • In the past, it was regarded as relatively buggy, but as of recently it can be considered stable enough for nearly all needs. Please report bugs.
  • The garbage collector isn't the best compared some languages like Java, but it's certainly well functioning. If you really cannot live without malloc/free, turn it off.
  • Not a lot of people use it, because you aren't using it yet.