Difference between revisions of "D (programming language)"

From ArchWiki
Jump to: navigation, search
(Installation)
(Updated most of the content, so that it is up to date.)
Line 1: Line 1:
 
[[Category: Development (English)]]
 
[[Category: Development (English)]]
{{out of date}}
 
 
= Introduction =
 
= Introduction =
 
<blockquote>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.</blockquote>
 
<blockquote>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.</blockquote>
Line 8: Line 7:
 
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.
 
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 {{Package AUR|dmd2-complete}} includes the standard library.
+
dmd is just the compiler, but also includes the standard library, which is called Phobos.
  
 
The package dmd is version 2 of dmd, and can be installed from [community]:
 
The package dmd is version 2 of dmd, and can be installed from [community]:
Line 14: Line 13:
 
  # pacman -S dmd
 
  # 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].
+
This will pull libphobos in as a dependency.
 
+
== 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 [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 =
 
To make sure that everything is installed and set up correctly, a simple Hello World program should suffice.
 
To make sure that everything is installed and set up correctly, a simple Hello World program should suffice.
  
For Phobos:
 
  
 
  import std.stdio;
 
  import std.stdio;
 
   
 
   
  int main(char[][] args) {
+
  void main() {
     writefln("Hello World!");
+
     string yourName = "archer";
     return 0;
+
     writefln("Hello %s!", yourName);
}
+
 
+
For Tango:
+
 
+
import tango.io.Stdout;
+
+
int main(char[][] args) {
+
    Stdout("Hello World!").newline();
+
    return 0;
+
 
  }
 
  }
  
Line 58: Line 33:
  
 
  $ ./hello
 
  $ ./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, bindings, etc. =
 
= Useful libraries, bindings, etc. =
 +
* [http://code.google.com/a/eclipselabs.org/p/ddt/ DDT] - Eclipse plugin for project and code management in D
 
* [http://www.dsource.org/projects/qtd/ QtD] - Qt bindings for D
 
* [http://www.dsource.org/projects/qtd/ QtD] - Qt bindings for D
 
* [http://www.dsource.org/projects/gtkd GtkD] - An object oriented GTK+ wrapper for D
 
* [http://www.dsource.org/projects/gtkd GtkD] - An object oriented GTK+ wrapper for D
Line 68: Line 55:
  
 
= Links =
 
= Links =
* [http://www.digitalmars.com/d/ Digital Mars] - The official home of D
+
* [https://github.com/D-Programming-Language/phobos/ Phobos source on github] - The official Phobos repo
 +
* [http://dlang.org/ Digital Mars] - The official home of D
 
* [http://www.dsource.org/ dsource] - An open source D community, hosts several open source projects
 
* [http://www.dsource.org/ dsource] - An open source D community, hosts several open source projects
 
* [http://planet.dsource.org/ Planet D] - A collection of blogs about D
 
* [http://planet.dsource.org/ Planet D] - A collection of blogs about D

Revision as of 21:33, 31 January 2012

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, but also includes the standard library, which is called Phobos.

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

# pacman -S dmd

This will pull 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, bindings, etc.

  • 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. In AUR

Links