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.

Ask HN: Modern Alternatives to C

17 pointsby leakbangabout 3 years ago
Recently with a group of friends I decided to start creating a web browser from the ground up using as few libraries as possible and I wanted to do it in C. I persuaded everyone to learn and start using C, because I personally had a sweet spot for C and I&#x27;ve seen many great applications written in C so I wanted to pay homage to the great developers who coded great software in C.<p>But none of us were familiar with C and graphical libraries such as Xlib and Cairo so it was and is a big learning experience for all of us. However, learning C and Xlib has become a massive hurdle for us. The problem is that C is a remarkably old language and the available learning resources are very old. Most of the information in books have become obsolete as standards and libraries have changed and and updated. The C communities have turned into ghost-towns with the latest posts being from several years ago. And worst of all, an unbelievably large chunk of C code on the internet cannot be compiled due to changes in standards and changes in libraries.<p>I think while it was a novel attempt to try to do the whole project in C with the bare minimums, it is very unproductive. It took out the confidence and fire in all of us so now I&#x27;m looking at some of the modern languages as a replacement for C. I still would like to keep it relatively low leveled and be in control. From my knowledge GO and Rust seem to be a modern take on C.<p>GO and Rust have caught my attention because they seem to have an active community, both allow the programmer to be in charge, and they perform quite well.<p>I&#x27;m asking you for advice and really like to hear your thoughts. Do you think Rust or GO would be suitable? Do you recommend other languages? What do you think?<p>I am interested to read your thoughts.

17 comments

