7 ms·
Kernel written in C++... The horror.
by sim_card_map 7y ago
Kernel written in C++... The horror.
- snvzz 7y agoDo you care to elaborate? I see no issue in using a fair subset of C++ features in privileged mode.
- DSingularity 7y agoI think most opponents of C++ for OS kernel development take their position because the simplicity of C results allows for pretty straightforward and direct reasoning about the static (asm, obj layout) and dynamic properties (memory allocations, procedure invocation, etc) of their code. Both C++ and our tooling has come a long way — not to mention a change in the nature of the challenges of kernel development/performance. I think most of the old arguments against C++ have lost their edge.
- cameronbrown 7y agoThough it is fun to rag on C++ every now and again, I believe Google's C++ style guide is a subset of features (classes, no exceptions, subset of boost,..). Most C++ issues come from using every feature under the sun and accumulating loads of technical debt instead of picking one tool and sticking with it.
- PyroLagus 7y ago> Though it is fun to rag on C++ every now and again, I believe Google's C++ style guide is a subset of features (classes, no exceptions, subset of boost,..). Which is the same thing Genode does[1], and it has served them well. Maybe a different language like ADA/SPARK or something else would have been better, but C++ was what they're familiar with, so they made it work. Although I like Rust, it's a bad argument here. Rust has been changing a lot and is still changing, and Fuchsia wasn't started yesterday. And with C++, you could even replace critical parts with formally verified LEAN[1], which has C++ code generation and should be even safer than Rust. [0] https://genodians.org/nfeske/2019-01-22-conscious-c++ https://genodians.org/nfeske/2019-01-22-conscious-c++ [1] https://leanprover.github.io/ https://leanprover.github.io/
- steveklabnik 7y agoDon’t forget that Fuchsia also has a lot of Rust in it already. These things don’t have to be either/or.
- fithisux 7y agoC++i is excellent when you have a large code base. But if you have a large code base for a driver or a stack, you have already lost.
- sk0g 7y agoLet me guess, you're a Rust 'evangelist'? And enjoy ragging on one of the most important programming languages that basically has a monopoly on entire industries?
- DSingularity 7y agoIt’s also possible that he formed his opinion based on the context of 20 years ago which has since changed into the reality we have today... Discourses become much nicer when we don’t make/take such explicitly negative angles which are rife with hostile undertones.
- sk0g 7y ago"Kernel written in C++... The horror." What kind of discourse is that leading to? It's just an unqualified, unsubstantiated attack on serious work undertaken by presumably top quality engineers.
- dodobirdlord 7y agoIn fairness though, it's kinda the stance taken by top quality engineers themselves when faced with the prospect of writing a kernel in C++. The Google C++ style guide is pretty rigid, and is pretty upfront about the fact that the rigidity is in the interest of not allowing Google C++ projects to devolve into the mess that consumes most large C++ projects.[0] Linus Torvalds has in the past said some pretty unkind things about the idea of doing kernel development in C++.[1] Finally, Fuchsia's kernel Zircon is a microkernel. The engineers involved have elected not to attempt to write a monolithic kernel in C++ probably in part for the reasons that Torvalds described. Things like filesystems, drivers, and the networking stack are outside of the Zircon kernel in the Garnet layer and are implemented in languages like Rust (filesystems, drivers) and Go (the networking stack). [0]https://google.github.io/styleguide/cppguide.html https://google.github.io/styleguide/cppguide.html [1]http://harmful.cat-v.org/software/c++/linus http://harmful.cat-v.org/software/c++/linus
- pjmlp 7y ago
- orbifold 7y agoSuper sane choice, C has had its time, Rust is an improvement over C++, but lacks higher kinded types and other niceties that are easy to implement in C++. C++ is also used in a large number of projects that fuchsia needs to interface with, such as skia, the graphics stack and so on. This is one of fuchsias competitive advantages. Moreover FIDL (fuchsia interface description language) allows for components to be implemented in a number of other languages.
- wyldfire 7y agoYou could sanely use namespacing and other simple mostly lexical / mangling features that help manage the codebase while adding negligible complexity.
- drewm1980 7y agoThey seem to see it the other way around. Most things are "hermetic C++" that export only a C interface. Which is to say they tame C++'s complexity not only by using a very restricted subset, but also by not letting ~any C++ stuff cross API boundaries.
- pjmlp 7y agoJust like Symbian, BeOS, newer parts of IBM mainframes, macOS/iOS drivers, Android drivers post Treble, Windows since Vista, Genode, Arduino,... C can stay with classical UNIX.