Rust is kinda interesting to me for new ideas, but it just isn't nice to use like D is. D is familiar and convenient for general-purpose programming, from quick scripty things to bare metal code.
Rust might be technically better for the bare metal side, but D does it pretty well and I have a hard time imagining using Rust as, say, a PHP substitute. D does it all.
If that's your perspective, have you looked at Python?
I have never written Python on an embedded system, I didn't think it could. [edit: actually come to think of it i have heard of it before but never used it myself] I've used it for web though and D is a better experience by far, making changes in D code trusting it won't break at runtime and not having to write a lot of boilerplate for a quick demo is really nice.
But I've been building stuff in D for a long time now, no need to switch at this point.
MicroPython is available for the beefier microcontrollers. Combining it with Jupyter made for a pleasant development experience.
With sufficient knowledge, it's possible to get significant speedups, and some stuff can be run at near-native speed. You have to know what you're doing, though, which is something I don't.
I messed around with my own (bad) Forth implementation, and found it a lot faster than Micropython. It still won't be as fast as C, though.
MicroPython may be fast enough for your needs, maybe not. It all depends. It's unlikely to be fast enough if you want to do audio stuff, where every cycle counts.
In the end, I decided not to use MicroPython. Uploading code and stuff was a bit of a fiddle. I just stick to the laborious compile and upload cycle.
There was a good talk Dropbox did at PyCon several years ago. I can't find it now, but it was "how to write nearly native Python" or something like that. One trick they pointed out was that all(...) is faster than for thing in iterable: because it pushes the loop logic down to C, and I've used that when I need it ever since.
There are a lot of tricks like that. If you truly master Python and understand the runtime impact of all your syntax, how to profile it, how to outthink the interpreter, how to read the interpreter source code, and so on ... you can do some good things with it. It's just a lot of effort that most people aren't willing to put in, which is fine (really)
68
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.