D (programming language)

From ArchWiki
Revision as of 13:13, 29 May 2013 by Fengchao (Talk | contribs)

Jump to: navigation, search

From Wikipedia:D (programming language):

"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".

Installation

To program in D you will need two things - a D compiler and a library. The official compiler is called dmd which is available in official repositories. It will pull the standard library libphobos in as a dependency.

Testing the installation

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

import std.stdio;

void main() {
   string yourName = "archer";
   writefln("Hello %s!", yourName);
}

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

You can also execute

$ dmd -run hello.d

which will simply compile and run without leaving any object files in the directory.

Considerations

There are however possible choices regarding the compiler you choose. The standard is dmd, but GDC (GNU D Compiler) and LDC (LLVM D Compiler) are also popular. There are packages in the AUR for both of these should you find it interesting.

The main difference is that the dmd's back end is not FOSS (licensed from Symantec), while the others compilers are completely FOSS, both back- and front-end.

Useful libraries and bindings

  • DDT - Eclipse plugin for project and code management in D
  • 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.
  • Mono-D - An IDE addin for programming in D. (based on MonoDevelop)

See Also