TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

OMG: Our Machinery Guidebook

94 pointsby onekorgover 5 years ago

7 comments

Aardappelover 5 years ago
Generally a wonderful set of minimalistic rules, much could carry over beyond C.<p>Except for: &quot;OMG-API-3: Unsigned integers are preferred over signed&quot;.. I feel they&#x27;re on the wrong side of history with this one.<p>&quot;Prefer unsigned&quot; only works if you can do 99% of your codebase this way, which, besides LLVM, probably doesn&#x27;t work for anyone. Having a codebase that is 99% signed is much more feasible. The worst is a codebase with plenty of both, which will be guaranteed endless subtle bugs and&#x2F;or a ton of casts. That&#x27;s what they&#x27;ll end up with.<p>Apparently the C++ committee agrees that size_t being unsigned was a huge mistake (reference needed), and I would agree. Related discussion: <a href="https:&#x2F;&#x2F;github.com&#x2F;ericniebler&#x2F;stl2&#x2F;issues&#x2F;182" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ericniebler&#x2F;stl2&#x2F;issues&#x2F;182</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;issues&#x2F;3493" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;issues&#x2F;3493</a> <a href="https:&#x2F;&#x2F;wesmckinney.com&#x2F;blog&#x2F;avoid-unsigned-integers&#x2F;" rel="nofollow">https:&#x2F;&#x2F;wesmckinney.com&#x2F;blog&#x2F;avoid-unsigned-integers&#x2F;</a><p>Even LLVM has all this comical code dealing with negative values stored in unsigneds.<p>The idea that you should use unsigned to indicate that a value can&#x27;t be negative is also pretty arbitrary. Your integer type doesn&#x27;t represent the valid range of values in almost all cases, enforcing it is an unrelated concern.
评论 #21771016 未加载
评论 #21774350 未加载
评论 #21776299 未加载
vietjtnguyenover 5 years ago
Quick typo under OMG-CODEORG-2:<p><pre><code> #pragma once #ifdef __cpluspus &#x2F;&#x2F; &lt;-- should be __cplusplus extern &quot;C&quot; { #endif #include &quot;api_types.h&quot; &#x2F;&#x2F; ... #ifdef __cplusplus } #endif </code></pre> Can&#x27;t say I&#x27;m a fan of OMG-CODEORG-3, however, it sounds like compilation time is a key metric for them.. I prefer a John Lakos style &quot;physical components&quot; set up which emulates a type-as-module inclusion style. At least OMG-CODEORG-3 clearly states that include order becomes important as a result.
评论 #21774238 未加载
评论 #21768585 未加载
bradknowlesover 5 years ago
NB: For those who are not aware, ourmachinery.com is a game engine development company.
mwcremerover 5 years ago
<i>I.e., use a double parameter that specifies seconds, instead of an uint32_t that specifies milliseconds.</i><p>This can have surprising and sometimes unpleasant consequences; see <a href="https:&#x2F;&#x2F;0.30000000000000004.com" rel="nofollow">https:&#x2F;&#x2F;0.30000000000000004.com</a>
评论 #21767935 未加载
评论 #21768659 未加载
评论 #21768825 未加载
mistrial9over 5 years ago
the layout and typesetting on this looks good in Firefox 70!<p>view-source:<a href="https:&#x2F;&#x2F;ourmachinery.com&#x2F;files&#x2F;guidebook.md.html" rel="nofollow">https:&#x2F;&#x2F;ourmachinery.com&#x2F;files&#x2F;guidebook.md.html</a><p>&lt;meta charset=&quot;utf-8&quot; emacsmode=&quot;-<i>- markdown -</i>-&quot;&gt;
评论 #21769745 未加载
Animatsover 5 years ago
Objects as structs with function pointers? 1990 is calling. I&#x27;m not a huge C++ fan, but trying to emulate C++ concepts in C is kind of lame at this late date.
评论 #21770979 未加载
评论 #21770005 未加载
rootlocusover 5 years ago
OMG-DESIGN-4: Explicit is better than implicit<p>Ahh, straight out of the zen of Python!<p><pre><code> $ python -c &quot;import this&quot;</code></pre>
评论 #21771588 未加载