Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
When you embedded, do you mean "offline linux system" embedded or "bare metal microcontroller" embedded?
-
how rust is envisioned is actually quite nice. But C is the way to go on microcontrollers, atleast for me personally.
Saying that that i have yet to discover developing for embedded stuff with rust. -
@thebiochemic for micro controllers I'll also stick with C I reckon
The stuff make on those is typically arduino (which is actually C++) and tends to be super simple.
I dont get why arduino is using C++ though, like just for singletons?
You dont have the stl so you can't use something like a std::array so I dont see the big benefit in that -
@thebiochemic tried with stm32. The libs are there but it is a mess of chain calls ending with unwrap. Rust isn’t a good fit for that domain.
-
@aviophile yeah for bare metal I'd probably stick with good ol' C
Unless maybe you had multiple cores? Some of rust's sync stuff is in core:: so you could use it there too.
As for the error handling, I disliked too initially, but I've grown to like it.
If I do run into the situation of unwrap chains I'd prefer returning a Result/Option and using the ? operator. -
Geoxion9012yOh well, then I'll tell my full-time embedded Rust colleagues to stop working on our projects 😉
If you tried embedded Rust before 2019, you should try again. It has improved massively!
But yeah, the only thing that really lacks is official vendor support. Espressif is working on it right now and Nordic had a job opening that desired Rust experience. So it's definitely going in the right direction. -
Geoxion9012y@LotsOfCaffeine Rusts Sync + Send abstraction is also very nice when dealing with interrupts. To share data you must either use Atomics or some Mutex. If you know it's safe to access you can use unsafe as well, but there are nice libraries so you can avoid using unsafe.
For example, there's a library with which you can move data into a container that can only be accessed from a specific interrupt. That way you never have a race condition.
There are also entire frameworks like RTIC that do all of this for you. -
@LotsOfCaffeine see, the problem is there are tons of ways to handle errors which you will forget the syntax for, in a week or so. Rust will become like C++.
Shoot me if I ever pollute embedded software with multithreading also. ISRs are acceptable. -
@Geoxion wake me up when all platforms support fully and Rust becomes a stable language, not C++ like feature creeped mess.
-
@Geoxion i maybe should tbh. I have a spare stm32f407 discovery board flying around, that is yet to find a project 😅
-
Geoxion9012y@aviophile Rust has been a stable language since 2015.
And you don't need all platforms to be supported. The only platforms you need is the platform you're using.
For me (and many others) that's Cortex-m and it works great 👍 -
@aviophile tons of ways?
Rust only really has one error mechanism, the Result<> or Option<>
You have to unwrap it somehow
Either with dedicated checks like Some()
Or directly using .unwrap which will just crash if things go wrong
Or by using ? and propagating any error, similar to exceptions
I think its a pretty elegant system, the syntax is either a regular function call, or the ?. which is similar to C# (they do this for null checks there)
And well, some applications will need a second "thread". I haven't done one of those myself though -
@LotsOfCaffeine unwrap, expect brothers, matching result with err or ok, ?, some. A single rust feature has more complicated syntax then all C syntax combined. There is even errorchain crate
-
@aviophile its literally functions and one (1) operator
Syntactically its dead simple.
Whether you like that feature or not is a different story of course, but the syntax is everything but complex. -
@LotsOfCaffeine syntax, way of doing things, whatever you call it. Rust seems more and more like cpp with facelift and it is also a religion, unfortunately.
Experimented with embedded Rust. Fuck that. C is a brilliant small language. Trustworthy. Rust is just C++ killer, it doesn’t belong in embedded domain. Bloated syntax, verbose error handling, crap quality crates with little to no documentation.
rant