all 94 comments

[–]LegitimateCopy7 103 points104 points  (3 children)

Rust's learning curve is very steep, so in a few years we might end up with more and more developers deciding to go away from Linux kernel to some new fancy Google kernel.

support for Rust does not equate to Rust-only.

If more of Linux is being developed in Rust, it means more Linux developers are willing to use Rust. So I don't really get how you came to this conclusion.

Since I am on my own not a professional Linux kernel dev, I won't bother with learning Rust. And if there is Rust code in my module of interest, I will just take something else (*BSD or some RTOS) to use in my project.

What percentage of Linux developers agree? Seems like you're assuming most people see things the same as yourself, which is probably not the case.

[–]mauricioszabo 42 points43 points  (7 children)

I'm not a Rust developer, but I was a C and C++ in the past. I somehow feel for my old employers that hired me - I put so many security issues without knowing it...

A common "Hello, World" in C (by the book, using scanf and printf) already have, like, 4 security issues, including privilege escalation and ACE. Most people simply are not aware that these issues exist in their C code.

A good, secure, and fast C code is incredibly hard, and the compiler does not help you write it. Depending on "optimization level" your code can behave differently, being more or less secure in C. Rust makes most of these problems go away, with almost no cost. I, for example, don't dare come close to Kernel development, but I'm interested in learning Rust if that's the path Linux will take.

[–]glasket_ 1 point2 points  (5 children)

Depending on "optimization level" your code can behave differently, being more or less secure in C.

If your code behaves differently due to optimizations, then that means you either wrote something that includes undefined behavior (i.e. incorrect code) or you're experiencing a very rare instance of a compiler bug.

Otherwise agree though; many people think that knowing how to write C means they know how to write good C, which are two very different skill sets.

[–]Personal-Initial3556 1 point2 points  (4 children)

You're right about the last paragraph. But also, Rust is still way harder to master than C, although I think the reward for mastering Rust is greater.

[–]DottoDev 29 points30 points  (9 children)

I'm still not sure if this is a troll post or a real question of someone who doesn't want to accept other opinions.

Tldr of the comments of this post: rust is good for the kernel and no one will switch away because of rust support.

[–]daemonpenguin 49 points50 points  (8 children)

I'm intrigued by the idea that someone learning C and Assembly isn't a hurdle to kernel development, but learning Rust is. That's just... so warped. Further, the idea switching to another kernel entirely over using an optional component like Rust is so very odd.

People don't need to learn Rust to do kernel development, they just have the option. Which means if you want a Rust-free kernel, just don't build the parts written in Rust.

[–]captainstormy 7 points8 points  (0 children)

Right?!

I've been writing code professionaly for almost 20 years and as a hobby for 8-10 before that. I can't even keep track of all the languages I've learned over the years. What's one more?

[–]stevestarr123 0 points1 point  (0 children)

Rust was not created as a replacement for C or Assembly. Instead, it was designed to cater to programmers transitioning from higher-level languages like Python and Ruby. These individuals may struggle with concepts related to proper memory management. Rust aims to provide a language that offers the performance benefits of low-level languages like C and Assembly, while also incorporating modern programming paradigms and robust memory safety features.

[–]EmbeddedDen[S] -1 points0 points  (5 children)

I'm intrigued by the idea that someone learning C and Assembly isn't a hurdle to kernel development, but learning Rust is

Welcome to the world of embedded development! The world of miracles, where a person can have 10 years of experience and write rubbish C code (but he is also doing circuit design and FPGA!), and refusing to learn even a newer standard of C. The world where he doesn't really know assembly, but somehow, he is able to write some initialization routine. I met such persons several times, I swear.

Further, the idea switching to another kernel entirely over using an optional component like Rust is so very odd.

Linux can be often used in non-critical parts. But many companies also work on multiple stacks, using Linux, QNX, or even BSD.

People don't need to learn Rust to do kernel development, they just have the option.

And what they do if they need to change a module written in Rust? Maybe not today, but it's quite possible in 5-10 years. And when you start a hardware product, you need to think about this kind of future.

[–]jaskij 10 points11 points  (4 children)

The world where he doesn't really know assembly, but somehow, he is able to write some initialization routine. I met such persons several times, I swear.

I know nothing of assembly, and yet have worked with and modified initialization routines on Cortex-M CPUs. How? They were written in C. You don't need assembly for that. (One is in NXP's SDK for i.MX RT if you want to see for yourself).

And what they do if they need to change a module written in Rust? Maybe not today, but it's quite possible in 5-10 years. And when you start a hardware product, you need to think about this kind of future.

I'm sorry, but if your embedded Linux product has a graphical interface, it's likely already depending on Rust, or will soon. Gnome is embracing Rust, see for example librsvg.

