Difference between revisions of "D (programming language)"

From ArchWiki
Jump to: navigation, search
({{out of date}} hasn't been updated to reflect the fact that there are now 2 versions of the language, etc. - I don't use D, so I can't really update it any more)
(Installation)
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
= Installation =
 
= Installation =
To program in D you will need two things - a D compiler and a library. The official compiler is called DMD and is available in the [[AUR]].
+
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.
  
{{Package AUR|dmd2}} is just the compiler, and {{Package AUR|dmd2-complete}} includes the standard library.
+
dmd is just the compiler, and {{Package AUR|dmd2-complete}} includes the standard library.
 +
 
 +
The package 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 [http://docs.google.com/Doc?id=dcswwfd8_48hq4fdwhd a comparison between the two].
 
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 [http://docs.google.com/Doc?id=dcswwfd8_48hq4fdwhd a comparison between the two].
Line 23: Line 27:
  
 
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 [http://aur.archlinux.org/packages.php?ID=15841 libtango-svn] available from the [[AUR]].
 
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 [http://aur.archlinux.org/packages.php?ID=15841 libtango-svn] available from the [[AUR]].
 +
 +
Note: Tango is no longer available in [community], as it lacks support for D2. libphobos will be installed by default if you install dmd via pacman.
  
 
= Testing the installation =
 
= Testing the installation =
Line 59: Line 65:
 
* [http://www.dsource.org/projects/bindings Bindings] - A project that houses a lot of bindings to different C libraries
 
* [http://www.dsource.org/projects/bindings Bindings] - A project that houses a lot of bindings to different C libraries
 
* [http://www.dsource.org/projects/descent Descent] - An [[Eclipse]] plugin for programming in D
 
* [http://www.dsource.org/projects/descent Descent] - An [[Eclipse]] plugin for programming in D
 +
* [http://www.d-programming-language.org/rdmd.html rdmd] - A utility that allows one to execute D files like shell scripts. [https://aur.archlinux.org/packages.php?ID=56070 In AUR]
  
 
= Links =
 
= Links =

Revision as of 20:04, 24 January 2012

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.

The package 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.

Note: Tango is no longer available in [community], as it lacks support for D2. libphobos will be installed by default if you install dmd via pacman.

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