Not really sure, though. I'm a mobile dev, and not an embedded dev :D
For "embedded" linux grade CPUs, rust is starting to gain some practical traction. A few years ago the idea of writing application level glue code in it was still a bit silly, but these days it's starting to actually get linked into production systems. It all seems to be done in a way that's interoperable with existing C/C++ codebases, though.
It sounds like you have some experience in this and I have been curious for a long time why Rust can't or doesn't run on almost every micro-controller? Is it based on the compiler? I thought that because Rust has no runtime/produces a binary which does not require a runtime that as long as the Rust compiler emits the right backend instructions it should just work?
Adding to my confusing, I think rustc uses LLVM which is a way of separating a language's frontend from the backend code emitted, so I thought any micro-controller supported by LLVM would work for Rust.
What you're saying isn't wrong, it's just that... embedded development is incredibly diverse. LLVM doesn't support as many platforms as GCC does, and even once LLVM gets support for something, we need to do some work in Rust to get things working; support isn't automatic.
If you get to pick what your hardware is, Rust is fantastic. If you don't get to pick... it's a roll of the dice.
I didn’t know that Rust support for a LLVM target isn’t free and didn’t realize micro-controller targets are so diverse. Very cool.
Also, a lot of embedded code consists of peripheral drivers, and in rust that likely means "unsafe" code. At that point, it's a bit of a wash which language you work in. That's especially true since rust can interoperate with the C ABI.
I haven't familiarized myself with all of rust's built-in data structures yet, and I'm not sure how much stuff necessitates allocating on a heap under the hood. That would be a compelling reason to carefully consider its use in some embedded systems. That's analogous to C++, where it's typical to avoid most of the STL data structures.
You do need some unsafe, but not as much as you may assume at first.
Rust doesn't really have any complex built-in data structures, and doesn't require a heap at all. That's a standard library thing, which you wouldn't be using in this context.
I'm quite intrigued by Zig and am hoping to get in and play with it, since it aims to be a "better C" (not C++) so it remains a small language. See this recent post which triggered my curiosity: https://kevinlynagh.com/rust-zig/
(edit: more thoughts on Zig) I am intrigued because I want out of a new embedded programming language aligns perfectly with their approach. comptime instead of the C preprocessor, generics, any allocation is explicit (any memory allocation is at initialisation time), etc.
EDIT: I'm not sure why you ask that here though. Rust doesn't appear to be mentioned in this post.
> I write our firmware using C. While some might gasp at using such an "old" language, it turns out that the combination of my familiarity with C, the maturity of its resources and tooling, and the low-level nature of writing firmware means that C happens to be a joyful language for me to write firmware in.
Which has the flavor of defending the choice of C as if it weren't the standard choice.
I'm working on a commercial firmware for ATSAMD21 using Rust, and have been finding it quite a nice experience. The tooling is great, PACs and HALs are at least as good as the last time I used the Atmel-provided ones, it's really nice being able to just add a line to Cargo.toml to bring in a library rather than cribbing from a prior project or writing my own.
That said, the Rust HAL for SAMD21 is certainly not complete; I'm working from a forked version of it, and have issued a few PRs to extend/fix it and other libraries. There are a few areas, DMA in particular, where the community hasn't quite decided on the right approach.
While you might find some C++ compilers, most vendors don't have linker scripts that work properly with C++ code, or libraries without issues.