3 ms·
Rust absolutely benefits embedded software. A big reason is that the type system allows libraries to let you enforce invariants at compile time. For example, y
by nynx 4y ago
Rust absolutely benefits embedded software. A big reason is that the type system allows libraries to let you enforce invariants at compile time.
For example, your i2c controller only supports two specific pins and they have to be in a specific mode? That can be a compile error if you make a mistake.
- allanparthore 4y agoConfiguring pins and peripherals with code is a chore, I use graphical tools for that. But C has no problems abstracting away peripherals, just hide the register bits in a private TU and expose i2c_init(), i2c_write(), etc.
- nynx 4y agoIt’s a chore because the alternative in C is to do things perfectly without the machine doubling checking your work. That assumption does not hold with tools other than C.
- zozbot234 4y ago> just hide the register bits in a private TU and expose i2c_init(), i2c_write(), etc. That's not a zero cost abstraction, unless these "functions" are actually provided in an include file. Embedded programming is often performance sensitive, so this can matter.
- pjmlp 4y agoThey certainly are when LTO and PGO are part of the picture.