3 ms·
The C++ you end up with by following Google's style guide is more of a "C with classes" thing, they prohibit several central features of C++. That said, I under
by fhd2 13y ago
The C++ you end up with by following Google's style guide is more of a "C with classes" thing, they prohibit several central features of C++. That said, I understand that they mostly do this to be consistent with their older code bases.
But it's not exactly a style guide I'd follow strictly in a new project/team.
- bjz_ 13y agoThe Google style guide could help explain why the Go team thought that their language would make more of an impact in C++ land than it actually did.
- dsymonds 13y agoNope. Go was born because large C++ builds were just too darn slow, but that wasn't due to using a restricted subset of C++. In fact, using a subset of C++ speeds the build up.
- brianpgordon 13y agoYou're right on the money. This passage is particularly damning: > Rvalue references encourage a programming style that makes heavier use of value semantics. This style is unfamiliar to many developers, and its performance characteristics can be hard to reason about. It's like, do you know C++ or don't you? Value semantics are C++.
- fauigerzigerk 13y agoThey are right that it's harder to reason about value semantics. The cost of passing a pointer is always the same whereas the cost of passing a value isn't. But I don't think that's a good enough reason not to prefer values considering the performance and memory usage drawbacks of shared_ptr. unique_ptr is often the best solution in my view.
- MichaelMoser123 13y agoActually they do prohibit those features that arguably cause more damage than benefit. c++ exceptions? in an unmanaged (runtime engine not managed by some sort of VM) language you can't really assume anything when an exception occurs, you can't assume that you will be able to allocate more memory from the heap, for instance - if the heap is corrupted then this will just not work. RTTI ? it costs a lot, well and you can do without it; Besides requirement of RTTI (assuming that the library does RTTI) will prevent you from using third party libraries that might be of use. Resolution: skip.
- jsnell 13y agoIt's a totally reasonable style guide to adopt with a new project / team. And in fact it's what I chose the last time I started a team doing systems programming. It's well reasoned, and hits my personal sweet spot for the power vs. complexity tradeoff. C++ has a pretty bad reputation. Possibly deservedly. So unless everyone has already bought fully into C++, the full language is a very hard sell. But C with a few extra conveniences and safety features (strings, unique_ptr, some limited polymorphism) is a much easier one.