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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: C Language Successors

6 点作者 blueredmodern7 个月前
For those of you who have experimented with potential C language successors, what are pros and cons and your experiences with them? I am talking about languages like Zig, Odin, C3, Hare, V and possibly Nim and Crystal, assuming that they are considered systems programming languages.

8 条评论

sylware7 个月前
All I know, is those &quot;successors&quot; should have a simpler syntax than C (since its syntax is already way too complex), and should have pointers, no garbage collection, no hard dependency on a complex runtime, etc.<p>Basically, it should be reasonable for one average dev to write a naive compiler in a reasonable little time.<p>Maybe it is better to cleanup the C syntax a bit: only sized types (u8&#x2F;16..&#x2F;u64, f32&#x2F;f64, s8...) namely inverting the primitive types; no implicit cast (except from literals and void*) or integer promotion, real hard compiler constants (re-definition of const keyword?); no switch keyword; only one loop keyword (loop {}); a clear split between static cast and runtime&#x2F;dynamic cast? (should give more thoughs to it, since only static cast seems to mean something); all those _generic, typeof, restrict, TLS, packed attribute (or how to lose the importance of alignment from sight), anonymous code block, stuff which have to go away; nowdays you need inline atomic, barriers, offsetof; and all the other things I am forgetting and of course if actually doing it, more thoughs will be required.<p>In the meantime I am coding RISC-V assembly which I can run an x86_64.
sim7c007 个月前
i think it depends a bit on your use case. wont go into too much detail because im definitely not an expert, but i found all alternatives that i managed to compile &#x27;bare metal&#x27; code with really tricky and weird to learn to write such code. this is ofcourse not the only kind of system programming, and things i tried might be suitable for other domains of system programming perfectly fine.<p>its likely lack of knowledge on my part, but i found it incredibly tedious to either reason about how binaries in such languages really worked, getting their toolchains to spit out binaries of the type i needed, or having to reimplement a lot of the core libraries which make those languages appealing, the last for example less needed when working within another operating system&#x27;s execution environment.<p>ultimately i ended up going back to C after many failed experiments. but this is just my &#x27;taste&#x27;. likely others might be more succesful (professional system programmers?)<p>i did not find a good alternative to C + assembly yet.
josh_ring7 个月前
I liked C3 a lot because it was the first C successor I looked at which I could understand easily and was relatively more C-like than the others. I have used that property to port various C libraries to C3 without much issue.<p>In Zig I had a really hard time getting productive. I found it really hard, but I really wanted to like it, I just couldn&#x27;t.<p>Hare was focused on just Linux and I wanted cross platform and ideally a C-like language.<p>Odin looks approachable but I didn&#x27;t really want a language which is quite different to C as it makes porting code from C more challenging.
iExploder7 个月前
Zig is nice, but subjectively I find some of the syntax is a bit weird, like ?&#x27;s !&#x27;s and the various array notations. I guess it just takes some time to get used to.
yawpitch7 个月前
I think you might want to provide a working definition of what precisely you mean by “successor” here.
评论 #41818085 未加载
purple-leafy7 个月前
What’s wrong with C itself?<p>I’m going back to C myself, to do some graphics programming
oulipo7 个月前
I quite like Swift
fithisux7 个月前
you forgot betterC (D-lang subset)