pyjarrettabout 3 years ago
Either Go or Rust would be great. They&#x27;re both good alternatives to C. D, Zig, Crystal, Nim are other ones you might consider.<p>An alternative to these that I use for hobby projects, is Ada. It&#x27;s weird and most people laugh at me for using it. It&#x27;s super simple (you can learn it in about a month), and it writes like a more strongly-typed and safer, Pascal version of C. It also has built-in concurrency and provides low-level control. I did a presentation at FOSDEM to give an overview of the language since most people don&#x27;t know much about it (<a href="https:&#x2F;&#x2F;fosdem.org&#x2F;2022&#x2F;schedule&#x2F;event&#x2F;ada_outsiders_guide&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fosdem.org&#x2F;2022&#x2F;schedule&#x2F;event&#x2F;ada_outsiders_guide&#x2F;</a>).<p>There&#x27;s a tool called Alire (<a href="https:&#x2F;&#x2F;alire.ada.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;alire.ada.dev&#x2F;</a>) that will install the toolchain for you and simplifies building and running. The open source community is super tiny, probably 1&#x2F;10th or smaller of that of the Rust or Go communities. However, since the language has been around and evolving for decades, it&#x27;s surprisingly easy to get answers to questions, since there&#x27;s quite a few very experienced folks around. Though it&#x27;s easy to make bindings, there&#x27;s relatively few available. However, since the language&#x27;s open source scene is new compared to the rest of the language, it&#x27;s a place you and your friends could make a big impact.
评论 #31243281 未加载
评论 #31223281 未加载
Const-meabout 3 years ago
If I wanted to create a web browser from the ground up, I would do that in C#.<p>And I would not use graphical libraries such as Xlib or Cairo, none of them has good hardware support. I think the right way is building on top of 3D GPU APIs, like I did there: <a href="https:&#x2F;&#x2F;github.com&#x2F;const-me&#x2F;Vrmac#vector-graphics-engine" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;const-me&#x2F;Vrmac#vector-graphics-engine</a>
评论 #31223264 未加载
评论 #31223511 未加载
Shadonototraabout 3 years ago
Zig - most portable modern C alternative, you can consume C&#x2F;C++ with ease, so if there are C&#x2F;C++ libraries that&#x27;ll help you kickstart your idea, you&#x27;ll just need to include the headers, that&#x27;s it<p>Comptime feature is unmatched, it&#x27;s not something weird as macro, you don&#x27;t need to learn a new language on top of the language itself, it is zig code<p>You can crosscompile with EASE to what ever target you want<p>My 2nd choice would be D<p>Rust? you&#x27;ll cry when you&#x27;ll have to wait 10+ minutes to compile a single line change, and the code becomes quickly unmanageable, the community is sectarian, elitist, and will hate you for criticizing their &quot;god&quot; language<p>Go? best language for servers, not so good for anything that require low level
评论 #31243467 未加载
评论 #31226610 未加载
armchairhackerabout 3 years ago
I consider Rust and Go to be the general “modern alternatives to C”.<p>Go afaik is more focused on simple applications, while Rust is better for large-scale apps or if you need unique performance, memory management, or security.<p>However Rust is hard to use&#x2F;learn and verbose. It’s a steep learning curve so you risk getting burnt out. IMO you need to understand low-level systems programming and some type theory to be good at Rust.<p>If you want other alternatives, you might also be better off just using Kotlin&#x2F;Java. It’s not as performant but it’s not terrible (e.g. JavaScript), and the good tooling, runtime checks, and reflection come in handy. .NET in C# is another alternative but i’ve never used it.<p>Or you could use Swift, which seems to be performant like Rust&#x2F;Go but still easy to learn&#x2F;use and similar to Kotlin. The only issues are that afaik Swift support on anything not Apple is hard, you basically need Xcode or AppCode, and there isn’t as big of an ecosystem.<p>ETA: I personally would choose Go but don’t build something too large-scale, try to simplify as much as possible.
评论 #31223186 未加载
binarynateabout 3 years ago
Rust and C++ are the best alternatives for systems programming languages that have the same performance characteristics as C. Go&#x27;s performance is similar to Java and C# due to its runtime and garbage collection. Maybe that&#x27;s fine for your use case, but that places it on a different part of the spectrum than C, C++, and Rust.
andrewmcwattersabout 3 years ago
You want to create a web browser from the ground up and C was a massive hurdle for you?<p>Oh boy.
评论 #31223087 未加载
cpachabout 3 years ago
Is Go really suitable…? I love Go, but so far I haven’t seen <i>any</i> desktop applications written in it. I guess that’s for a reason?<p>BTW, if you want some inspiration, have a look at the browser bundled with SerenityOS. It’s written in C++.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;SerenityOS&#x2F;serenity&#x2F;tree&#x2F;master&#x2F;Userland&#x2F;Applications&#x2F;Browser" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;SerenityOS&#x2F;serenity&#x2F;tree&#x2F;master&#x2F;Userland&#x2F;...</a><p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=Gbvhmt9EdfI" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=Gbvhmt9EdfI</a>
评论 #31229810 未加载
评论 #31243367 未加载
rizzaxcabout 3 years ago
C++<p>I don&#x27;t think Go or Rust has the mature graphics APIs you&#x27;d need
评论 #31223121 未加载
pkphilipabout 3 years ago
Free Pascal with Lazarus. Sounds weird but you can do pretty low level programming (as with C) with Free Pascal including using assembly language, if needed. And you can compile into a single executable.<p>Also, since it already includes a UI and also a web browser component which you can extend&#x2F;modify, it would be trivial to get started with developing the nuts and bolts of the Web browser
评论 #31245772 未加载
评论 #31226574 未加载
Royiabout 3 years ago
Another esoteric choice would be the Odin Programming Language [0]. While being very simple it is modern and effective with some real projects built using it.<p>Performance wise it is at the very top with other low level languages.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;odin-lang&#x2F;Odin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;odin-lang&#x2F;Odin</a>
评论 #31229839 未加载
pyuser583about 3 years ago
Rust and Golang are suitable.<p>If you’re willing to consider esoteric languages, they Ada. It’s made with security in mind, so might be appropriate for a web browser.<p>There’s an Ada HTTP server that might be a good starting point. It’s called Ada Web Server, or just AWS for short.<p>The Ada community is cursed with terrible acronyms (AWS, GPS, SPARK, and Ada).
评论 #31223225 未加载
khoobid_shomaabout 3 years ago
I think C is the best option which is simple, fast and powerful. You need to introduce a separation layer to decouple your core implementation from the graphics, networking... libraries. This makes porting to other OSes or switching to the other libraries easy.
gadiyarabout 3 years ago
Why not consider D?
评论 #31223155 未加载
评论 #31222608 未加载
post-factumabout 3 years ago
What about Zig?
评论 #31220583 未加载
bartmikaabout 3 years ago
Take a look at the Crystal Programming Language - “Slick Like Ruby and Fast Like C” is goal of the project.<p><a href="https:&#x2F;&#x2F;crystal-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;crystal-lang.org&#x2F;</a>
评论 #31223094 未加载
评论 #31228999 未加载
mikewarotabout 3 years ago
Does anyone have a good reference for C as it should be used in 2022? It seems all the references out there are backwards facing and&#x2F;or decades old.
评论 #31228956 未加载
yuppie_scumabout 3 years ago
It’s got to be Go I think.