Movatterモバイル変換


[0]ホーム

URL:


www.digitalmars.com

D Programming Language 1.0


Last update Sun Dec 30 20:34:42 2012

Articles

Tools

Forums

Community

Appendices

Books

D Programming Language 1.0

“It seems to me that most of the ‘new’ programming languagesfall into one of two categories: Those from academia with radicalnew paradigms and those from large corporations with a focus on RADand the web. Maybe it’s time for a new language born out ofpractical experience implementing compilers.” -- Michael

“Great, just what I need.. another D in programming.” -- Segfault

D is a systems programming language.Its focus is on combining the power and high performance of C and C++ withthe programmer productivity of modern languages like Ruby and Python.Special attention is given to the needs of quality assurance, documentation,management, portability and reliability.

The D language is statically typed and compiles directly to machine code.It’s multiparadigm, supporting many programming styles: imperative, object oriented, and metaprogramming. It’s a member of the C syntax family, and its appearance is very similar to that of C++.Here’s a quick list offeatures.

It is not governed by a corporate agenda or any overarching theory ofprogramming. The needs and contributions of theD programming community form the direction itgoes.

There are two versions of the language:

  1. D version 2which is recommended for new projects.
  2. D version 1which is in maintenance mode.

There are currently four implementations:

  1. Digital Mars dmd forWindows1.02.0,x86 Linux1.02.0,Mac OS X1.02.0, andx86 FreeBSD1.0,2.0.
  2. LLVM D Compilerldcfor D version 1.
  3. Gnu D compilergdc.
  4. D.NET compileralpha for .NET for D version 2.

A large and growing collection of D source code and projectsare atdsource.More links to innumerable D wikis, libraries, tools, media articles,etc. are atdlinks.

This document is available as apdf,as well as inJapaneseandPortugesetranslations.A German bookProgramming in D: Introduction to the new Programming Languageis available, as well asa Japanese bookD Language Perfect Guide,and a Turkish bookD Programlama Dili Dersleri.

This is an example D program illustrating some of the capabilities:

#!/usr/bin/dmd -run/* sh style script syntax is supported *//* Hello World in D   To compile:     dmd hello.d   or to optimize:     dmd -O -inline -release hello.d*/import std.stdio;void main(string[] args){    writeln("Hello World, Reloaded");// auto type inference and built-in foreachforeach (argc, argv; args)    {// Object Oriented Programmingauto cl =new CmdLin(argc, argv);// Improved typesafe printf        writeln(cl.argnum, cl.suffix," arg: ", cl.argv);// Automatic or explicit memory managementdelete cl;    }// Nested structs and classesstruct specs    {// all members automatically initialized        size_t count, allocated;    }// Nested functions can refer to outer// variables like args    specs argspecs()    {        specs* s =new specs;// no need for '->'        s.count = args.length;// get length of array with .length        s.allocated =typeof(args).sizeof;// built-in native type propertiesforeach (argv; args)            s.allocated += argv.length *typeof(argv[0]).sizeof;return *s;    }// built-in string and common string operations    writefln("argc = %d, " ~"allocated = %d",argspecs().count, argspecs().allocated);}class CmdLin{private size_t _argc;private string _argv;public:this(size_t argc, string argv)// constructor    {        _argc = argc;        _argv = argv;    }    size_t argnum()    {return _argc + 1;    }    string argv()    {return _argv;    }    string suffix()    {        string suffix ="th";switch (_argc)        {case 0:            suffix ="st";break;case 1:            suffix ="nd";break;case 2:            suffix ="rd";break;default:break;        }return suffix;    }}

Notice: We welcome feedback about the D compiler or language, but please be explicit aboutany claims to intellectual property rights with a copyright or patent notice if you have such foryour contributions. We want D to remain open and free to use, and do not wish to be caught bysomeone posting a patch to the compiler, and then later claim compensation for that work.





Forums |Comments | D  |Search |Downloads |Home
Copyright © 1999-2012 by Digital Mars ®, All Rights Reserved |Page generated byDdoc.

[8]ページ先頭

©2009-2025 Movatter.jp