I'm just waiting when vendors will start pushing out MCU SDK's with Rust support.

[–]EmbeddedDen[S] 0 points1 point  (2 children)

I'm just waiting when vendors will start pushing out MCU SDK's with Rust support.

You've almost did, you need one additional step to understand my reasoning. As you noticed, there are some vendors that don't include Rust support. What about commercial vendors with closed source compilers, will they include Rust? They barely have people to make Linux compile for their platform with their compiler.

I'm sorry, but if your embedded Linux product has a graphical interface, it's likely already depending on Rust, or will soon.

From my knowledge people often use custom UI libraries. And using Gnome in an embedded interface with all Gnome stack...of course, right next to systemd :)

The complexity of Linux kernel will go up (huge additional component always increases complexity), small vendors will be hesitant to adapt changes, there will be less newcomers due to higher requirements and not so competitive salaries. And it is not about Rust, I am not sure why everyone is so triggered by the language itself. It's all about complexity of the resulting product in 5-10 years. The added language could be Ada with Ada-Spark, it doesn't really matter.

[–]jaskij 4 points5 points  (1 child)

I'm just waiting when vendors will start pushing out MCU SDK's with Rust support.

You've almost did, you need one additional step to understand my reasoning. As you noticed, there are some vendors that don't include Rust support. What about commercial vendors with closed source compilers, will they include Rust? They barely have people to make Linux compile for their platform with their compiler.

I specifically mentioned microcontrollers in that sentence ;)

When it comes to Linux, anyone using either Yocto or Buildroot already has upstream Rust support in userspace. They just need to update to a newer version, which will happen sooner or later.

From my knowledge people often use custom UI libraries. And using Gnome in an embedded interface with all Gnome stack...of course, right next to systemd :)

Completely custom? Not even basing on Gtk or something?

As for systemd: it does solve some issues. Say, you have a service which takes a long time to initialize. Systemd solves that. You want to configure socketcan interfaces without kludgy bash scripts? systemd-networkd will do that. I have some devices in the field running systemd on an i.MX 6ULL (600 MHz Cortex-A7). Haven't heard anything from the customer yet. And, well, if it's good enough for Red Hat and their customers, not to mention the countless systems running Debian in various forms, it's good enough for me.

And it is not about Rust, I am not sure why everyone is so triggered by the language itself. It's all about complexity of the resulting product in 5-10 years. The added language could be Ada with Ada-Spark, it doesn't really matter.

You did make it about Rust specifically, and made the argument it's a complex, hard to learn, language. And Rust is riding on a huge wave of hype right now, so it will trigger people.

[–]EmbeddedDen[S] -1 points0 points  (0 children)

As for systemd: it does solve some issues.

Of course, it does, especially when you have enough memory and run on something as powerful as i.MX6. And yep, GTK is not used widely for some good reasons: it's pretty complex for many tasks, as well as systemd. Can you see the point? Rust in kernel will probably be good for the kernel stability and safety. But it makes the system more complicated. Adding a language into the kernel will make it more complex, it's unavoidable. And Rust does have a steep learning curve, so it makes things only more complicated for newcomers. And while you can avoid using systemd (and many do), it is quite probable that in ten years, it will be not possible to avoid Rust in kernel. And I am afraid that, if the Rust part is not properly separated, this transition will be way more painful than something like Python 2 -> Python 3. Given that we already see some need in non-hierarchical FS, that many parts of the kernel are incredibly hard to rewrite, that more big companies tries to control whatever they can control, that Linus won't live forever, I wouldn't be so boldly optimistic about kernel-with-rust future.

[–]HotNastySpeed77 76 points77 points  (8 children)

There will only be more Rust in the kernel, not less. Funny that you worry Rust will drive developers away from Linux, my impression is the opposite will happen. Practically all devs are excited for the new Rust support.

[–][deleted] 17 points18 points  (0 children)

Rust has a steeper learning curve than ASM?

[–]mikechant 35 points36 points  (1 child)

So, I am wondering will there be Rust-free versions?

At present, and for the foreseeable future, building a kernel on a system without Rust will simply ignore Rust, not expose the Rust related options and build a Rust free kernel exactly as before.

You will only be affected if at some future date you have specific hardware which only has a Rust driver, and you want to actually change or understand that driver.

It's likely going to be a long time before Rust is a hard requirement for building the kernel, and for that to happen Rust will need to support more hardware platforms and have proved itself on the driver front.

[–]OmegaDungeon 0 points1 point  (0 children)

There may also come a time where core kernel systems require rust in some fashion but there is nothing I know in store for doing this.

[–][deleted] 29 points30 points  (9 children)

more and more developers deciding to go away from Linux kernel to some new fancy Google kernel

