Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Programming IT Technology

The D Language Progresses 526

xsniper writes "D made its debut here on Slashdot in August 2001. Since then, many new features have been implemented, to include: operator overloading and slew of additional functionalities. It was featured as a cover story for the February 2002 issue of Dr. Dobb's Journal, and has been ported to the UNIX environment. I encourage programmers to revisit the specs to see how Walter Bright has addressed their concerns. A copy of the compiler is also available for testing. I'm sure some would be surprised by the achievements made thus far."
This discussion has been archived. No new comments can be posted.

The D Language Progresses

Comments Filter:
  • What is D? (Score:5, Informative)

    by Anonymous Coward on Sunday January 12, 2003 @01:12AM (#5065294)
    What is D?
    D is a general purpose systems and applications programming language. It is a higher level language than C++, but retains the ability to write high performance code and interface directly with the operating system API's and with hardware. D is well suited to writing medium to large scale million line programs with teams of developers. D is easy to learn, provides many capabilities to aid the programmer, and is well suited to aggressive compiler optimization technology.
    D is not a scripting language, nor an interpreted language. It doesn't come with a VM, a religion, or an overriding philosophy. It's a practical language for practical programmers who need to get the job done quickly, reliably, and leave behind maintainable, easy to understand code.

    D is the culmination of decades of experience implementing compilers for many diverse languages, and attempting to construct large projects using those languages. D draws inspiration from those other languages (most especially C++) and tempers it with experience and real world practicality.

    Why D?
    Why, indeed. Who needs another programming language?
    The software industry has come a long way since the C language was invented. Many new concepts were added to the language with C++, but backwards compatibility with C was maintained, including compatibility with nearly all the weaknesses of the original design. There have been many attempts to fix those weaknesses, but the compatibility issue frustrates it. Meanwhile, both C and C++ undergo a constant accretion of new features. These new features must be carefully fitted into the existing structure without requiring rewriting old code. The end result is very complicated - the C standard is nearly 500 pages, and the C++ standard is about 750 pages! The reality of the C++ compiler business is that few compilers effectively implement the entire standard.

    C++ programmers tend to program in particular islands of the language, i.e. getting very proficient using certain features while avoiding other feature sets. While the code is portable from compiler to compiler, it can be hard to port it from programmer to programmer. A great strength of C++ is that it can support many radically different styles of programming - but in long term use, the overlapping and contradictory styles are a hindrance.

    It's frustrating that such a powerful language does not do basic things like resizing arrays and concatenating strings. Yes, C++ does provide the meta programming ability to implement resizable arrays and strings like the vector type in the STL. Such fundamental features, however, ought to be part of the language. Can the power and capability of C++ be extracted, redesigned, and recast into a language that is simple, orthogonal, and practical? Can it all be put into a package that is easy for compiler writers to correctly implement, and which enables compilers to efficiently generate aggressively optimized code?

    Modern compiler technology has progressed to the point where language features for the purpose of compensating for primitive compiler technology can be omitted. (An example of this would be the 'register' keyword in C, a more subtle example is the macro preprocessor in C.) We can rely on modern compiler optimization technology to not need language features necessary to get acceptable code quality out of primitive compilers.

    D aims to reduce software development costs by at least 10% by adding in proven productivity enhancing features and by adjusting language features so that common, time-consuming bugs are eliminated from the start.

  • Re:D? (Score:2, Informative)

    by Jason1729 ( 561790 ) on Sunday January 12, 2003 @01:25AM (#5065346)
    P and L got used up by APL though. This is BCD..Binary Coded Decimal.

    Jason
    ProfQuotes [profquotes.com]
  • Contracts (Score:4, Informative)

    by The Bungi ( 221687 ) <thebungi@gmail.com> on Sunday January 12, 2003 @01:25AM (#5065347) Homepage
    Nice to see contracts [digitalmars.com] were added to D. They are one of the cooler things in Eiffel. And I'd wish they would have added them to C#.

    And of course, generics [digitalmars.com].

    Now all it needs is some community support and ECMA goodness. I think it has a good chance of being widely used.

  • Re:Java sans VM? (Score:1, Informative)

    by Anonymous Coward on Sunday January 12, 2003 @01:56AM (#5065446)
    From the D faq:

    Why should I use D instead of Java? D is distinct from Java in purpose, philosophy and reality. Here are some of the ways, in no particular order:
    D has Design by Contract.
    D has unit testing.
    D has lightweight arrays.
    D has lightweight objects.
    D has enumerated types.
    D has typedefs.
    D has function delegates.
    D has inline assembler.
    D has direct access to hardware I/O ports.
    D has a considerably smaller executable size (no VM needed).
    D has out and inout function parameters, i.e. functions can return multiple values.
    D has code execution speed that is as fast or faster than C.
    D has direct support of all C types.
    D has support for complex and imaginary floating point types, ASCII, unsigned types, etc.
    D has arrays of bits.
    D has associative arrays.
    D supports direct interfacing to C and operating system APIs.
    D has version control as part of the language.
    Debug D programs with common, existing C debuggers.
    D has a minimal learning curve for C programmers.
    D has turn-offable array bounds checking.
    D has support for assert()s and debug statements, and other tunable runtime error checking.
    D has no need for external C functions.
    D's full library source means complete control over generated app.
    D's floating point is the best available on the target machine.
    D has strings implemented as arrays, not objects.
    D does not do dynamic class loading.
    D works with your other existing dev tools (make, linkers, debuggers, etc.)
    Java is designed to be write once, run everywhere. D is designed for writing efficient native system apps. Although D and Java share the notion that garbage collection is good and multiple inheritance is bad , their different design goals mean the languages have very different feels.

  • by Anonymous Coward on Sunday January 12, 2003 @02:30AM (#5065552)
    Non-virtual methods in Java also involve no indirection. A non-virtual method is one that is private, final, or static. The only difference is:

    in C++, a method is non-virtual unless declared virtual
    in Java, a method is virtual unless declared non-virtual
  • Re:Hello World (Score:2, Informative)

    by Burton Radons ( 640514 ) <loth@users.sourceforge.net> on Sunday January 12, 2003 @03:25AM (#5065697)
    void main ()
    {
    printf ("Hello, World!\n");
    }

    Not exactly informative, although note that "void main ()" is explicitly a well-formed main, and could be:

    void main ();
    void main (char [] [] args);
    int main ();
    int main (char [] [] args);

    The OOP version:

    class HelloWorld
    {
    char [] string = "Hello, Class!\n";

    /* Called at the start of the program before main */
    static this ()
    {
    printf ("Hello, Program!\n");
    }

    /* Called after main or an unhandled exception. */
    static ~this ()
    {
    printf ("Bubye, Program!\n");
    }

    /* The constructor - C++ would have "HelloWorld ()" here */
    this ()
    {
    string = "Hello, World!\n";
    }

    /* The destructor - C++ would have "~HelloWorld ()" here */
    ~this ()
    {
    printf ("Goodbye, World!\n");
    }

    void print ()
    {
    printf ("%.*s", string);
    }
    }

    void main ()
    {
    (new HelloWorld).print ();
    }
  • by Anonymous Coward on Sunday January 12, 2003 @03:41AM (#5065729)
    Value classes by definition are always copied and never passed by reference. Values classes have no identity, only values, so the use of pointers or references with value classes is forbidden. If your classes have references, then they are not value classes but some bastard hybrid between value and interface classes.
  • Re:Hello World (Score:1, Informative)

    by Anonymous Coward on Sunday January 12, 2003 @04:03AM (#5065762)
    C++ allows code to be executed before main() is called, they're called static constructors. The problem is, as you pointed out, there is no specified order in which libraries (modules in D) get their static constructors run. In D, however, the order in which they (the module initializers) is called is determined by how the modules import each other.
  • Re:Hello World (Score:2, Informative)

    by Burton Radons ( 640514 ) <loth@users.sourceforge.net> on Sunday January 12, 2003 @04:43AM (#5065845)
    Nothing. D is not a safe language; making it safe would change the language (no pointers, union restrictions), what it can do (no direct interaction with other languages), and what it can be applied to drastically.

    The calling order of static constructors is not defined. Anyone trying to use static constructors as their only tool is going to get burned, same as with destructors. So:

    class Foo
    {
    private bit initialised;

    static void init ()
    {
    if (initialised)
    return;
    initialised = true;
    ...
    }

    static this ()
    {
    init ();
    }
    }

    Is still a necessary construct.
  • Re:What is D? (Score:5, Informative)

    by ebyrob ( 165903 ) on Sunday January 12, 2003 @06:01AM (#5065978)
    C is a powerful language

    Whenever I think about language utility I always think of the gallery of CSS descramblers [cmu.edu]. Here we see a CSS descrambler in C that is 434 bytes long and runs at better than 10 times the speed of the next smallest implementation (472 bytes of perl code).

    Is there another general purpose language around that can solve this problem with equivalent portions of simplicity and performance?

    I think incompatability, lack of design work and other general language misuse are more to blame for problems in most C code than the language itself. Nearly any language can be used successfully and effectively and nearly any language can be abused.

    Will C be the most widely used programming language for the next 20 years? Hopefully not. Will C continue to be used effectively in the next 20 years when appropriate? Hopefully so.
  • Csharp is not Dflat (Score:2, Informative)

    by Habbie ( 601521 ) on Sunday January 12, 2003 @07:08AM (#5066089) Homepage
    Yes, on a piano it is. As on most guitars. But on a recorder flute or for example a violin, Csharp and Dflat are not the same!
  • by RockyJSquirel ( 412960 ) on Sunday January 12, 2003 @07:31AM (#5066116)
    I was looking at the list of features.

    While it looks fine, and useful, I can't help noticing that last time we heard about D it didn't have most of these features (templates, overloading etc.) and they were claiming that the lack of these features was it's strength.

    I called them ignorant swine for that at the time.

    The new D looks a lot like Modula 3, a great language aiming at the same sort of niche which disappeared without a trace.

    Rocky J. Squirrel
  • by nels_tomlinson ( 106413 ) on Sunday January 12, 2003 @01:42PM (#5067199) Homepage
    Here's what I'd like to know, in my limited knowledge of languages: What languages out there are truly modular? Are there any languages that encompass basic logic principles and which are then able to be augmented by blackboxed modules? So, if you had a language that needed string concatenation, you could whip up a string concatenation module that would then become part of the language.

    Lisp.

    Now, I'm walking a semantic line here, because you can presumably do all that by writing header files, includes, classes, etc. that contain new logic within the structure of the language. But what I mean is a language that by its nature is abstracted and modular, even to the point where the syntax of, say, control structures could be modified in a module?

    Lisp.

    I guess the root question I'm asking is: Are there any truly novel languages out there,

    Lisp.

    or are they all just variations on a common theme, with shared shortcomings and much duplication of effort?

    Everything else.

  • Re:Hello World (Score:1, Informative)

    by Anonymous Coward on Sunday January 12, 2003 @02:39PM (#5067494)
    This is no more of a problem for D than it is for C. With ld.so, each DLL's _init() function is called first. Under Windows, something similar is done for DllEntryPoint() or whatever.

    Of course there is code called before main(). On Linux and BSD, the _start symbol is jumped to, and that sets up argc and argv, then calls main().
  • by bratmobile ( 550334 ) on Sunday January 12, 2003 @03:24PM (#5067745)
    `Value classes' as you term them, amazingly complicate the language; they're one of the reasons that C++ is such a ball of hair.


    Wrong. You are confusing local-scoped (stack) value types with explicit memory management (malloc/free new/delete). The thing that makes life so difficult in C++ is explicit memory management -- the programmer has control over when memory is freed, and therefore, usually gets it wrong.

    Look at the value type system in C# / .Net. It's very, very simple, simplifies a lot of the base class library (common classes like Point and Rectangle), and just makes sense.

    I love garbage collectors. However, putting undue pressure on them will reduce their performance. And memory management performance is one of the hot issues between traditional unmanaged execution (C/C++ malloc/new/etc.) and managed memory (GCs).

    Value types do not complicate GC design. They are completely orthogonal to GC design -- by definition, they simply don't involve GC at all.

    Again, look at value types in C# / .Net. Very simple, very effective, and with absolutely no penalty for use.
  • Re:What is D? (Score:3, Informative)

    by be-fan ( 61476 ) on Sunday January 12, 2003 @06:41PM (#5068802)
    Ha ha. Even the Java folks realized the power of generics. There are lots of things (take a look at Loki or Boost) that simply cannot be done in static languages like C/C++ and Java without something like the template mechanism. Remember, C++ isn't an OOP language, it is a multi-paradigm language. There are lots of cases (and data structures is a big one) where "proper OOP" sucks. Just look at the cast-fest that is the Java collection classes. One of the major powers of the template mechanism is that it allows high level design with low-level performance. And there are *lot's* of people (especially in graphics, science, systems-programming) that really do need low-level performance. Generic data structures without templates usually require either abandoning type safety (by using void pointers, the C way to do it) or abandoning performance (by using inheritence and virtual functions, the Java way to do it). With templates, you don't have to abandon either. In practice, the STL list class is about 50% the speed of a single-type C data structure. Very impressive considering the C structure has embedded link nodes and no copy on insert while the STL does. Vector and matrix classes using templates in scientific applications are often 100% the speed of an equivilent C structure, because of the fully optimizable nature of templates. Of course, like everything else in C++, templates are easy to abuse and use the wrong way. But they are hardly unnecessary and redundant.

Happiness is twin floppies.

Working...