D

DMD

Installation

Ubuntu
apt install dmd
Alma Linux
# Download dmd-{version}-fedora.{arch}.rpm from https://dlang.org
dnf install dmd-{version}-fedora.{arch}.rpm
Arch Linux
pacman -S dmd

Examples

Fibonacci Numbers
// Fibonacci Numbers

import std.stdio;
import std.conv;

int fib(int n) {
    if (n < 2) {
        return n;
    } else {
        return fib(n - 2) + fib(n - 1);
    }
}

void main(string[] args) {
    int n = to!int(args[1]);
    writeln(fib(n));
}

/*
example
    compile:
        dmd -O -inline fib.d
        gdc -O3 fib.d
    run:
        ./fib 39
*/

GDC

Installation

Ubuntu
apt install gdc
Arch Linux
pacman -S gcc-d