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.
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.
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.
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?
I am interested to read your thoughts.
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: https://github.com/const-me/Vrmac#vector-graphics-engine
These nuts and bolts are very different between CPU and GPU. CPU-based libraries are painting pixels in bitmaps in system memory. Most GPU-based libraries are uploading indexed triangle meshes, and rendering them with weird shaders.
Worse, there're no good open source implementations of GPU-based ones. Microsoft ships an implementation as a part of OS (Direct2D) but it's not open source. Linux simply doesn't have an equivalent.
At least for initial versions, consider C interop with this https://github.com/memononen/nanovg It cuts a few corners (no cleartype for text, CPU overhead for repeated rendering of same static paths) but it's still good overall, simple, and easy to use.
> My only concern with C# is the cross compatibility
Works well on Linux, Windows and OSX, including ARM CPUs. Not sure about Android and iOS, never tested.
My largest concern with C# would be performance. Technically the language allows to code in any style, but most guides and examples are using OO-heavy one. Less than ideal for performance-critical pieces where you'd want cache-friendly RAM layout i.e. mostly value types, minimize dynamic memory allocations (e.g. lambdas are using managed heap when created), and so on.
My largest concern with the project overall would be the scale. Browsers are incredibly complicated. In C# the standard library contains many important pieces (HTTP stack, WebSockets, XML, etc.), you'll definitely find good free libraries to deal with HTML and CSS, you'll probably find libraries to interpret or JIT-compile JavaScript, but still, the remaining pieces are huge.
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
Thank you for your recommendation.
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 (https://fosdem.org/2022/schedule/event/ada_outsiders_guide/).
There's a tool called Alire (https://alire.ada.dev/) 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.
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
You can crosscompile with EASE to what ever target you want
My 2nd choice would be D
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
Go? best language for servers, not so good for anything that require low level
D is something to look at, but I'm wondering if the opportunity passed it by and it has become almost as wide/complex as C++. I never quite understood why D didn't go more heavily into application development, like Object Pascal, as a lane it could make more of a name for itself. Hard to be kind of similar to C++, going for same usage, and then to displace it. C++ is just so established and people so invested in it.
In the case of Zig, Vlang, or Odin, these are clearly more about being a step higher than C, but ease of use as well.
That is very unfortunate.
I have been looking into Zig since you and a few other people have suggested it. It is looking more promising the more I look into it. It looks like a pretty robust language with an active community.
Oh boy.
Xlib is very low level.
Changing languages won't solve the problem. E.g. if you have Rust or Go bindings for Xlib, Xlib is still Xlib.
There are a lot of requirements going into a browser. Think about, oh, rendering HTML + CSS: the whole ultra-complicated model. Fonts. Javascript engine. Handling a myriad image formats. Video. TLS security. Javascript engine!
Xlib is the least of your problems.
BTW, if you want some inspiration, have a look at the browser bundled with SerenityOS. It’s written in C++.
https://github.com/SerenityOS/serenity/tree/master/Userland/...
I have deviated away from both Go and Rust. Some people in this thread have recommended the Zig programming language and it looks very promising. Right now I'm experimenting with that.
> BTW, if you want some inspiration, have a look at the browser bundled with SerenityOS. It’s written in C++.
This is so awesome, thanks for sharing it. I'm going to love checking out the video and the source code!
One similar thing I know about is a Rust port of the Netsurf browser [1] to Redox OS [2] an OS written in Rust. But this is even better!
[1] https://www.netsurf-browser.org/
[2] https://en.wikipedia.org/wiki/Redox_%28operating_system%29
But I did quickly glance and it and it looks very interesting. Although I will take a closer look to see how active the community is, and the documentations too.
Thank you for the recommendation.
Personally I think D is not only suitable for systems programming but it also very much suitable for modern data science programming as I commented recently in the other discussions on C++ Matlab like library topic [1].
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.
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.
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.
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.
ETA: I personally would choose Go but don’t build something too large-scale, try to simplify as much as possible.
I don't think Go or Rust has the mature graphics APIs you'd need
C++ is definitely powerful for this use-case and I believe it has a very active community as well.
Thanks for the recommendation.
Performance wise it is at the very top with other low level languages.
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.
There’s an Ada HTTP server that might be a good starting point. It’s called Ada Web Server, or just AWS for short.
The Ada community is cursed with terrible acronyms (AWS, GPS, SPARK, and Ada).
[2]: POSIX.1-2017. https://pubs.opengroup.org/onlinepubs/9699919799.2018edition...
[3]: The Linux man-pages project. https://www.kernel.org/doc/man-pages/
[4]: Apple Documentation Archive. https://developer.apple.com/library/archive/navigation/
[5]: Windows API index. https://docs.microsoft.com/en-us/windows/win32/apiindex/wind...
The age of the documentation has absolutely nothing to do with using the software. I highly encourage developers to get rid of this mindset. Generally it comes from younger developers who have less exposure across the board. Senior developers should be comfortable reading standards documents and knowing that they will be years old. They are old for a reason. They stood the test of time.
Read your man pages. Eat your vegetables.