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'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'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'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.
Either Go or Rust would be great. They'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's weird and most people laugh at me for using it. It'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't know much about it (<a href="https://fosdem.org/2022/schedule/event/ada_outsiders_guide/" rel="nofollow">https://fosdem.org/2022/schedule/event/ada_outsiders_guide/</a>).<p>There's a tool called Alire (<a href="https://alire.ada.dev/" rel="nofollow">https://alire.ada.dev/</a>) that will install the toolchain for you and simplifies building and running. The open source community is super tiny, probably 1/10th or smaller of that of the Rust or Go communities. However, since the language has been around and evolving for decades, it's surprisingly easy to get answers to questions, since there's quite a few very experienced folks around. Though it's easy to make bindings, there's relatively few available. However, since the language's open source scene is new compared to the rest of the language, it's a place you and your friends could make a big impact.
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://github.com/const-me/Vrmac#vector-graphics-engine" rel="nofollow">https://github.com/const-me/Vrmac#vector-graphics-engine</a>
Zig - most portable modern C alternative, you can consume C/C++ with ease, so if there are C/C++ libraries that'll help you kickstart your idea, you'll just need to include the headers, that's it<p>Comptime feature is unmatched, it's not something weird as macro, you don'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'll cry when you'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 "god" language<p>Go? best language for servers, not so good for anything that require low level
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/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/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/Go but still easy to learn/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.
Rust and C++ are the best alternatives for systems programming languages that have the same performance characteristics as C. Go's performance is similar to Java and C# due to its runtime and garbage collection. Maybe that's fine for your use case, but that places it on a different part of the spectrum than C, C++, and Rust.
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://github.com/SerenityOS/serenity/tree/master/Userland/Applications/Browser" rel="nofollow">https://github.com/SerenityOS/serenity/tree/master/Userland/...</a><p><a href="https://www.youtube.com/watch?v=Gbvhmt9EdfI" rel="nofollow">https://www.youtube.com/watch?v=Gbvhmt9EdfI</a>
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/modify, it would be trivial to get started with developing the nuts and bolts of the Web browser
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://github.com/odin-lang/Odin" rel="nofollow">https://github.com/odin-lang/Odin</a>
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).
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.
Take a look at the Crystal Programming Language - “Slick Like Ruby and Fast Like C” is goal of the project.<p><a href="https://crystal-lang.org/" rel="nofollow">https://crystal-lang.org/</a>
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/or decades old.