Difference between revisions of "D (programming language)"

From ArchWiki
Jump to: navigation, search
(Installation: is now in aur, updating)
(See Also)
(18 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category: Development (English)]]
+
[[Category:Programming language]]
= Introduction =
+
From [[Wikipedia:D (programming language)]]:
<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>
+
:"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 =
+
== 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. Easiest way to get srated fast is to install {{Pkg|dlang-dmd}} package group. It will provide the official compiler ({{Pkg|dmd}}), standard lbrary {{Pkg|libphobos-devel}} and collection of small development tools {{Pkg|dtools}}.
  
{{Package AUR|dmd2}} is just the compiler, and {{Package AUR|dmd2-complete}} includes the standard library.
+
== Testing the installation ==
 
+
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].
+
 
+
== 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]].
+
 
+
= 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 52: Line 24:
 
  $ ./hello
 
  $ ./hello
  
= Useful libraries, bindings, etc. =
+
You can also execute
* [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
+
$ dmd -run hello.d
* [http://www.dsource.org/projects/derelict Derelict] - Bindings for multimedia libraries, focused toward game development
+
 
* [http://www.dsource.org/projects/bindings Bindings] - A project that houses a lot of bindings to different C libraries
+
which will simply compile and run without leaving any object files in the directory.
* [http://www.dsource.org/projects/descent Descent] - An [[Eclipse]] plugin for programming in D
+
 
 +
== Considerations ==
 +
There are however possible choices regarding the compiler you choose. The standard (reference one) is dmd, but {{Pkg|gdc}} (GNU D Compiler) and {{Pkg|ldc}} (LLVM D Compiler) are also popular. Those are also in [community].
 +
 
 +
The main difference is that the dmd's back end is not FOSS (licensed from Symantec), while the others compilers are completely FOSS. All 3 compilers share same front-end code and thus have almost identical support for language features (assuming same front-end version).
 +
 
 +
== Useful libraries and bindings ==
 +
* [https://code.google.com/p/ddt/ DDT] - Eclipse plugin for project and code management in D
 +
* [http://mono-d.alexanderbothe.com/ Mono-D] - [http://monodevelop.com/ MonoDevelop] addin for programming in D
 +
* [https://bitbucket.org/qtd/repo QtD] - Qt bindings for D
 +
* [http://gtkd.org/ GtkD] - An object oriented GTK+ wrapper for D
 +
* [https://github.com/aldacron/Derelict3 Derelict] - Bindings for multimedia libraries, focused toward game development
 +
* [https://github.com/D-Programming-Deimos Deimos] - A project that houses a lot of bindings to different C libraries
  
= Links =
+
== See Also ==
* [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://www.dsource.org/ dsource] - An open source D community, hosts several open source projects
+
* [http://dlang.org/ The D Programming Language] - The official home of D
 
* [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 13:16, 29 September 2013

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. Easiest way to get srated fast is to install dlang-dmd package group. It will provide the official compiler (dmd), standard lbrary libphobos-devel and collection of small development tools dtools.

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 (reference one) is dmd, but gdc (GNU D Compiler) and ldc (LLVM D Compiler) are also popular. Those are also in [community].

The main difference is that the dmd's back end is not FOSS (licensed from Symantec), while the others compilers are completely FOSS. All 3 compilers share same front-end code and thus have almost identical support for language features (assuming same front-end version).

Useful libraries and bindings

  • DDT - Eclipse plugin for project and code management in D
  • Mono-D - MonoDevelop addin for programming in D
  • QtD - Qt bindings for D
  • GtkD - An object oriented GTK+ wrapper for D
  • Derelict - Bindings for multimedia libraries, focused toward game development
  • Deimos - A project that houses a lot of bindings to different C libraries

See Also