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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Why is C slower than Bolin?

17 点作者 snikolaev超过 2 年前

7 条评论

arinlen超过 2 年前
Spoiler: the title is clickbait and the article actually says that C isn&#x27;t really slower.<p>The initial C implementation written by the author that was passed off as representative of C was naive and had a couple of performance blockers. The author points out those performance blockers, and once the author gets rid of those blockers and re-tests te conclusion is that C isn&#x27;t actually slower.
评论 #32627013 未加载
评论 #32627007 未加载
flohofwoe超过 2 年前
Better title: why are some C stdlib functions slower than some Bolin stdlib functions. Unlike with many other languages, it&#x27;s totally fine to write C code and (almost) completely ignore the stdlib functions. The C stdlib is essentially just the least common denominator to get trivial cmdline tools working (badly) across platforms, but that&#x27;s about it.
LionTamer超过 2 年前
According to the website [1] there is a strict license to this programming language.<p>&gt; The License is intended for free learning and hobbyists and is a personal use license which means the Software may be installed and run only on Licensee computer as required for the purposes of Licensee’s code to produce a binary executable output (the “Executable Product”) only on Licensee-controlled Endpoint. An Endpoint is defined as a computer operating system (“OSE”) of any type physically hosted, but limited to Licensee’s internal personal use and not for distribution or any other use. For certainty, Licensee may not: distribute, assign, sell or grant any rights in or to the Software OR the binary executable product created by using the Software.<p>People of course can license the fruits of their labor however they wish to, I just can’t understand why someone would license their compiler in a way that prohibits me from sharing a useful program I made with my family or friends.<p>[1] <a href="https:&#x2F;&#x2F;bolinlang.com&#x2F;eula" rel="nofollow">https:&#x2F;&#x2F;bolinlang.com&#x2F;eula</a>
pechay超过 2 年前
You are comparing file IO, string to int, raw processing, and text output speed all at the same time. There are pros and cons associated with the choices made in both sets of libraries and compilers for each of those aspects. What exactly are you trying to measure? Can you isolate those parts more specifically and compare them instead? That would probably be more informative.
ncmncm超过 2 年前
When I run the &quot;faster&quot; C code, it takes 176 ms. When I run this C++ code:<p><pre><code> #include &lt;iostream&gt; #include &lt;fstream&gt; int main() { auto&amp; out = *std::cout.rdbuf(); std::filebuf in; in.open(&quot;&#x2F;tmp&#x2F;numbers&quot;, std::ios::in); for (int c, n = 0; (c = in.snextc()) != EOF;) { if (c != &#x27;\n&#x27;) { n = n * 10 + (c - &#x27;0&#x27;); } else { out.sputc((n &amp; 7) + &#x27;0&#x27;), n = 0; } } std::cout &lt;&lt; &#x27;\n&#x27;; } </code></pre> it takes 84 ms (and presumably 90 ms on the author&#x27;s machine).<p>So, why is Bolin slower (and longer) than C++? And why is so much of published code so bad?
评论 #32627432 未加载
conradludgate超过 2 年前
I think there is merit to these discussions. One has to ask what the most natural&#x2F;idiomatic program to solve a problem is, and sometimes the performance of that matters more than the utmost performance you can get from the language.<p>I&#x27;m know to be a rust fanboy, so I&#x27;ll talk about C++ instead. C++ is known to be fast, but theres also some known logic that you should use smart pointers to have more memory safety than raw pointers. If you follow that you&#x27;ll end up with a slower program. Of course, you can remove those and manage the pointers yourself, but then you have to deal with documenting the lifetimes properly.<p>These are trade offs people agree to when using a language. The easier thing might be slower and that&#x27;s ok. Speed isn&#x27;t always critical, so you can&#x27;t exactly rate languages by that metric alone
评论 #32631302 未加载
up2isomorphism超过 2 年前
Nobody understands C use fgets when he&#x2F;she wants speed.<p>The whole point of C is the programmer decides the performance himself, not trying to the fastest. None of the popular languages consistently deliver this.