3 ms·
"Rewrote memcached (which I wrote pre-Google) in Google C++" What is diff in 'Google C++' and 'C++'?
by cyanbane 7y ago
"Rewrote memcached (which I wrote pre-Google) in Google C++"
What is diff in 'Google C++' and 'C++'?
- yencabulator 7y agohttps://google.github.io/styleguide/cppguide.html https://google.github.io/styleguide/cppguide.html
- cyanbane 7y agoAhh, so just style changes. TY
- Laremere 7y agoMore than that, the guide limits C++ usage to a safer subset of features.
- bradfitz 7y agoIn addition to style/subset, I also meant using Google's internal standard library.
- erik_seaberg 7y agoC++ relies heavily on RAII. Exceptions are safer than broken instances from failed constructors.
- SamReidHughes 7y agoIn their defense, the style guide says they inherited that from legacy code.
- kragen 7y agoGoogle C++ doesn't allow using exceptions and therefore requires broken instances from failed constructors.
- saalweachter 7y agoGoogle C++ tends towards the convention of constructors that do only cursory initialization to a sane but non-functional state, things that almost-always succeed (and assert on failure), with the "real" initialization pushed to an Init() or Start() function.
- bruckie 7y agoNot these days, although that was true 8-9 years ago. The preferred pattern now is to use factory functions that can return either a fully-initialized object or an error.
- d1zzy 7y agoNot having exceptions doesn't imply that. An alternative is ErrorOr<ReturnType> returning factory functions. It requires that ReturnType is movable tho (can be further wrapped in std::unique_ptr if not). Not every error is exceptional so not every error should use exceptions. This is especially important in lower level code where someone's exception is someone else's expected code path.
- mseepgood 7y agoC++ are many languages in one. It depends which subset you choose.
- Laremere 7y agoIt follows Google's style guide: https://google.github.io/styleguide/cppguide.html https://google.github.io/styleguide/cppguide.html