6 ms·
The folks behind the Pistachio microkernel said they used C++: https://github.com/l4ka/pistachio https://github.com/l4ka/pistachio I don't know if it has exce
by nickpsecurity 7y ago
The folks behind the Pistachio microkernel said they used C++:
https://github.com/l4ka/pistachio https://github.com/l4ka/pistachio
I don't know if it has exceptions or an unusual style since I don't know C++. It is written by CompSci researchers which usually means a different style. Just throwing it out there for anyone considering C++ in kernels since the L4 kernels were all really fast and lean.
- kevin_thibedeau 7y agoAnd Google merrily uses C++ with exceptions disabled. That doesn't make it right when the shit hits the fan. "Works most of the time" is not acceptable in an OS.
- nickpsecurity 7y agoYour statement equates not using exceptions with no error handling at all. Are exceptions the only way C++ can handle errors? Or can it do things like return codes used in C or advanced constructs via its metaprogramming?
- tomjakubowski 7y agoYou can use error codes or, better, a Result<T, E> template in C++, but throwing an exception is the only sane way to signal an error from a C++ constructor that I know of. The alternatives are awkward: you either stick an error code on the struct, which the caller can check after construction, or write an error code to the caller through an out parameter. In either case, the class implementation now must be concerned with handling objects in some partly-initialized, "error" state.
- ncmncm 7y agoError handling without exceptions tends to 3x to 5x as much raw code, with corresponding numbers of errors and poorly-exercised paths. Exception paths rely mostly on destructors which are otherwise well-tested in normal operation.
- kevingadd 7y agoWould you seriously argue that "works most of the time" does not describe C? Or are you just saying that accepting it for another language is not okay, and anything new allowed into the kernel needs to be perfect instead of just better than C?