5 ms·
We have to rule out any language with a garbage collector. C++ adds about as much negative as positive to be worth while. That doesn’t leave many other options.
by goalieca 5y ago
We have to rule out any language with a garbage collector. C++ adds about as much negative as positive to be worth while. That doesn’t leave many other options.
- sanxiyn 5y agoC++ would be a clear win on net. Anyone thinking otherwise, even if they are Linux developers, are wrong.
- loeg 5y agoIt’s fine to have opinions, but you’re stating them as if they’re fact. The Linux kernel maintainers disagree with you. They’re experienced engineers, and ultimately, they make the rules.
- sanxiyn 5y agoC++ is the industry standard, C is a retrocomputing language. Everyone is using C++, except for legacy codebases and some recalcitrant FOSS maintainers. Of course Linux is maintained by Linux maintainers, I am just pointing out they are against industry consensus.
- adgjlsfhk1 5y agoThe industry isn't typically writing kernels.
- sanxiyn 5y agoWell, 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
- czynskee 5y agoMac and Windows kernels are also written (predominantly) in C. So not sure what industry you're referring to. If anyone's interested - here's Linus on C++ in the linux kernel: http://harmful.cat-v.org/software/c++/linus http://harmful.cat-v.org/software/c++/linus
- secondcoming 5y agoThat was written in 2007
- pjmlp 5y agoMac drivers (which run on kernel space) are written on a C++ subset. Windows has been slowly migrating to C++ since Vista, when VC++ got kernel support for C++ code, naturally one just doesn't move something like Windows to C++ just like that. https://community.osr.com/discussion/291326/the-new-wil-library-for-c-code-in-drivers https://community.osr.com/discussion/291326/the-new-wil-libr... > First off, let me point out that this library is used to implement large parts of the OS. There are hundreds of developers here who use it. So unlike, uh, some other things that get tossed onto github, this project is not likely to wither and die tomorrow.
- kaba0 5y agoThat website is the stupidest shit though. They should be playing with rocks with that stupid ultra-minimalistic bullshit they spew. Also, both windows and mac has considerable and growing amount of C++.
- fault1 5y agoI would say for lower level code, when C++ is used, it's a C-like dialect of C++ that is used. This is even true with something like clang and llvm. Certainly the /more/ low level you go, the less C++-isms you see. These days, sure you can use a highly restricted form of C++ in systems close to HW, but you might as well be using the industry standard in those environments, which is C, compiled with a C/C++ compiler.
- pjmlp 5y agoAUTOSAR is an industry standard that requires C++14, in the process of being ratified for C++17.
- mlindner 5y ago> C++ is the industry standard, C is a retrocomputing language. You'd be surprised how many fortune 500 software companies have thousands of programmers who are writing new C code every day. Even Apple writes new C every day.
- yakubin 5y agoOk, now it's my turn: C++ would be a clear loss on net. Anyone thinking otherwise, even if they are Linux developers, are wrong. Now that was productive.
- rhinoceraptor 5y agoI think the main issue with C++ is just that C++ is not one thing. Everyone has a different idea of which of the incredible number of features added over the years are good, and which are footguns. Obviously many of the features of C++ are incompatible with kernel development, since C++ is designed to be used for applications, not kernels.
- jll29 5y agoExactly. Very well said - in other words: C++ is NOT ORTHOGONAL, whereas C is. C++ is also an evolving monster that everyone uses different subsets of, and many developers only know or use subsets of, either for lack of expertise or out of conviction (see how polarised the discussion of exceptions in C++ is here). And every five years, even more complexity gets added, making the C++ story a modern PL/1-like story. For many decades, there were also substantial differences in compiler maturity, forcing many to rely on subsets artificially.
- kaba0 5y agoBut C is so small that every project will use their own under-specified conventions with no documentation, no tooling, etc. At least C++ language features will have proper documentation, not this “if we place a struct inside this one at a specific place, we can use it as a linked list for no added memory cost” shit that one must know for each and every project (and is error prone).