TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Google C++ style guide

39 点作者 degio大约 11 年前

15 条评论

fhd2大约 11 年前
The C++ you end up with by following Google&#x27;s style guide is more of a &quot;C with classes&quot; 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.<p>But it&#x27;s not exactly a style guide I&#x27;d follow strictly in a new project&#x2F;team.
评论 #7564911 未加载
评论 #7565118 未加载
评论 #7565143 未加载
评论 #7566198 未加载
shmerl大约 11 年前
<i>&gt; Functions should start with a capital letter and have a capital letter for each new word. No underscores.</i><p>Why so? It&#x27;s Java-ish. Java favors camel notation for some historic reason. C++ on the other hand favors snake notation which is clearly reflected in stdc++. Snake notation is also easier to read, especially if the name contains many words in it. Of course in the end it&#x27;s a matter of preference, I just wonder why Google mandates camel notation.
评论 #7565025 未加载
评论 #7564972 未加载
ajtulloch大约 11 年前
For those who are unaware, `clang-format` (<a href="http://clang.llvm.org/docs/ClangFormat.html" rel="nofollow">http:&#x2F;&#x2F;clang.llvm.org&#x2F;docs&#x2F;ClangFormat.html</a>) can be used to automatically convert existing C++ code to a given formatting style (Google, LLVM, a custom style, etc).<p>It&#x27;s similar to `gofmt` in the golang world, and is a really useful tool for enforcing these kind of style guides.
mmaldacker大约 11 年前
No lambdas allowed? For many other things they say &quot;use within reason&quot;, I don&#x27;t see why they can&#x27;t say this for lambdas. They&#x27;re finally making the stl algorithms easily usable. You don&#x27;t have to write Functors that are in a different place then called.<p>Also, the guide seems to completely miss templates and actually pretty much allow everything in C++ (except lambdas and exceptions). I don&#x27;t really see the point then.
评论 #7564683 未加载
评论 #7564845 未加载
评论 #7564669 未加载
NickHolt大约 11 年前
There&#x27;s a few style guides up the path for those interested: <a href="http://google-styleguide.googlecode.com/svn/trunk/" rel="nofollow">http:&#x2F;&#x2F;google-styleguide.googlecode.com&#x2F;svn&#x2F;trunk&#x2F;</a>
greggman大约 11 年前
As an x googler I had my issues with it<p><a href="http://games.greggman.com/game/lets-debate-coding-style/" rel="nofollow">http:&#x2F;&#x2F;games.greggman.com&#x2F;game&#x2F;lets-debate-coding-style&#x2F;</a>
eksith大约 11 年前
&quot;Use only spaces, and indent 2 spaces at a time.&quot; Of course you realize, this means war.<p>Much like all other style guides I&#x27;ve come across, there are a lot of hints that I&#x27;ll find helpful and encourage at our next meetup, but honestly, the only style guide that truly matters is the one you can all agree to in your team and makes sense in your context.<p>And, I&#x27;m not sure if this is just those who share the same water cooler, many C++ devs seem to dislike using STL. I can&#x27;t figure out why.
评论 #7565434 未加载
cubbimew大约 11 年前
It doesn&#x27;t get any worse than that guide (except maybe EC++ or the FQA). No RAII, no class invariants, no value semantics, no streams, no operators (which means no custom Iterators, EqualityComparable or even CopyAssignable types! Such a basic feature called &quot;insidious&quot;). Not even mentioning the FUD about newer C++ features.
nemasu大约 11 年前
I love C++, I wish there was more work available that used it. EDIT: Clearly my issue is where I lived, not the lack of available jobs apparently.
评论 #7565158 未加载
评论 #7564896 未加载
评论 #7564898 未加载
评论 #7564787 未加载
评论 #7564912 未加载
评论 #7564775 未加载
评论 #7564874 未加载
patchhill大约 11 年前
Looking at this style guide as a C++ programmer, I&#x27;d hate to work at Google.
joshvm大约 11 年前
FYI, the lint tool referenced in the guide is found here:<p><a href="http://google-styleguide.googlecode.com/svn/trunk/cpplint/" rel="nofollow">http:&#x2F;&#x2F;google-styleguide.googlecode.com&#x2F;svn&#x2F;trunk&#x2F;cpplint&#x2F;</a>
shin_lao大约 11 年前
It might sound like a good idea to precisely describe how code should be written, until you realize it&#x27;s inefficient and useless.<p>Code coherence can be accomplished with more relaxed rules if you delegate more responsibility to your engineers.
评论 #7564652 未加载
评论 #7564931 未加载
teemo_cute大约 11 年前
&quot;Vigorous programming is concise. A method should contain no unnecessary statements, a class no unnecessary methods, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts. This requires not that the programmer make all his methods short, or that he avoid all detail and treat his classes only in design, but that he make every statement tell.&quot;<p>—String and Wire (Elements of Modern Programming Style)
frozenport大约 11 年前
C++ Guide: We do not use C++ exceptions.<p>Python Guide: Exceptions are allowed but must be used carefully.<p>C++ Guide: Do not use lambda expressions, std::function or std::bind.<p>Python Guide: Okay for one-liners.
评论 #7565091 未加载
frozenport大约 11 年前
Does Google&#x27;s 80 character limit include the identification sequence?
评论 #7565177 未加载