3 ms·
Well yes. But Linus is right on that one. I wouldn't say Windows drivers were C++, more like "C with Classes" (and maybe a little bit C++) Also, Windows drive
by raverbashing 5y ago
Well yes. But Linus is right on that one.
I wouldn't say Windows drivers were C++, more like "C with Classes" (and maybe a little bit C++)
Also, Windows drivers are usually much more convoluted than Linux drivers https://github.com/microsoft/Windows-driver-samples https://github.com/microsoft/Windows-driver-samples
- pjmlp 5y agoLinus is only right for those that share the same opinion. Anything that uses 1% of C++ specific features is C++. C as used by Linux kernel is not ISO C, yet no one argues it isn't C.
- raverbashing 5y ago> Anything that uses 1% of C++ specific features is C++. Technically correct and this raises an important point. How long would the kernel take to compile in C++ versus in C? Though in practice if you think the kernel should support all the craziness of "modern" C++ you're going to have a big problem in making it work in kernel space. (things like heavy templates, etc) And just to disagree with Linus I think the 'new' part is the least of our problems in making the kernel work with C++
- pjmlp 5y agoApple, Google and Microsoft do just fine without modern C++ craziness in kernel and drivers. As for compilation times, it is all a matter of how the build system is architected. Most of my C++ build pipelines compile faster than Rust, in make clean all scenarios. There is no black magic in how to achieve it, just knowing what one is doing, making use of binary libraries, build caches, and be aware of how much craziness is allowed, most of which wouldn't be allowed on the kernel anyway.
- volta83 5y agoAll my rust projects (>1 million LOC at this point) compile 10x faster than our C++ code base ever did (300k LOC and shrinking, used to be 900k LOC c++ but over the last 4 years all new functionality has been rust, and every substantial fix of existing functionality has resulted in rewriting C++ code to Rust). How to do this is surprisingly easy: write small crates that do 1 thing. A Rust crate is a C++ TU, pretty much everybody that complains that Rust is slow is comparing Rust crates that are 10-100x larger than the size of the .cpp files they use in their C++ projects. For some reason, people, and particularly C++ devs, like to write huge Rust crates (I’ve seen crates with 200k LOC). They’d never write a 200k LOC .cpp file, so I really don’t get why they do this. Either way, if your Rust compile times are slow, it’s probably your and only your fault. How to get blazing fast Rust compile times isn’t a secret. We have a lot of data of the time it took to compile C++ TUs vs the equivalent Rust crate, and Rust reliably compiles at least one order of magnitude faster, sometimes two. All our crates are less than 10kLOC, median is 1812 LOC. Rust crate binary compatibility is also pretty awesome, so that in general a new hire does not need to compile anything at all (an unmodified build just fetches binary objects from sccache). When they start modifying the project, only those binary objects that actually changed have to be recompiled, the rest is just dynamically linked. This gives you <5s edit-compile cycle if you are working on a leaf crate.
- pjmlp 5y agoNow go around and apply the same build optimizations to the C++ source base, including the use of incremental compilation, incremental linking, pre-compiled headers, export templates in TU, making use of lib files. If your C++ compile times are slow, it’s probably your and only your fault.
- volta83 5y agoOur C++ code base has been using Clang modules and all those optimizations (explicit template instantiations, incremental linking, dynamic libraries, etc.) since 2011.. It also supports unity builds, and C++ modules TS, so we can compare the performance of all 3 approaches Rust consistently beats all of them by at least an order of magnitude in apples to apples comparisons, with at least an order of magnitude less fiddling in terms of modifying the source code, fiddling with build system and compiler options, etc. So in our experience, Rust gives you 10x faster compile times with 10x less effort than C++ if you use similarly sized compilation units. Rust makes it easy to write compilation units that are 10x-100x faster than C++ ones and still compile reasonably fast for their size, but we don’t allow this by convention (we have a clippy lint that rejects crates that are too large).
- gnull 5y ago∀ X, X is right for those who share the same opinion. If you think a simple tautology disproves someone's claim, there's a good chance you're missing the point.