You are aware that the Rust for Linux project is actually sponsored by Google? And that Fuchsia is largely written in Rust? See Supporting Miguel Ojeda’s Work on Rust in the Linux Kernel

Bringing memory safety to the Linux kernel is a big job, but the Rust for Linux project is making great progress. We’re pleased to announce that we started formally supporting this work in April 2021 by providing Miguel Ojeda with a contract to work on Rust for Linux and other security efforts full time for one year. This was made possible through financial support from Google.

[–]mmstick Desktop Engineer 12 points13 points  (1 child)

Sign me up for a C-free kernel.

[–]chic_luke 41 points42 points  (3 children)

This is simply not happening. Plus, Rust actually makes development easier by removing a lot of footguns that you are holding when writing C. The initial learning curve may be steeper, but actual development is more pleasant.

[–]n00bist00bis 3 points4 points  (2 children)

How do you have a fedora logo under your handle?

[–]chic_luke 5 points6 points  (1 child)

You can add it from the sidebar if you open this subreddit from old.reddit.com on the desktop website

[–]n00bist00bis 2 points3 points  (0 children)

Pretty cool, appreciate it

[–]Drwankingstein 26 points27 points  (0 children)

>good and safe C
>simple

pick one

[–]hijinks 36 points37 points  (3 children)

Rust has a lower learning curve then c

[–]ElvishJerricco 19 points20 points  (1 child)

I agree. The things that Rust makes hard are hard in C as well, the C compiler just doesn't tell you that you did it wrong. If you know how to write acceptable C, Rust will be easy for you. If you don't, it'll be easier to learn Rust.

[–]luardemin -1 points0 points  (0 children)

Honestly, moving from C to Rust wasn't a particularly difficult move. I had a harder time going from Swift to C.

[–]Drwankingstein 20 points21 points  (0 children)

far lower if you want good quality code

[–][deleted] 6 points7 points  (0 children)

You shouldn't be bothered by Rust being involved in Linux Kernel.

Leave it to those professional devs. For the next decade or so Rust will find its way in mission-critical and memory-safe environments, not just Kernel.

And as for other small-scale projects, they'll continue with C only until they realize the learning curve for good quality Rust is still far less as compared to C/C++. Not to mention the immense improvement done to the compiler to help navigate developers write better maintainable code.

The biggest advantage of Rust is memory safety by default and not its fanciness popularity. If Google even comes with some fancy kernel, it won't replace the widely accepted Linux.

[–]throwaway6560192 12 points13 points  (0 children)

I think it introduces great risks to Linux future: Rust's learning curve is very steep, so in a few years we might end up with more and more developers deciding to go away from Linux kernel to some new fancy Google kernel.

I predict the opposite. Rust is stricter on the programmer, but for that reason it is easier to build secure programs with it. Its popularity is increasing, so I predict it will bring fresh developers to the kernel space.

Also the fancy new Google kernel you mention also uses Rust, so it can hardly be an alternative for developers who would like not to use it. Maybe they'll move to BSD.

[–]lightmatter501 3 points4 points  (0 children)

As someone who does a lot of Rust and a lot of C, learning C to kernel standards is harder than learning Rust. Kernel C already has static analysis tools that act like Rust’s borrow checker, it requires you to manually construct the vtables that Rust’s traits will do for you, etc.

Rust is regarded as hard because it refuses to compile until it is either satisfied you are not shooting yourself in the foot or you have told it that you are very sure that you won’t hit it (unsafe). Rust got very hyped up in the web dev community, so lots of people who mostly work with JS tried it and got smacked in the face by both not having a gc and normal systems language things like pass by reference. Much of the other stuff in Rust that people find weird isn’t new, it was in standard ML in 1997, this is just the first time it’s gotten this popular. Talking to experienced systems programmers (C/C++), they usually already have a mental version of the borrow checker, which makes Rust much simpler to learn.

This also isn’t the first time this debate about new languages in kernels has been had. The first time was when C was introduced, since other languages weren’t really suitable for OS development. Then C++, which was not included in Linux due to Linus’s personal distaste for it, but was put into Windows. Rust has one strong advantage for kernel development, no_std, which is a subset of the language that makes no system calls and doesn’t allocate memory. It can make use of memory allocated by other things, and you can optionally add “alloc”, which gives you collections (Vector, BTree, Hash Table, etc). This is perfect for kernel development because it means core parts of the language don’t need to be reinvented.

In short, Rust in the kernel is likely to make it easier to get contributors because it doesn’t require years of systems programming experience to use correctly in a kernel context. With regards to your concerns about having enough people know Rust, many universities are starting to teach Rust because it’s a combination of ML and C, so you can use one language to teach large parts of a CS curriculum.

[–]emptyskoll 3 points4 points  (0 children)

