by axegon_ · 6y ago · 0 comments
Firstly, C is where it is because it's well established and has solid foundations and it has remained pretty much unchanged for decades. Rust on the other hand is changing rapidly and fast, which is something you wouldn't want for a language that powers your kernel
Secondly, the Rust community is painfully small.
Thirdly, Rust lives in the LLVM world and I don't see it coming into the GCC world anytime soon. Which is a huge problem, as far as replacing C goes(namely licencing might be problematic in some cases).
Lastly Rust, in terms of it's nature, is more closely related to C++ rather than C. If Rust was to replace something, it has a much better chance against C++ than C.
I truly want to see the day I open up linkedin, go to the jobs section, type in rust and see 6000 new job offers. But at this point in doubt this day will ever come.
librsvg largely did. Brian Cantrill was very bullish, and apparently still is given… well the name of his company is a reference for starters, and if you look a Oxide's public repos those with C as the main language are all forks.
> Lastly Rust, in terms of it's nature, is more closely related to C++ rather than C. If Rust was to replace something, it has a much better chance against C++ than C.
That's very true, but at the same time C++ is way more complicated than Rust, with features interacting in subtle pitfalls and a lot more implicit (and often undesirable) behaviours e.g. the Chromium Cursor / GDI leak where a missing (therefore implicitly-declared) copy-assignment operator led to a leak of invisible kernel resources.
Not all of the people who'd rather do C than C++ do so because they don't want anything better than C. Again I'll cite Cantrill who very famously and publicly hated C++.
That said, Oxide is definitely doing The Right Thing(tm) selecting Rust, since they explicitly NEED boot and system board firmware that A. Is fast native code and B. Is as close to semi-sorta-provably-secure as one can get. Rust fits that specific bill better than anything short of C/ASM and NASA-level code validation processes.
To the matter at hand: yes, I have fallen in love with Rust.[4] Yes, I think it is a good fit for system software.[5] And yes, this has served as a bonding force at Oxide -- but as much (if not more!) for the values that it reflects than for it itself.[6]
[1] http://dtrace.org/blogs/bmc/2010/08/11/the-node-js-demograph...
[2] http://dtrace.org/blogs/bmc/2012/05/05/debugging-node-js-mem...
[3] https://vimeo.com/230142234
[4] http://dtrace.org/blogs/bmc/2018/09/18/falling-in-love-with-...
When it comes to building user mode applications like desktop programs with QT or GTK or what have you or command line programs such as curl and wget, I think these crowds have a valid point. Most of those applications are written in an object oriented language though.
There's also a very small group that's very militant about everything, including kernels and microcontroller programs, being rewritten into Rust. I don't pay too much attention to that crowd; C has its place and it's not the ultimate solution to programming languages.
Rust won't replace C in the kernel, but I do think we will see tooling for our network clients, file indexing and perhaps even version control slowly switching languages (if they still rely on C, that is). These will all be new tools though, because rewriting an old application into Rust and maintaining compatibility and performance is a big challenge.
Maybe I want to write a game. Gfx-rs is deprecated. Its replacement? It’s in a half ready beta state, and most of its developers are now focusing on a compatibility wrapper for MacOS, so progress is stalled.
The ecosystem just isn’t there. System libraries have an interface that is extremely suited for C. Interfaces have to be uniquely adapted for rust or be marked completely unsafe. Dynamic linking is convoluted, so Rust encourages statically linking everything. It’s not easy, and the situation needs to improve or Rust will be relegated to just another text processing language. C library symbols need to be accessible as a first-class part of the language.
Perhaps Rust will not be able to interface with Win32 because of its reliance on pointers, but there's the possibility of leveraging alternative programming interfaces such as the abstractions in the .NET runtime.
I believe that if Python and Java can have cross-platform GUI libraries, so can Rust. I don't know what the result would look like but the tooling has already massively improved since I first looked into the language. I'm too annoyed at GTK for their obsession with client-side decorations messing up the native look on Windows and other platforms to use it for my own projects, but the Qt integration didn't look all that bad in my opinion. Rust-qt is clunky because the Qt API requires unsafe code, but with some work the unsafe parts can be abstracted away from the main program logic. It's suboptimal but it does allow you to do data and network traffic parsing and handling in a safe manner, which would already be a huge win for application security in my opinion.
Do you mean the Linux kernel, XNU, Free/Net/OpenBSD, or other existing kernel's? There are plenty of examples of folks successfully building kernels in Rust. The likely hood of any of the major kernels adopting it (beyond drivers) is probably low. I expect the only reason that would happen is if any of the folks behind those kernels decide that they actively want to migrate the entire thing away from C in the long-run.
Ground up new kernels in Rust are very feasible, though. Will any of those attract the community and contribution that we see in Linux? That's unlikely, but it's not impossible, as your comment implies.
The only option for kernels that are mostly Rust I can see is a ground-up kernel, but those rarely succeed if ever. There's been small kernels in C# for a while now, for example, but those are usually no more than a fun experiment.
Fuchsia is the closest thing to a completely new kernel that I can think of and despite its age and the amount of people working on it, it's not used outside of lab environments. Perhaps in ten or twenty years a new kernel will replace Linux, and that might very well be written in Rust.
I wouldn't be surprised if there are multiple large communities that preach about nodejs replacing c. However I doubt anyone from the core rust developers lives with such illusions.
You may be surprised... we'll see, and it very much depends on what you mean by "soon," but there have been some interesting rumblings here.
I'm rooting for Zig and Odin as the better evolution for C. So is Carmack, at least for Zig [0] it seems.
[0] https://twitter.com/ID_AA_Carmack/status/1300579679951294464
In the same thread on Rust when asked, "What’s a better modern choice?", the response was: "Rust would be the obvious things [sic], and I don't have any reason to doubt it would be good, but I haven't implemented even a medium sized application in it."
https://twitter.com/ID_AA_Carmack/status/1299574198365495297...
C is so much of a lingua franca -- especially at the ABI boundary -- that any language wishing to "replace" it must properly absorb C. Zig is the language in town succeeding in that effort.
The specific issues I personally have run into with Rust and the C ABI are varargs (possible just not simple) and then dealing with function interfaces defined through CPP macros. Are there others you've seen?
modern c++ is very different nowadays, and it keeps evolving fast, to some extent many modern languages are having the same new features, c++ is becoming better and better for each new standard release, and g++/clang++ also keep up with new sanitizer, static analysis, excellent warning optional flags etc, in fact it is now very hard to make those stupid mistakes these days with modern c++ in a good IDE(even vim with the right configuration).
I will keep my eye on rust, I use a few rust utilities myself, but for the heavy duty of my carerr, c/c++ remains to the the top choice.
Google has, supposedly, some of the best engineers¹ in the world, and the best tooling in the world, and they keep pouring tons of resources on the best engineers and the best tools.
Yet, the same memory safety errors (which Rust, or any hypothetical memory-safe language, prevent entirely) keep popping again, and again. Have you heard of CVE-2020-0022? It's amazing.
In this perspective, pouring resources and effort on those languages is like trying to open a door by banging the head harder. It's fine if you like it, just don't pretend it's the optimal way to open doors.
¹=edited, to make it clearer what I wanted to convey.
I would say, it's SpaceX. (I wonder what they code in.)
Depends on where you look. In some online spaces a lot of Rust advocates do.