| 1 |
Ddoc |
|---|
| 2 |
|
|---|
| 3 |
$(D_S D Programming Language $(VER), |
|---|
| 4 |
|
|---|
| 5 |
$(BLOCKQUOTE |
|---|
| 6 |
$(DOUBLEQUOTE It seems to me that most of the $(SINGLEQUOTE new) programming languages |
|---|
| 7 |
fall into one of two categories: Those from academia with radical |
|---|
| 8 |
new paradigms and those from large corporations with a focus on RAD |
|---|
| 9 |
and the web. Maybe it’s time for a new language born out of |
|---|
| 10 |
practical experience implementing compilers.) -- Michael |
|---|
| 11 |
) |
|---|
| 12 |
|
|---|
| 13 |
$(BLOCKQUOTE |
|---|
| 14 |
$(DOUBLEQUOTE Great, just what I need.. another D in programming.) -- Segfault |
|---|
| 15 |
) |
|---|
| 16 |
|
|---|
| 17 |
$(V1 |
|---|
| 18 |
$(P The D book $(AMAZONLINK 1590599608, Learn to Tango with D) |
|---|
| 19 |
by Kris Bell, Lars Ivar Igesund, Sean Kelly and Michael Parker is now out. |
|---|
| 20 |
) |
|---|
| 21 |
) |
|---|
| 22 |
|
|---|
| 23 |
$(COMMENT |
|---|
| 24 |
The second |
|---|
| 25 |
$(LINK2 http://d.puremagic.com/conference2008/, D Programming Language Conference) |
|---|
| 26 |
will take place in Seattle at Amazon, Aug 4..6, 2008. |
|---|
| 27 |
|
|---|
| 28 |
$(P The first |
|---|
| 29 |
$(LINK2 http://d.puremagic.com/conference2007/, D Programming Language Conference) |
|---|
| 30 |
took place in Seattle at Amazon, Aug 23..24, 2007.) |
|---|
| 31 |
) |
|---|
| 32 |
|
|---|
| 33 |
$(P |
|---|
| 34 |
D is a systems programming language. |
|---|
| 35 |
Its focus is on combining the power and high performance of C and C++ with |
|---|
| 36 |
the programmer productivity of modern languages like Ruby and Python. |
|---|
| 37 |
Special attention is given to the needs of quality assurance, documentation, |
|---|
| 38 |
management, portability and reliability. |
|---|
| 39 |
) |
|---|
| 40 |
|
|---|
| 41 |
$(P The D language is statically typed and compiles directly to machine code. |
|---|
| 42 |
It’s multiparadigm, supporting many programming styles: |
|---|
| 43 |
imperative, object oriented, and metaprogramming. It’s a member of the C |
|---|
| 44 |
syntax family, and its appearance is very similar to that of C++. |
|---|
| 45 |
Here’s a quick list of $(LINK2 comparison.html, features). |
|---|
| 46 |
) |
|---|
| 47 |
|
|---|
| 48 |
$(P It is not governed by a corporate agenda or any overarching theory of |
|---|
| 49 |
programming. The needs and contributions of the |
|---|
| 50 |
$(LINK2 ../NewsGroup.html, D programming community) form the direction it |
|---|
| 51 |
goes. |
|---|
| 52 |
) |
|---|
| 53 |
|
|---|
| 54 |
$(P There are two versions of the language: |
|---|
| 55 |
$(OL |
|---|
| 56 |
$(LI $(LINK2 http://www.digitalmars.com/d/1.0/index.html, D version 1) |
|---|
| 57 |
which is in maintenance mode.) |
|---|
| 58 |
$(LI $(LINK2 http://www.digitalmars.com/d/2.0/index.html, D version 2) |
|---|
| 59 |
which is recommended for new projects.) |
|---|
| 60 |
) |
|---|
| 61 |
) |
|---|
| 62 |
|
|---|
| 63 |
$(P There are currently four implementations: |
|---|
| 64 |
$(OL |
|---|
| 65 |
$(LI Digital Mars dmd for |
|---|
| 66 |
Windows $(LINK2 http://www.digitalmars.com/d/1.0/dmd-windows.html, 1.0) |
|---|
| 67 |
$(LINK2 http://www.digitalmars.com/d/2.0/dmd-windows.html, 2.0), |
|---|
| 68 |
x86 Linux $(LINK2 http://www.digitalmars.com/d/1.0/dmd-linux.html, 1.0) |
|---|
| 69 |
$(LINK2 http://www.digitalmars.com/d/2.0/dmd-linux.html, 2.0), |
|---|
| 70 |
Mac OS X $(LINK2 http://www.digitalmars.com/d/1.0/dmd-osx.html, 1.0) |
|---|
| 71 |
$(LINK2 http://www.digitalmars.com/d/2.0/dmd-osx.html, 2.0), and |
|---|
| 72 |
x86 FreeBSD $(LINK2 http://www.digitalmars.com/d/1.0/dmd-freebsd.html, 1.0) |
|---|
| 73 |
) |
|---|
| 74 |
|
|---|
| 75 |
$(LI LLVM D Compiler $(LINK2 http://www.dsource.org/projects/ldc, ldc) |
|---|
| 76 |
for D version 1. |
|---|
| 77 |
) |
|---|
| 78 |
|
|---|
| 79 |
$(COMMENT |
|---|
| 80 |
$(LI Gnu D compiler $(LINK2 http://dgcc.sourceforge.net/, gdc) |
|---|
| 81 |
for several platforms, including |
|---|
| 82 |
$(LINK2 http://gdcwin.sourceforge.net/, Windows) and |
|---|
| 83 |
$(LINK2 http://gdcmac.sourceforge.net/, Mac OS X) |
|---|
| 84 |
for D versions 1.030 and 2.014. |
|---|
| 85 |
) |
|---|
| 86 |
) |
|---|
| 87 |
$(LI Gnu D compiler $(LINK2 http://bitbucket.org/goshawk/gdc/wiki/Home, gdc). |
|---|
| 88 |
) |
|---|
| 89 |
|
|---|
| 90 |
$(LI $(LINK2 http://dnet.codeplex.com/, D.NET compiler) |
|---|
| 91 |
alpha for .NET for D version 2.) |
|---|
| 92 |
) |
|---|
| 93 |
) |
|---|
| 94 |
|
|---|
| 95 |
$(P A large and growing collection of D source code and projects |
|---|
| 96 |
are at $(LINK2 http://www.dsource.org, dsource). |
|---|
| 97 |
More links to innumerable D wikis, libraries, tools, media articles, |
|---|
| 98 |
etc. are at $(LINK2 http://www.digitalmars.com/d/dlinks.html, dlinks). |
|---|
| 99 |
) |
|---|
| 100 |
|
|---|
| 101 |
$(P |
|---|
| 102 |
This document is available as a |
|---|
| 103 |
$(LINK2 http://www.prowiki.org/wiki4d/wiki.cgi?LanguageSpecification/PDFArchive, pdf), |
|---|
| 104 |
as well as in |
|---|
| 105 |
$(LINK2 http://www.kmonos.net/alang/d/, Japanese) |
|---|
| 106 |
and |
|---|
| 107 |
$(LINK2 http://elderane.50webs.com/tuto/d/, Portugese) |
|---|
| 108 |
translations. |
|---|
| 109 |
A German book |
|---|
| 110 |
$(LINK2 http://www.amazon.de/Programmieren-D-Einf%C3%BChrung-neue-Programmiersprache/dp/3939084697/, Programming in D: Introduction to the new Programming Language) |
|---|
| 111 |
is available, as well as |
|---|
| 112 |
a Japanese book |
|---|
| 113 |
$(LINK2 http://www.gihyo.co.jp/books/syoseki-contents.php/4-7741-2208-4, D Language Perfect Guide), |
|---|
| 114 |
and a Turkish book |
|---|
| 115 |
$(LINK2 http://ddili.org/ders/d/, D Programlama Dili Dersleri). |
|---|
| 116 |
) |
|---|
| 117 |
|
|---|
| 118 |
$(COMMENT: Japanese by Kazuhiro Inaba, Portugese by Christian Hartung) |
|---|
| 119 |
|
|---|
| 120 |
$(P This is an example D program illustrating some of the capabilities:) |
|---|
| 121 |
---- |
|---|
| 122 |
#!/usr/bin/dmd -run |
|---|
| 123 |
/* sh style script syntax is supported */ |
|---|
| 124 |
|
|---|
| 125 |
/* Hello World in D |
|---|
| 126 |
To compile: |
|---|
| 127 |
dmd hello.d |
|---|
| 128 |
or to optimize: |
|---|
| 129 |
dmd -O -inline -release hello.d |
|---|
| 130 |
*/ |
|---|
| 131 |
|
|---|
| 132 |
import std.stdio; |
|---|
| 133 |
|
|---|
| 134 |
void main(string[] args) |
|---|
| 135 |
{ |
|---|
| 136 |
$(V1 writefln("Hello World, Reloaded");)$(V2 writeln("Hello World, Reloaded");) |
|---|
| 137 |
|
|---|
| 138 |
// auto type inference and built-in foreach |
|---|
| 139 |
foreach (argc, argv; args) |
|---|
| 140 |
{ |
|---|
| 141 |
// Object Oriented Programming |
|---|
| 142 |
auto cl = new CmdLin(argc, argv); |
|---|
| 143 |
// Improved typesafe printf |
|---|
| 144 |
writeln(cl.argnum, cl.suffix, " arg: ", cl.argv); |
|---|
| 145 |
// Automatic or explicit memory management |
|---|
| 146 |
delete cl; |
|---|
| 147 |
} |
|---|
| 148 |
|
|---|
| 149 |
// Nested structs and classes |
|---|
| 150 |
struct specs |
|---|
| 151 |
{ |
|---|
| 152 |
// all members automatically initialized |
|---|
| 153 |
int count, allocated; |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
// Nested functions can refer to outer |
|---|
| 157 |
// variables like args |
|---|
| 158 |
specs argspecs() |
|---|
| 159 |
{ |
|---|
| 160 |
specs* s = new specs; |
|---|
| 161 |
// no need for '->' |
|---|
| 162 |
s.count = args.length; // get length of array with .length |
|---|
| 163 |
s.allocated = typeof(args).sizeof; // built-in native type properties |
|---|
| 164 |
foreach (argv; args) |
|---|
| 165 |
s.allocated += argv.length * typeof(argv[0]).sizeof; |
|---|
| 166 |
return *s; |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
// built-in string and common string operations |
|---|
| 170 |
writefln("argc = %d, " ~ "allocated = %d", |
|---|
| 171 |
argspecs().count, argspecs().allocated); |
|---|
| 172 |
} |
|---|
| 173 |
|
|---|
| 174 |
class CmdLin |
|---|
| 175 |
{ |
|---|
| 176 |
private int _argc; |
|---|
| 177 |
private string _argv; |
|---|
| 178 |
|
|---|
| 179 |
public: |
|---|
| 180 |
this(int argc, string argv) // constructor |
|---|
| 181 |
{ |
|---|
| 182 |
_argc = argc; |
|---|
| 183 |
_argv = argv; |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
int argnum() |
|---|
| 187 |
{ |
|---|
| 188 |
return _argc + 1; |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
string argv() |
|---|
| 192 |
{ |
|---|
| 193 |
return _argv; |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
string suffix() |
|---|
| 197 |
{ |
|---|
| 198 |
string suffix = "th"; |
|---|
| 199 |
switch (_argc) |
|---|
| 200 |
{ |
|---|
| 201 |
case 0: |
|---|
| 202 |
suffix = "st"; |
|---|
| 203 |
break; |
|---|
| 204 |
case 1: |
|---|
| 205 |
suffix = "nd"; |
|---|
| 206 |
break; |
|---|
| 207 |
case 2: |
|---|
| 208 |
suffix = "rd"; |
|---|
| 209 |
break; |
|---|
| 210 |
default: |
|---|
| 211 |
break; |
|---|
| 212 |
} |
|---|
| 213 |
return suffix; |
|---|
| 214 |
} |
|---|
| 215 |
} |
|---|
| 216 |
---- |
|---|
| 217 |
|
|---|
| 218 |
$(P $(B Notice:) We welcome feedback about the D compiler or language, but please be explicit about |
|---|
| 219 |
any claims to intellectual property rights with a copyright or patent notice if you have such for |
|---|
| 220 |
your contributions. We want D to remain open and free to use, and do not wish to be caught by |
|---|
| 221 |
someone posting a patch to the compiler, and then later claim compensation for that work.) |
|---|
| 222 |
|
|---|
| 223 |
) |
|---|
| 224 |
|
|---|
| 225 |
Macros: |
|---|
| 226 |
TITLE=Intro |
|---|
| 227 |
WIKI=Intro |
|---|