Comment by 10000truths

3 years ago

C is valuable because it puts an emphasis on ABI. In that sense, it’s a gentle introduction to assembly - functions map 1-to-1 with generated subroutines (modulo inlining), and no monomorphization/templating encourages code reuse at the instruction level. Those philosophies are important stepping stones to understanding concepts like dynamic linking, calling conventions, how registers behave, etc.

Of course, you could emulate this behavior with Rust using extern and unsafe and whatnot, but the affordances of Rust steer you away from those details in favor of the higher level abstractions it offers. Which is what you want for 99% of software development, but when you’re writing platform specific code (e.g. OS startup, context switching, optimized SIMD) that a compiler can’t reliably generate, it helps to be able to quickly prototype something with C and then tweak certain instructions in the generated assembly subroutine until you get what you want.

You can write Rust in a C-like style, without generics and without traits. The output assembly will likely match the C output too.