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.

A “Better C” Benchmark

183 pointsby bshanksabout 4 years ago

24 comments

lew89about 4 years ago
Nice and clear article. I like an idea of looking at quality of the process and not only the product. It was pleasant to read.<p>I didn&#x27;t like that C itself was missing, because C is still my language of choice for some tasks and I still use it because I&#x27;m happy about it, I don&#x27;t feel I would need any of its competitors. Maybe if this benchmark included C it would be some argument to give them a try. So I decided to do it for you.<p>It took me 30 minutes, only change is that I don&#x27;t check if file is binary, I guess. I liked that I was doing it in C because I know it and I&#x27;m comfortable with it. Few checks in man and everything&#x27;s clear. Only disadvantage of C is that it doesn&#x27;t have standard API for directories, so my code is only for POSIX. Here&#x27;s the code: <a href="https:&#x2F;&#x2F;github.com&#x2F;BartekLew&#x2F;dumbgrep" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;BartekLew&#x2F;dumbgrep</a><p>The other thing are sources you&#x27;ve done. They are almost the same (it&#x27;d be nice to see the more feeling of the language, idiomatic code, etc.) and I didn&#x27;t like reading them at all, not a clean code and all are longer than my C code.<p>Another thing is that C has very narrow application nowadays. A benchmark should be focussed on them and not on generic algorithms.
评论 #26601277 未加载
评论 #26602149 未加载
renoxabout 4 years ago
What I find funny is his choice of languages: &#x27;hipe driven&#x27; I&#x27;d say.<p>If you can use a GCd language like Go why would you go with Rust(which add a lot of complexity) or Zig(which is unsafe(1)) instead of the numerous existing GCd languages D,Nim, Crystal, Java,... which provides memory safety without complexity<p>If you can&#x27;t why evaluate Go instead of Ada or DasBetterC?<p>1: At work a frequent issue in C++ is UAF a pointer to a stack variable which outlives the function, Zig don&#x27;t help you here..
评论 #26600677 未加载
评论 #26603134 未加载
评论 #26600849 未加载
评论 #26600618 未加载
评论 #26601992 未加载
评论 #26601090 未加载
评论 #26600918 未加载
评论 #26603982 未加载
评论 #26604756 未加载
评论 #26601161 未加载
评论 #26601360 未加载
chhsabout 4 years ago
I threw together a D Programming language glob-grep based off of the Zig version the author posted, if anyone is curious: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;aruthane&#x2F;005c6c48f0deb9c4bfc83bc75e0e95f7" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;aruthane&#x2F;005c6c48f0deb9c4bfc83bc75e0...</a>
评论 #26602051 未加载
评论 #26606800 未加载
antirezabout 4 years ago
50 years is not a good age for a bottle of wine. There are wines that are still enjoyable after such long time, but will hardly express the same potential they had at the peak of their maturity. Many other bottles will be already totally gone after 50 years.
评论 #26602176 未加载
评论 #26604393 未加载
vitusabout 4 years ago
A nit&#x2F;bug re: the glob matching algorithm in use:<p>&#x27;?&#x27; evidently represents &quot;any character&quot; per the !glob(&quot;h?i&quot;, &quot;hi&quot;) test.<p>But, if I add a test for glob(&quot;???&quot;, &quot;hi&quot;), that succeeds unexpectedly even though it should run out of input.<p>I believe it&#x27;s because the &#x27;?&#x27; case checks nt &lt; text.length() (which AIUI is for consuming variable input for &#x27;*&#x27;) instead of t. Changing that case to t &lt; text.length() seems to fix that problem.<p>(This looks like it&#x27;s the case for all four languages, as the glob algorithm looks identical in all four, modulo syntax differences)
maccardabout 4 years ago
I think there is definitely merit in these kinds of posts.<p>This developers measure of productivity is &quot;how low level can I go&quot; clearly; they declared zig was clear despite saying this:<p>&gt; The lack of string handling routines in the stdlib was unexpected, to concatenate strings one has to do everything manually - allocate the buffer, put strings there. Or use formatter and an allocator to print both strings side by side and free the buffer afterwards.<p>This combined with &quot;strings&quot; being byte buffers like in C are not a good thing. I had a quick look and the author appears to be german; how do you handle an umlaut in zig?<p>His dismissal of C++ as &quot;not having a build system&quot; seems like considering the language without the ecosystem. Using cmake and llvm solves all of his gripes on C++.<p>Finally, this post measures the productivity of a single developer, On a 1-3 file project. How these projects work with 2-5 developers, or on projects that support more than the anglosphere are very important.
评论 #26601474 未加载
评论 #26602613 未加载
评论 #26601988 未加载
评论 #26602181 未加载
评论 #26601270 未加载
评论 #26603059 未加载
评论 #26601163 未加载
himujjalabout 4 years ago
Zig is promising. The UX problem that the author talks about will be solves by Zig.<p>About documentation, its still not 1.0, the language. So, its a work in progress.
评论 #26601187 未加载
Zardoz84about 4 years ago
Seeing the title, I expected an article benchmarking DLang &quot;Better C&quot;. Instead, the author even don&#x27;t mentioned anything about DLang...
评论 #26606826 未加载
lhorieabout 4 years ago
&gt; The lack of string handling routines in the stdlib was unexpected, to concatenate strings one has to do everything manually - allocate the buffer, put strings there<p>Not sure how long the author spent looking at zig stdlib, but there is std.mem.join for this. Most string utils are under std.mem, it seems. To be fair, I also rolled my own std.mem.eql for string comparison before stumbling upon it as a beginner, so this definitely an area for improvement.<p>Overall I agree with the assessment about stdlib docs. Many things are not even listed in docs, and many that are have little to no description. Also some of type signatures are not really clear, e.g. when they use `var` as a type.<p>What works for me is having stdlib docs and source code from github side by side and jumping back and forth between them.<p>But overall, as someone who&#x27;s gone through a similar language evaluation process, his assessment feels pretty on point: zig&#x27;s lack of maturity still shows in a lot of places, Rust feels complicated and puzzling at the beginning, etc. My only difference is I&#x27;d lean towards C if I had to pick between it and C++, but that&#x27;s largely a matter of personal preferences IMHO.
kidfrommarsabout 4 years ago
The Rust code is very non-idiomatic, which is probably part of the reason why it seemed difficult to put together and why reading it is a bit of a chore. Compared to Zig or Go, naively translating C code into Rust isn&#x27;t going to work nearly as well. This isn&#x27;t necessarily because Rust is more complicated (although it definitely is) but has a lot to do with the fact that it&#x27;s semantics are inspired almost as much by OCaml and Haskell as they are by C and C++. It&#x27;s not surprising, then, that someone who is predominately a C programmer would need more than a couple hours to be able to really judge the difference between the languages.
评论 #26604540 未加载
评论 #26603523 未加载
评论 #26603172 未加载
bfrogabout 4 years ago
Honestly Rust is pretty expressive. There&#x27;s always some things that you are going to run into. But mostly Rust is a really nice language and environment to work in.
alfiedotwtfabout 4 years ago
These comparison articles can be reduced into 3 types...<p>Write code:<p>1. In less time<p>2. That runs faster<p>3. That&#x27;s less buggy<p>Pick one.<p>... this article advocates for (1).
maxpertabout 4 years ago
Heeyyyyy! Where is my Nim and Crystal? If you think GC based languages are acceptable I highly highly encourage Crystal.
kgeistabout 4 years ago
&gt;All had about the same performance when scanning through my whole &#x2F;usr&#x2F;include file tree. That’s why I wanted to highlight that technical characteristics are often not as important as the developer experience.<p>Strange conclusion considering their benchmark was I&#x2F;O-bound by design
aruncabout 4 years ago
Wondering why D was not considered. D is probably the better C I&#x27;ve come across.
slmjkdbtlabout 4 years ago
im worried about something managed to actually replace C, now every platform provides their lowest level sdk in C which is super nice, if you want to do cross platform native dev like games and ui, just using C can get you anywhere, i dont&#x27;t want it to be like graphics where better tech came out but each vendor uses their own specs (OpenGL everywhere -&gt; Vulkan &#x2F; Metal &#x2F; D3d &#x2F; WebGPU) and makes it impossible to do actual cross-platform dev unless you can put up with some HAL bloat
fithisuxabout 4 years ago
A benchmark with &quot;better c&quot; mode of Dlang would be amazing.
notoranditabout 4 years ago
C is not C++! Where is the implementation in C? Boob!
评论 #26600877 未加载
drannexabout 4 years ago
I am really surprised that D&#x27;s --betterC subset (or just D proper) wasn&#x27;t even tested, considering that&#x27;s exactly what it is called and would likely outrank a good bit of everything else on the list.
lernoabout 4 years ago
Would have liked comparisons with Nim, Crystal, Odin, D.
vram22about 4 years ago
&gt;They often complain the syntax is unclear and requires paying attention to details.<p>Attention to detail comes with the territory for programming roles. People who can&#x27;t or don&#x27;t want to pay attention to details are not fit to be programmers. We are working with precise binary digital machines, FFS. I sometimes find this attitude among students of my training courses - the misconception &quot;computer, do what I mean, not what I say&quot;. Obviously such students don&#x27;t do well in my course or in their career.
justAnIdeaabout 4 years ago
&gt; With no previous experience I opened vim and started coding.<p>That is where i stopped reading. If you&#x27;re not using an IDE in 2021, you&#x27;re not working on serious software&#x2F;big codebases&#x2F;commercial projects and what you have to say is not something I&#x27;m interested in, ESPECIALLY when talking about UX of programming! VIM, oh please... time to have a nap, grandpa.
评论 #26630241 未加载
评论 #26601404 未加载
评论 #26601365 未加载
评论 #26601346 未加载
评论 #26601116 未加载
评论 #26601283 未加载
systemBuilderabout 4 years ago
--- comment removed ---
评论 #26602564 未加载
marvel_boyabout 4 years ago
Simplicity wins. Always.
评论 #26600769 未加载
评论 #26601547 未加载
评论 #26600688 未加载
评论 #26602661 未加载
评论 #26600909 未加载