5 ms·
And C++ is used in so many places on top of that. Every web browser is written in C++. Most GUI systems are written in C++ (or Objective C). All gaming engines
by TwoBit 10y ago
And C++ is used in so many places on top of that. Every web browser is written in C++. Most GUI systems are written in C++ (or Objective C). All gaming engines are written in C++, etc.
- humanrebar 10y agoIt's also my understanding that the LLVM, GNU, and Microsoft C compilers are technically (1) all written in C++. It's also my experience that larger embedded projects also tend to be C++. So maybe your microwave is written in C, but your car's control systems are probably C++, at least in the new parts. (1) So the gcc codebase is almost entirely C but it is compiled as C++. Someone else might be able to explain exactly what features of C++ made this an attractive option . My intuition tells me it has to do with better compiler diagnostics, perhaps involving type checking. I'm on mobile or I would research and provide more authoritative sources.
- shpx 10y agoTaylor's slides list the reasons to commit to writing GCC in C++: C++ is well-known and popular. It's nearly a superset of C90, which GCC was then written in. The C subset of C++ is as efficient as C. C++ "supports cleaner code in several significant cases." It never requires "uglier" code. C++ makes it harder to break interface boundaries, which leads to cleaner interfaces. https://lwn.net/Articles/542457/ https://lwn.net/Articles/542457/
- humanrebar 10y ago> It never requires "uglier" code. Again, I mostly agree with everything you wrote, but this is overstating things a little. Because exception safety can be a little more complicated than it first appears, you do end up having to do a bit more work in C++ in certain cases. One example of this is writing an external ABI in C++. Depending on how nice you want to be to the consumer of your ABI, you might need to add a try...catch(...) to every public function to make sure exceptions don't escape the C++ code. There are also tricky subtleties around writing, say, a swap function in the face of constructors that might throw.
- coldtea 10y ago>One example of this is writing an external ABI in C++. Depending on how nice you want to be to the consumer of your ABI, you might need to add a try...catch(...) to every public function to make sure exceptions don't escape the C++ code. That's not "required" if you write the C++ code yourself though, as you can just refrain from using (throwing) exceptions in the first place. That's what the parent means.
- stephen82 10y agoYou can write exception free code since C++11. All you must do is to add noexcept operator at the end of your function that you don't want to throw an exception and that would do. Also, in the article it states that cars are using C. If I'm not mistaken, Bjarne himself in a couple of videos he has mentioned certain companies, like BMW and Mercedes, are using C++ for their cars and of course these two companies are not the only ones. The good thing is that C++ committee did pay attention to what people and companies have suggested and or complained for years and fixed it with the release of C++11. I really love using C myself, but I wish C had the safety C++ has by default.
- pandaman 10y agoOne can use a compiler switch to disable exceptions in every popular C++ compiler.
- ksec 10y ago>The C subset of C++ is as efficient as C. this.