(Warning, this is somewhat of a blog post. You can safely skip down to the question at the end if it bores you.)
I've been playing around with the D language for the past couple of days, and I have to say I'm very impressed. My interest is twofold: I'm looking for a language to write my web framework in and I'm interested in using it with Allegro.
For web programming, I've come from a heavy background in scripting with classic ASP (ugh) and PHP. While I like PHP a lot, it (and haphazard scripting in general) breaks down for large scale, framework style of applications. That's not to say it's out of PHP's league, but one can only take so much of the $this->foo syntax before officially going insane. And I've never cared much for Java, so I haven't even given C# a chance.
Unlike Java, D compiles to native code and can (almost) directly interface with C libraries (hence, DAllegro). The first thing I did was create my own wrapper class around libmysqlclient to mimic the style of database access I've come to enjoy with PHP. A side by side comparison:
$db = new DB(); DB db = new DB();
$db->execute("UPDATE foo"); db.execute("UPDATE foo");
$foo = $db->getOne("SELECT foo"); char foo = db.getOne("SELECT foo");
$row = $db->getRow("SELECT *"); DBRow row = db.getRow("SELECT *");
echo $row['foo']; writef("%s", row["foo"]);
foreach ($db->getAll($sql)) as $row) foreach(row; db.getAll(sql))
echo $row['foo']."\n"; writef("%s", row["foo"]);
Obviously C++ can do the same thing, but D is so concise. While I sometimes use C++ for the STL, it is so ugly...
The nice thing about writing in D, as opposed to PHP, is you can bind results directly to variables (without having to go through some invisible conversion):
DBStatement st = db.prepare("SELECT id,name FROM foo");
writefln("Person #%d's name is %s.", id, name);
D can pretty much do everything PHP can do right out of the box, which is impressive considering that it's a compiled language. (Obviously, I'm talking about core language features, not the plethora of PHP C Modules.)
// associative arrays
foo["pizza"] = 1;
// dynamic arrays
foo ~= 1; // foo = 1
While D has no "string" object, it doesn't really need one because of how flexible the arrays are.
foo = "Hello";
foo ~= ", World";
For a test, I translated the a.cc database indexer line by line from PHP to D. On my Linux VM, it ran almost twice as fast. On the live server, it actually runs the same speed, but it's possible that the database is the bottleneck. Of course, I'm also doing some PHP-like things, so that doesn't help D out.
All-in-all, it really seems nice. In fact, I'd say that D is what C++ should have been. Everything it does is so simple compared to C++...
The Question at the End: Does anyone here use D? Have any favorite features or gripes to share? Why, except for legacy and maturity purposes, would anyone use C++ over D? (I realize it doesn't have many tools, IDEs, etc... I'm asking about the language itself.)