Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

JR via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 10 06:22:33 PDT 2014


On Monday, 7 July 2014 at 23:47:26 UTC, Aerolite wrote:
> So, if you would be so kind, give me a bullet list of the 
> aspects of D you believe to be good, awesome, bad, and/or ugly. 
> If you have the time, some code examples wouldn't go amiss 
> either! Try not to go in-depth to weird edge cases - remain 
> general, yet informative. E.g. I consider D's string mixins to 
> be in the 'awesome' category, but its reliance on the GC for 
> large segments of the standard library to be in the 'ugly' 
> category.

I'm a big fan of (templated) UFCS. Along with parameterless 
function calls it goes a long way toward improving readability 
with its pipe-like flow. And like with all templates, allowing 
for breaking out common functionality *without* resorting to 
inheritance. Templates overall are sexy.


void main() {
     import std.stdio;
     import std.conv;
     import std.string;
     import std.range;
     import core.thread;

     // values known at compile-time --> CTFE kicks in~

     static assert(12345.to!string == "12345");

     immutable period = 1.seconds + 100.msecs + 100.usecs;
     writeln(period);
     Thread.sleep(period);

     immutable line = "fedcba"
         .retro
         .to!string
         .toUpper;

     // wish this worked: typeof(line).is!string;
     static assert(is(typeof(line) : string));
     static assert(line == "ABCDEF");
}


More information about the Digitalmars-d-learn mailing list