D (programming language)

From ArchWiki
Revision as of 20:01, 24 January 2012 by Steventrouble (Talk | contribs) (Installation)

Jump to: navigation, search

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:D (programming language)#)

Introduction

The D programming language, also known simply as D, is an object-oriented, imperative, multi-paradigm system programming language by Walter Bright of Digital Mars. It originated as a re-engineering of C++, but even though it is predominantly influenced by that language, it is not a variant of it. D has redesigned some C++ features and has been influenced by concepts used in other programming languages, such as Java, C#, and Eiffel.

From Wikipedia:D (programming language).

Installation

To program in D you will need two things - a D compiler and a library. The official compiler is called DMD and is now available in arch's community repository.

dmd is just the compiler, and Template:Package AUR includes the standard library.

dmd is version 2 of dmd, and can be installed from [community]:

# pacman -S dmd

You now have to choose the library you want to use, Phobos or Tango. If you are having trouble deciding which library to choose, have look at a comparison between the two.

Phobos

Phobos is the standard D library. It is available from Arch's community repo:

# pacman -S libphobos

Tango

The D community, after being unhappy about several aspects of the standard D library, wrote their own library called Tango. Tango can be installed from [community]:

# pacman -S libtango

Though at the time of writing, the current release of Tango has a bug making the math modules unusable. It is therefore recommended to install Tango from SVN. The package libtango-svn available from the AUR.

Testing the installation

To make sure that everything is installed and set up correctly, a simple Hello World program should suffice.

For Phobos:

import std.stdio;

int main(char[][] args) {
   writefln("Hello World!");
   return 0;
}

For Tango:

import tango.io.Stdout;

int main(char[][] args) {
   Stdout("Hello World!").newline();
   return 0;
}

Paste the code into a file, name it hello.d, and run

$ dmd hello.d

in the same directory as the file. You should then be able to execute the program with:

$ ./hello

Useful libraries, bindings, etc.

  • QtD - Qt bindings for D
  • GtkD - An object oriented GTK+ wrapper for D
  • Derelict - Bindings for multimedia libraries, focused toward game development
  • Bindings - A project that houses a lot of bindings to different C libraries
  • Descent - An Eclipse plugin for programming in D
  • rdmd - A utility that allows one to execute D files like shell scripts. In AUR

Links

  • Digital Mars - The official home of D
  • dsource - An open source D community, hosts several open source projects
  • Planet D - A collection of blogs about D