3 ms·
> Am I predicting the imminent extinction of C? No. For the foreseeable future I think it will retain a pretty firm grip on OS kernels and device firmware. Ther
by Santosh83 9y ago
> Am I predicting the imminent extinction of C? No. For the foreseeable future I think it will retain a pretty firm grip on OS kernels and device firmware. There, the old imperative to squeeze out maximum performance even if it means using an unsafe language still has force.
Rust is well suited for OS code if not for the inertia that most OS devs are experts at C and not so in Rust and compiler support. Those two factors are going to become less important going forward, so Rust (with generous 'unsafe') could replace C in its last stronghold too.
- muricula 9y agoI don’t believe Rust is ready for OS kernels yet. People have written OS kernels but they really stretch the language to do it. For instance, the default heap allocation API panics on failure, which isn’t something I want my kernel to do. There’s work on a new API which doesn’t do this in nightly rust, but they could completely change all that tomorrow. Additionally, alignment constraints are also really important at that level, but rust doesn’t have a mature way to align structures or arrays. Rust isn’t ready for this space yet.
- steveklabnik 9y agoWhen you're writing a kernel in Rust, you aren't using the default heap allocation API; you aren't using the allocation API at all. You could then build any sort of allocation strategy you want. You don't need to wait for the new traits, though of course, using them eventually helps with interoperability. You're certainly right about "mature way" wrt alignment, but it's something that can be worked around until then.
- tetromino_ 9y agoWell, C's default heap allocation API is not suitable for kernel mode either. Compare libc's malloc and the kernel's kmalloc, with the fine-grained control [1] over what kind of allocation to perform. [1] https://github.com/spotify/linux/blob/master/include/linux/gfp.h https://github.com/spotify/linux/blob/master/include/linux/g...