4 ms·
Well, Google is writing a new kernel (for Fuchsia), and it is written in C++.
by sanxiyn 5y ago
Well, Google is writing a new kernel (for Fuchsia), and it is written in C++.
- vlovich123 5y agoFuchsia is a micro kernel. The core kernel bit is written in C + ASM as Rust wasn't ready at the time. The various ancillary pieces that make up the OS (e.g. filesystem, drivers, etc) are written primarily in Rust. C++ I believe had been used but as Rust has matured and evolved that's gone away for the most part.
- sanxiyn 5y ago> The core kernel bit is written in C This is untrue. Where did you get it? Have a look at kernel scheduler written in C++ here: https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/zircon/kernel/kernel/scheduler.cc https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/z.... constexpr! namespace!
- vlovich123 5y agoOh huh. It must have moved on significantly from when I last looked at it years ago. It started of based largely on LK work. If you look at the old code [1], it has a C++ extension & is likely compiled with a C++ compiler but the code itself is really just C. That's why cloc sometimes isn't an accurate tool for these. I don't have a sense of what the policy is but they could still be sticking with the C convention w/ C++ only utilizing things like constexpr & various other compiler pieces. They do seem to be making use of templates so it looks like there's been a lot more modernization done there. [1] https://fuchsia.googlesource.com/fuchsia/+/9c7855e320662ad909903d2bef6a8e7c23dd5d90/zircon/kernel/kernel/sched.cc https://fuchsia.googlesource.com/fuchsia/+/9c7855e320662ad90...
- jyounker 5y agoIt would be wise not to confuse C++ at Google with C++. Google has extremely strong internal coding standards. Those standards restrict which C++ features can be used, and how and where those C++ features can be used. Without compliance based upon paycheck and performance reviews, I'm not sure that I'd want to try to make that kind of selective enforcement work.
- nybble41 5y agoRust makes up the majority of the current Fuchsia code on the main branch (2.6M lines), at least according to `cloc`, but there are more lines of C++ code (1.6M) than plain C, assembly, and C/C++ headers combined (0.95M). And that's very generously assuming all those headers are compatible with C and not just C++. ------------------------------------------------------- Language files blank comment code ------------------------------------------------------- Rust 11813 339160 541958 2661720 C++ 9207 344592 198973 1632916 Go 2906 81163 138138 608871 C/C++ Header 7544 156294 209786 559658 C 1680 49614 52841 260405 Assembly 322 18112 11620 133536 ------------------------------------------------------- Header + C + Assembly 9546 224020 274247 953599