3
aviophile
208d

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.

Comments
  • 1
    When you embedded, do you mean "offline linux system" embedded or "bare metal microcontroller" embedded?
  • 3
    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.
  • 1
    @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
  • 0
    Hard disagree on your criticism on Rust but yeah, embedded Rust is a bit sketchy
  • 1
  • 0
    @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.
  • 0
    @aviophile in contrast i had quite a lot of fun with an stm32 and C 😊
  • 0
    @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.
  • 2
    Oh 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.
  • 2
    @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.
  • 1
    @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.
  • 1
    @Geoxion wake me up when all platforms support fully and Rust becomes a stable language, not C++ like feature creeped mess.
  • 1
    @Geoxion i maybe should tbh. I have a spare stm32f407 discovery board flying around, that is yet to find a project 😅
  • 0
    @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 👍
  • 0
    @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
  • 0
    @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
  • 1
    @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.
  • 0
    @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.
Add Comment