4 ms·
Slight tangent, is C the only language in the kernel at the moment? (Not including scripts used to build things the kernel.) For example NetBSD has Lua in the
by eatonphil 5y ago
Slight tangent, is C the only language in the kernel at the moment? (Not including scripts used to build things the kernel.)
For example NetBSD has Lua in the kernel and FreeBSD has or had a Forth interpreter in the bootloader.
- geofft 5y agoYes, unless you count the ACPI machine language or BPF, but both of these are languages interpreted by the kernel, not languages linked directly to C.
- vlovich123 5y agoIf I’m not mistake, the BPF interpreter is gone. All those programs are JITed. I don’t know BPF well enough to know, but I suspect you can call kernel C functions from there. Overall though, your overarching point still stands that the Rust development is big in that this marks the first time actual Linux kernel code will be written in a language other than C (or platform-specific assembly).
- wtallis 5y agoThe BPF JIT is still optional. When it is enabled, there is a separate option to disable the interpreter and always use the JIT (CONFIG_BPF_JIT_ALWAYS_ON).
- ncmncm 5y agoRunning eBPF does not involve a JIT at all. The code is compiled to native, if it is, exactly when it is inserted, not when it is first used. Most uses insert code once or at specific junctures, and execution mostly happens at points widely separated from those. People talk about the insertion process as if it were JIT just because it reuses infrastructure originally invented for JIT.
- edgyquant 5y agoYes the kernel is entirely written in C and assembly, there’s a Linus rant about why that is and why he doesn’t want C++ in it. Curious as to what changed his mind about rust
- Yoric 5y agoWell, there's also the BPF. But it's a domain-specific language, by opposition to Rust.
- ncmncm 5y agoNo. eBPF is C++, or Rust, or C, or D, or pretty much any language that can be compiled to LLVM intermediate code and doesn't necessarily rely on a runtime. What can be done in eBPF code is somewhat limited, but nowhere nearso as you might imagine from the restrictions imposed on eBPF programs. Things eBPF code is not allowed to do directly are routinely done in functions eBPF is allowed to call, or in the code that calls the eBPF program in a loop.
- rjsw 5y agoLua in NetBSD is optional. Sun had a research project to put a JVM in the Solaris kernel.
- lenkite 5y agoIf you are talking about the "kernel" in general, then C++ 17 is used as the primary language in the Zircon kernel https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/cxx https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/...
- TheRealPomax 5y agoThat's wasn't the question, though? Zircon is not the Linux kernel.