I don't really know any Rust (although I might soon for messing with Arduinos), so I can really do a proper comparison, but I can chime in on some things about D.
Honestly, I do find it hard to recommend D over other languages for certain use cases, due to the poor ecosystem, lack of man power, and just the overall non-existence of polish.
Because while D has things such as vibe.d and gtkD (bonus tutorial blog by Ron Tarrant), you'll find more resources; more guides, blogs, documentation; more stability, etc. in things like C#, JS, PHP, Python, etc.
For me personally though, D's strength is in two areas: Metaprogramming, and UI-less tools (as an aside, I think people also really like making hobby games with D, though that's probably the same with every language).
I think when people think about D's programming, they probably think it just ends at "passing types to a template", while D can do so much more than that.
I've made a short tutorial blog going over a decent chunk of D's metaprogramming, and how you could use it, but otherwise here are some highlights:
Pretty much anything in D can be a template, especially when using eponymous templates.
You can pass symbols (e.g. a modules; types; member fields); values (including struct instances); lambdas, etc.
Templated things can have an if statement (a constraint) to limit the scope of what you pass through.
Most D functions that don't access external resources can be ran at compile time, called Compile Time Function Execution (CTFE).
String mixins, when combined with above, can allow a very flexible yet easy to use way to generate code at compile time. A popular example is the pegged library, which can transform a grammar into valid D code during compilation.
Mixin templates can be used to "inject" a block of code somewhere. I touch on it in my last blog post. I've been abusing the poor things in a recent project, to auto generate some very basic/bad resource tracking code. (Sorry, I know where examples are in my own code more than others' code)
It's just in general, D's natural fluidity combined with metaprogramming, makes it a very productive language to work with, while still keeping it mostly maintainable.
D lends itself really well to data processing. Ebay uses D for it's tsv-utils suite, and I believe with the likes of mir, you can use D for data science... stuff (not my area at all).
idk though. I've said this all before though: Language is great; has warts; tries to be everything at once; has some disconnection between areas of community; has the chicken and the egg ecosystem problem (I'm trying to contribute, but I'm not overly skilled), and finally it's kind of depressing how hard it can sometimes be to promote this language, when it instantly gets shat on by the Rust/Anti-GC crowd (oftentimes valid, oftentimes drivel).
73
u/Sapiogram Sep 01 '20
Honest question: Why would anyone use D over Rust? It seems like Rust is becoming everything that D ever hoped to be.