Originally posted by pal666
View Post
Announcement
Collapse
No announcement yet.
Linus Torvalds' Initial Comment On Rust Code Prospects Within The Linux Kernel
Collapse
X
-
Originally posted by Danny3 View PostOk, but how is the code written in Rust compared to C at the performance level ?
Is Rust adding any safety checks at runtime that makes the code slower based on the assumption that the code is badly written ?
- Likes 11
Comment
-
Originally posted by pal666 View Postwell, it has to be disabled by default because gcc 4.9 doesn't support it
- Likes 4
Comment
-
Originally posted by p91paul View Post
A quick Google lookup will teach you that Rust bindgen *understands C headers* and generates Rust bindings from that.
Things like:- C-style callbacks
- Opaque pointers
- Type-casting to first internal struct (poor man's oop)
- Non-owning arrays
- Multi-threading
I don't actually mind rust in the kernel. I am a bit weary of bindings becoming unmaintained and in the way. I honestly think the reason why other languages haven't managed to beat C/C++ in multiple domains is because they don't include the ability to consume C headers. I strongly believe that Objective-C will ultimately outlive Swift for this same reason.
If we can all migrate to Rust as the "defacto native systems language", I will be very pleased! I just think binding generators is the wrong approach and just breeds language package managers like Crates.io, NPM, PIP, CPAN which simply rack up technical debt with dependencies and screw project lifespans and deterministic development.Last edited by kpedersen; 11 July 2020, 12:26 PM.
- Likes 7
Comment
-
Originally posted by kpedersen View Post
It generates "a good start" but for anything remotely complex you need to spend a large amount of man hours to solve.
Things like:- C-style callbacks
- Opaque pointers
- Type-casting to first internal struct (poor man's oop)
- Non-owning arrays
- Multi-threading
Also, there is nothing wrong in calling functions marked unsafe in your driver. You just have to check the functions requirements yourself.
Considering the rest you listed, I suggest you have a look at what GTK did with its rust bindings. They did lots of experimentation how to wrap C stuff idiomatically, but they turned out pretty nice, IMHO. You can even run rust futures (or async functions for that matter) on a glib based executor.
EDIT:
Async functions also work nicely with interrupts. The interrupts can wake some async task when it has new data. The following (from the Writing an operating system in rust blog series) is a good read. They show how to implement a keyboard driver:
Last edited by oleid; 11 July 2020, 01:29 PM.
- Likes 7
Comment
Comment