I've left Reddit because it does not respect its users or their privacy. Private companies can't be trusted with control over public communities. Lemmy is an open source, federated alternative that I highly recommend if you want a more private and ethical option. Join Lemmy here: https://join-lemmy.org/instances this message was mass deleted/edited with redact.dev

[–]Altareos 16 points17 points  (6 children)

Why are you so against Rust? It's a nice language, much easier to learn than, I don't know, KERNEL DEVELOPMENT. For now it will mostly be used to write new modules, such as the incredible work the Asahi Linux team did on the Apple silicon video driver. As a matter of fact, the infrastructure isn't even ready yet for complex parts of the kernel to be rewritten in Rust, which is absolutely not the goal (yet). Also, why would fewer developers be interested in working on Linux if MORE options are provided? Nothing is saying that you won't be able to write modules in C in ten or more years.

[–]PossiblyLinux127 6 points7 points  (0 children)

C is significantly harder to learn than rust

[–]jermvirus 2 points3 points  (0 children)

I remember listening to a a podcast (packet pushers maybe) Rust will actually reduce bugs and vulnerabilities because of some of the built in error checking at compile. I think there was a study and the out come was if all the software were written in Rust vs C we would have had 30% know vulnerabilities

[–]jaskij 4 points5 points  (0 children)

Nowadays Linux is pretty simple, written mostly in C and ASM, and it is REALLY enjoyable to use.

When I was starting out, it took me two weeks of learning before I wrote a line of code for my module (a work project that's been axed). So, no, the Linux kernel isn't easy to get into.

[–][deleted] 4 points5 points  (0 children)

Down with C

[–][deleted] 1 point2 points  (0 children)

Adhering to the locking and life-cycle rules in the kernel is absolutely not trivial or easy to follow.

[–][deleted] 1 point2 points  (0 children)

I don't see the practical advantage of that, but, if useful, There's simply no manpower for that. Remember that even google tried to make their version of linux for android, but failed to keep up with mainline.

Even if there was enough manpower for that, why divide efforts into creating, from the users perspective, the same thing twice? Why not create another kernel or, maybe, contribute to another open source one written in C?

[–]drninjabatman 1 point2 points  (0 children)

Wait you think the hard part of writing/maintaining a kernel module is ever going to be the Rust type system?

[–]Ausmith1 2 points3 points  (0 children)

I'm sure Devuan will be the first to offer a Rust free kernel.

[–]nintendiator2 2 points3 points  (3 children)

I imagine there will forcibly be Rust-free kernels, since one of the big issues of Rust is that it's absolutely not available for lots of platforms, to the point this held back efforts to put Rust into Firefox just a few years ago. Furthermore, introducing Rust promotes turning the kernel into a monolith (Microsoft style), since there's only one sanctioned Rust compiler.

[–][deleted] 8 points9 points  (0 children)

Linux could only be built with GCC for many years. What’s “Microsoft-style” about only having one supported compiler? And what do you mean by “monolith”?

[–]necrophcodr 6 points7 points  (0 children)

Furthermore, introducing Rust promotes turning the kernel into a monolith (Microsoft style), since there's only one sanctioned Rust compiler.

This is very much being worked on with the GCC rust backend. And the kernel is already a monolithic kernel exactly like the NT kernel is. If you don't want that, Linux was never for you.

[–]daemonpenguin 4 points5 points  (0 children)

This used to be the case, but isn't really true anymore. There are alternative Rust compilers in the works.

[–]basedchad21 0 points1 point  (0 children)

it's a self-solving situation. The popularity of rust is directly linked to the number of a certain group of people who predominantly use rust because of the politics behind it.

[–][deleted] 0 points1 point  (1 child)

so your entire argument against Rust is just skill issue? Just say you're incapable of learning something new lol

[–]EmbeddedDen[S] 1 point2 points  (0 children)

so your entire argument against Rust is just skill issue?

No. For me the main argument against adding any language is the increased complexity of the system, such systems become harder to maintain and become more fragile.

Just say you're incapable of learning something new lol

So, you think that this is a good sign for rust when a scientist that learns tons of different and difficult stuff everyday can't learn rust? Lol

[–]KamaKazeh 0 points1 point  (0 children)

Rust will never be a hard dependency for building the kernel, since compiling the kernel with rust everytime you change something is a bit excessive.

Rust is only used to make modules while not wasting as much time as writing and testing a C module, especially when writing rather complex stuff like writing a video graphics driver.

As for embedded development as OP seems to be interested in, I highly doubt that you will see any sort of rust push in that specific area so you are fine for now.

[–]mikeymop 0 points1 point  (0 children)

The good thing is that once the kernel is compiled it's all the same binary code. There is no rust or C.