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.

Alternative code styles

230 pointsby _7ffcover 6 years ago

13 comments

crehnover 6 years ago
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 未加载
vhbover 6 years ago
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-robertsonover 6 years ago
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 未加载
aequitasover 6 years ago
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 未加载
janlaureysover 6 years ago
That Fibonacci based indentation might not be a bad idea after all. Especially when doing callback-style javascript.
评论 #18218218 未加载
评论 #18218737 未加载
评论 #18218598 未加载
评论 #18218494 未加载
mmjaaover 6 years ago
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 未加载
aasasdover 6 years ago
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.”
letientai299over 6 years ago
&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 未加载
inherentFloydover 6 years ago
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 未加载
jpfedover 6 years ago
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.
XorNotover 6 years ago
Braceless Rust does look very nice. I wonder if a python style syntax is possible?
评论 #18219933 未加载
HiroshiSanover 6 years ago
Wow! I&#x27;ve never heard of bournegol. That is really cool.
评论 #18220638 未加载
runemadsenover 6 years ago
oh god no stop.