This is an HTML rendering of a working paper draft that led to a publication. The publication should always be cited in preference to this draft using the following reference:
Bell K., Igesund L., Kelly S., Parker M.
Learn to Tango with D
D is a strongly typed, natively compiled language, and Tango is one of its major companion libraries. The major intellectual forebear of D is clearly C++ (the language’s designer, Walter Bright, developed the first native C++ compiler, Zortech C++). However, D sheds many nowadays often irritating legacy C++ features. Gone is the preprocessor and the C data types that retain compatibility with programs written for the PDP-11 more than 30 years ago. D defines from scratch an intuitive set of basic data types derived for modern hardware architectures, and puts in order C’s postfix declarations, and the passing of variables to functions by defining in, out, and reference argument types. D also balances nicely Java’s compulsory overhead of subtyping polymorphism against the unattractiveness of the C++ virtual method declarations by using the “struct” keyword for defining objects that can’t be subclassed and reserving the “class” keyword for building class hierarchies with dynamic dispatch tables. Furthermore, D adopts innovations from other languages, like Java, C#, and Eiffel, by supporting modules, delegates, and invariants.
At times one is however left with the feeling of creeping featurism run wild. There is built-in support for associative arrays and unit tests, complex numbers, template metaprogramming, and the innovative concept of compile-time function evaluation. To this reviewer the selection of features to include in the language seems arbitrary. If one adds these features to a programming language, why stop there and not add support for XML constants, SQL statements, internationalization, matrices, or branch prediction annotations? There is also an unclear boundary between abstract concepts and implementation-related properties, like the distinction between (kernel implemented) threads and (language-supported) fibers. In general, D seems like a language that solves yesterday’s problems admirably well, but fails to address modern challenges, like increased memory latencies and multi-processor and distributed programming on the systems programming side, or web, end-user, and domain-specific programming on the application side.
“Learn to Tango with D” is clearly not a beginner’s guide but does a nice job in introducing the language and its library to programmers versed in C++, Java, and C#. Programmers who aren’t familiar with all these languages may find some of the descriptions slightly cryptic, as they assume knowledge of how these features function in another language. The writing is in general clear, though a chapter on the dry subject of procedural lifetime mysteriously appearing in the middle of the book in which the notion of delegates crops up without any prior introduction certainly seems out of place. Furthermore, the explanation of how the novel, interesting, and apparently useful “scope” statement works could be improved: currently the reader is left mystified on whether the statement’s scope is static or dynamic. In addition, the examples used throughout the book, although adequate for the purpose they serve, could be enhanced by being more useful and imaginative. Finally, the book lacks an index, an inexcusable omission in the age of electronic typesetting.
There is still space for a language better than D and for a book on D better than this one. In the meantime, both the language and the book are remarkable offerings.