3 ms·
Yeah, the "driver" parts of Mac OS X -- the bits that aren't Mach or BSD -- use a restricted subset of C++. It doesn't carry over into userland. Not much, anywa
by jjoonathan 5y ago
Yeah, the "driver" parts of Mac OS X -- the bits that aren't Mach or BSD -- use a restricted subset of C++. It doesn't carry over into userland. Not much, anyway.
I know that C++ is out of vogue, but last time I wrote drivers in linux and OSX (10 years ago) I left with the distinct impression that it was oversold, at least compared to C. C clunks hard and C++ addresses the worst of it. I've never had to corral a bunch of overzealous junior C++ programmers, which I suspect is where the C++ reputation comes from, but Apple went down that path and wound up with something pretty decent.
IMO today it's a shrug and 25 years ago it was forward looking.
- zozbot234 5y agoLinux devs are working to support Rust, which is a lot cleaner than C++ (essentially, no implementation inheritance) and has more straightforward interfacing with C components.
- StillBored 5y agoSelective implementation inheritance is actually quite useful for kernel/driver development if its used where function pointers in C tend to be used. Pluggable interfaces. It standardizes the syntax, provides default implementations, and forces implementation of mandatory methods. C++ when used as a better C, really is better.
- zozbot234 5y agoPluggable interfaces are ok, and Rust supports them just fine via traits. Actual implementation inheritance is inherently anti-modular.
- jjoonathan 5y agoI'm not convinced that "no inheritance" is better -- drivers seem to be one place where it's actually put to good use -- but I also don't think it really matters that much. In contrast, Rust definitely has fewer foot-guns, and that matters a lot. Of course, the OSX driver code is going on 25 years old, so it's not evidence of anyone's opinion that C++ beats Rust for OS dev.