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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Alternative code styles

230 点作者 _7ffc超过 6 年前

13 条评论

crehn超过 6 年前
Nowadays I couldn't care less about what style is used. As long as the code is consistent and there's an easy way to adhere (clang-format, black, prettier, etc.) I'm happy.
评论 #18218984 未加载
评论 #18219880 未加载
评论 #18219522 未加载
评论 #18218959 未加载
vhb超过 6 年前
Surprised nobody talks about the kdb codding style: <a href="https:&#x2F;&#x2F;github.com&#x2F;KxSystems&#x2F;kdb&#x2F;blob&#x2F;master&#x2F;c&#x2F;c&#x2F;k.h" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;KxSystems&#x2F;kdb&#x2F;blob&#x2F;master&#x2F;c&#x2F;c&#x2F;k.h</a>
评论 #18219733 未加载
评论 #18219067 未加载
评论 #18218457 未加载
评论 #18219661 未加载
dan-robertson超过 6 年前
The only style there that is actually used by a person is the Bourne style. There are other styles that people develop for themselves, for example there was some Haskell program posted to a mailing list with a warning about personal style. This defines:<p><pre><code> (.) :: a -&gt; (a -&gt; b) -&gt; b x.f = f x </code></pre> And then the author can write e.g.<p><pre><code> x.length </code></pre> Instead of<p><pre><code> length x </code></pre> I think this is really quite a natural operator (and other languages support it, eg in F# it is pronounced |&gt; and closure has something like it with -&gt;)
评论 #18220379 未加载
评论 #18219378 未加载
aequitas超过 6 年前
The best coding styles are the ones that allow to be translated back and forth to another style.<p>It doesn&#x27;t matter which style you prefer. As long as a computer can pick it up and translate it into the project standard style and back to yours again. You can simply setup git filters and live in you own style world.
评论 #18218484 未加载
评论 #18222579 未加载
janlaureys超过 6 年前
That Fibonacci based indentation might not be a bad idea after all. Especially when doing callback-style javascript.
评论 #18218218 未加载
评论 #18218737 未加载
评论 #18218598 未加载
评论 #18218494 未加载
mmjaa超过 6 年前
Putting every single item in this on my list of &quot;reasons to kill a motherfucker&quot;.<p>Seriously though, I find myself oddly attracted to the Python-braces style .. if only I could use it without running afoul of my own list.
评论 #18220170 未加载
aasasd超过 6 年前
I followed the link to the OOPS source code from the comments: <a href="http:&#x2F;&#x2F;people.idsia.ch&#x2F;~juergen&#x2F;oopscode.c" rel="nofollow">http:&#x2F;&#x2F;people.idsia.ch&#x2F;~juergen&#x2F;oopscode.c</a> (originally from <a href="http:&#x2F;&#x2F;people.idsia.ch&#x2F;~juergen&#x2F;oops.html" rel="nofollow">http:&#x2F;&#x2F;people.idsia.ch&#x2F;~juergen&#x2F;oops.html</a>)<p>Aaaand… “we&#x27;re achieving levels of nerdery that shouldn&#x27;t be possible.”
letientai299超过 6 年前
&gt; Poetry... quite eye-pleasing<p>I disagree with this comment. That style makes the code extremely hard to follow, as there&#x27;s no proper indention to identify scope.
评论 #18219488 未加载
评论 #18218347 未加载
评论 #18221520 未加载
inherentFloyd超过 6 年前
This has to be satire. Most of these are terrible and I&#x27;m pretty sure the fibonacci indentation originated on &#x2F;g&#x2F;.
评论 #18221369 未加载
评论 #18220144 未加载
评论 #18225422 未加载
jpfed超过 6 年前
Kevlin Henney gave a talk ( <a href="https:&#x2F;&#x2F;vimeo.com&#x2F;97329157" rel="nofollow">https:&#x2F;&#x2F;vimeo.com&#x2F;97329157</a> ) that included an interesting idea for style:<p>Imagine every non-whitespace character in your code were replaced with garbage. Indent so that the reader could still understand the structure of your code.
XorNot超过 6 年前
Braceless Rust does look very nice. I wonder if a python style syntax is possible?
评论 #18219933 未加载
HiroshiSan超过 6 年前
Wow! I&#x27;ve never heard of bournegol. That is really cool.
评论 #18220638 未加载
runemadsen超过 6 年前
oh god no stop.