3 ms·
I agree. I wonder though - why all the rust projects go bare metal, instead of integrating a c based RTOS using rustbingen ? Seems like the fastest way to get c
by petra 11y ago
I agree. I wonder though - why all the rust projects go bare metal, instead of integrating a c based RTOS using rustbingen ? Seems like the fastest way to get cross-platform, which is key for many developers - and speed rust's adoption - making bare metal much easier.
- LBarret 11y agoI think rust people wants to proove repeatedly the addded value of their language : "no cost abstraction over bare metal" because it is the thing that will win the heart of their audience. Still, in practice, it will likely play as you say, but not now.
- rcxdude 11y agoHooking into an RTOS doesn't really give you much cross-platform ability: most RTOS only give you a scheduler and synchronisation primitives, not any drivers. The closest thing to a a cross-platform RTOS I know of is chibiOS, and it supports a fairly low number of platforms.
- antoinealb 11y agoauthor here. My RTOS of choice (ChibiOS) uses a lot of function like macros which are not supported by rustbindgen. Other RTOSes such as FreeRTOS or UC/OS-II would be easier but they don't provide drivers, making them less interesting. If anybody has experience with writing C macros to rust bindings I would be interested in hearing about it.
- petra 11y agoI know that chibi OS is funded by ST(for developing a version for their automotive line of automotive mcu's). Hence why it's only limited to ST platforms(still that's a lot of variety at great price). Maybe they'll be interested in funding rust development? it might give them some competitive advantage, some amount of control of a possible future platform, i.e. rust.
- antoinealb 11y agoI did not know that ChibiOS was funded by ST. I thought they only worked on FreeRTOS (CHibiOS is not limited to ST's MCUs).
- elcritch 11y agoA C based rtos inherits all the difficulties present in C. Ideally Rust is interesting, to me, as an ideal language to write the RTOS itself in. Once you get through the low level details, writing a (simple) schedule system is not hard and would be more flexible due to the better types safety in Rust. Also C is difficult for DSLs, Rust should be better. That's the dream at least.
- petra 11y ago>> A C based rtos inherits all the difficulties present in C. Can you please expand on that, especially assuming(a big assumption) that the c code you're interfacing is high quality , with rare bugs ?
- antoinealb 11y agoEven assuming the existing code is high quality, there is still a lot of problems with pointer ownership and type checking which Rust removes. Personally I think the best way is to wrap existing C code into higher level, safer Rust APIs.
- elcritch 11y agoExactly, even the most disciplined code base will have errors. Rust type system "automates" the process that many well designed C code bases will do by convention (e.g. borrowing and keeping ownership localised). While wrapping C libraries in safer Rust APIs is useful for many application, having something as fundamental as time-sharing, task interruption, etc would be much better if written in Rust and care is taken to define simple semantics for the system (e.g. like the recent HN post regarding state-machine based asynchronous IO in Rust).