Navigation
  • Home
  • Recent
  • Most Active
  • Popular
  • Blog
  • Credits
  • RSS
  •   Interaction
  • Register
  • Statistics
  •   Help
  • Suggestions
  • Contact Us
  • How to Edit
  • Help



  • [Edit]




    D is an object-oriented, imperative, multiparadigm system programming language by Walter Bright of Digital Mars. It originated as a re-engineering of C++, but even though it is predominately influenced by that language, it is not a variant of C++. D has redesigned some C++ features and has been influenced by concepts used in other programming languages.


        D (programming language)
            Features
                Memory management
                Interaction with other systems
            Implementation
            Examples
                Example 1
                Example 2
                Example 3
            See also
    NameD
    ParadigmMulti-paradigm programming language
    Year1999
    Typingstrong, static
    DesignerWalter Bright
    Latest Release Version0.171
    Latest Release DateOctober 18 2006
    Implementationshttp://www.digitalmars.com/d/changelog.html D...
    Influenced ByC++ (programming language)

    top

    Features
    NOTE: The feature set and detailed design of the language is not quite finalized as of the time of this writing.

    D is being designed with lessons learned from practical C++ usage rather than from a theoretical perspective. It uses many C++ concepts but discards some, such as strict backwards compatibility with C source code. It adds to the functionality of C++ by also implementing design by contract, unit testing, true modules, automatic memory management (garbage collection), first class arrays, associative arrays, dynamic arrays, array slicing, nested functions, inner classes, closures (anonymous functions), lazy evaluation and has a reengineered template syntax. D retains C++'s ability to do low-level coding, and adds to it with support for an integrated inline assembler. C++ multiple inheritance is replaced by single inheritance with interfaces and mixins. D's declaration, statement and expression syntax closely matches that of C++.

    The inline assembler typifies the differences between D and application languages like Java and C#. An inline assembler lets programmers enter machine-specific assembly code in with standard D code—a technique often used by systems programmers to access the low-level features of the processor needed to run programs that interface directly with the underlying hardware, such as operating systems and device drivers.

    D has built-in support for embedded documentation comments (called Ddoc), but so far only the compiler supplied by DigitalMars implements a documentation generator.

    top

    Memory management
    Memory is usually managed with garbage collection, but specific objects can be finalized immediately when they go out of scope. Explicit memory management is possible using the overloaded operators new and delete, as well as simply calling C's malloc and free directly. It is also possible to disable garbage collection for individual objects, or even for the entire program if more control over memory management is desired. The manual gives numerous examples as to how to implement different extremely optimized memory management schemes when garbage collection won't quite do it for part of the program.

    top

    Interaction with other systems
    C's ABI (Application Binary Interface) is supported as well as all of C's fundamental and derived types, enabling direct access
    to existing C code and libraries. C's standard library is part of standard D. Unless you use very explicit namespaces it can be somewhat messy to access, as it is spread throughout the D modules that use it -- but the pure D standard library is usually sufficient unless interfacing with C code.

    C++'s ABI is not supported, although D can access C++ code that is written to the C ABI, and can access C++ COM (Component Object Model) code. The D parser understands an extern (C++) calling convention for linking to C++ objects, but it is not yet implemented.

    top

    Implementation
    Current D implementations compile directly into native code for efficient execution.

    D is still under development, and changes to the language are made regularly. Although the design is almost frozen, it is possible that some of these changes could break D programs written for older versions of the language and compiler. The official compiler by Walter Bright defines the language itself, and it is currently in the beta testing state.

      DMD Compiler: the Digital Mars D compiler, the official D compiler by Walter Bright. The compiler front end is licensed under both the Artistic License and the GNU GPL license, sources for the front end are distributed along with the compiler binaries. The compiler back end is copyrighted closed-source.
      Gnu D Compiler (GDC): the GNU D Compiler, built making the DMD compiler front end and the GCC compiler back end work together.

    top

    Examples
    Keywords are in , strings in , comments in .

    top

    Example 1
    This example program prints its command line arguments.
    The main function is the entry point of a D program, and args
    is an array of strings representing the command line arguments.
    A string in D is an array of characters, represented by char.

    std.stdio;
    main( args)


    The foreach statement can iterate over any collection, in this case it
    is producing a sequence of keys (i) and values (a) from the array
    args.

    top

    Example 2
    This illustrates the use of associative arrays to build much more complex data
    structures.

    std.stdio;

    main()


    display_item_count( person, items)


    top

    Example 3
    This heavily annotated example highlights many of the differences from C++, while still retaining some C++ aspects.



    std.stdio;

    main( args)



    CmdLin



    top

    See also
     
    Search more:
     

       
    Source Privacy License Download Contact Us Atlas
    Scientus.org Dictionary (Yet Another Wiki) RC : 1.39
    This article is licensed under the GNU Free Documentation License [copyleft]. It uses material from the Wikipedia article "D (programming language)". link