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.

Why is C slower than Bolin?

17 pointsby snikolaevover 2 years ago

7 comments

arinlenover 2 years ago
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 未加载
flohofwoeover 2 years ago
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.
LionTamerover 2 years ago
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>
pechayover 2 years ago
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.
ncmncmover 2 years ago
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 未加载
conradludgateover 2 years ago
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 未加载
up2isomorphismover 2 years ago
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.