Linux Creator Torvalds Says Rust Adoption in Kernel Lags Expectations
Posted by unixmachine@reddit | programming | View on Reddit | 536 comments
Posted by unixmachine@reddit | programming | View on Reddit | 536 comments
sjepsa@reddit
Who would have guessed that a language that impairs you and makes almost impossible to do any meaningful low level stuff would have slowed the progression down?
ficiek@reddit
Ok, why do you people always post comments like this and never elaborate. As someone learning rust I am interested, please explain what you are referring to as I'd like to learn something. What isn't possible, how does the language impairs you, what low level stuff is impossible etc?
sjepsa@reddit
OMG you tried to modify an object that you passed to another function by reference... YOU. MONSTER.
Read the official take on Concurrency from Rust:
https://doc.rust-lang.org/1.8.0/book/concurrency.html
It's hilarious
You can't do something simple like this:
And say that it is a feature of the language.
Complicating simple stuff, because of 'safety'. It's like walking down the street with two blocks of concrete around your legs, to not fall
uss_wstar@reddit
Yes you can, who told you that?
sjepsa@reddit
OMG but that's unsafe!
eugay@reddit
𤥠you're embarrassing yourself and laying bare your lack of knowledge.
sjepsa@reddit
thread::scope is blocking
You do multithread a la python style: one after the other
eugay@reddit
No. Lmao seriously quit embarrassing yourself
sjepsa@reddit
All spawned threads in your code must have finished before thread_scope can go on -> blocking behaviour
What would the UB be in my code, I'm very curious
eugay@reddit
your vec goes out of scope before your detached threads are guaranteed to complete. they write to invalid memory.
sjepsa@reddit
OMG you were for real.... Just read this now.
The scope doesn't end... it's just a snippet. I can put a sleep after or do other code or it could be in main or whatever... if i wanted RAII i would just have used jthread...
The official Rust documentation https://doc.rust-lang.org/1.8.0/book/concurrency.html 'solution' lol:
Talk about overcomplicating simple stuff
eugay@reddit
Clown
KrisstopherP@reddit
Trash code, skill issue.
sjepsa@reddit
Implement a double linked list
Ok-Entertainer-8612@reddit
Honestly, not even joking, you never need to use a double linked list. You can write every piece of software without this data structure. No one needs it. And its performance is worse than the alternatives.
Anyway, you can implement it nonetheless, even in Rust.
warmwaffles@reddit
I don't think the double linked list is necessarily a heavily used data-structure. But a graph structure is and a double linked list is a hyper focused directed graph. So I think the challenge should be to "Implement a directed graph with BF search and DF search."
sjepsa@reddit
You can implement everything without Rust too
Kernel develeopers seem to understand that well, too
Craiggles-@reddit
I know most people are lazy about learning rust so they give up and move on. I really like rust. I think it has a lot of cool syntax and code structure. It's fun at times, but then randomly it's also super clunky. I program Typescript/Rust 50-50 split. I've also used Zig and c++ heavily. Rust is a CHORE. I'm sorry but it is, even if it's fun at times. It requires so much effort to do it the Rust way at random intersections of code. Oh you want a linked list? Well Rust...
I'm beyond tired of people saying it's the perfect bullet for borrowing/lending. The most egregious I've heard from Rust evangelists is "You don't have to do testing, you test when you write the code". Makes me want to metaphorically vomit as I spiral into existential dread and hopefully I don't even have to explain why. (Being pedantic because its fun)
Managing lifetimes is more often a bigger chore then mentally tracking ownership in other languages in my opinion. Pretty frequently I and many projects I've read resolve to just throw the data in a `Rc<RefCell<_>>` and call it a day. But I can't count the number of times I asked for mutable ownership of said rc and the test says I'm already borrowing. Don't worry, Rust still to this day doesn't do stack traces, so I have to spend a fuck load of time tracking down where my dumbass fucked up.
I honestly could rant for an hour, but I think my first main example already sums up the Rust experience. You sacrifice convenience and efficient solutions to solve the memory safety problem, and ontop of that Rust is still missing a ton of debugging tools that would make productively skyrocket 10x.
sjepsa@reddit
Yeah that's what I call "the compiler is fighting against you"
YeetCompleet@reddit
It's just a common theme in r/programming. It happens a lot with any language tbh, there's always multiple people in the thread saying x language is shit, isn't suitable, has a bad community, and we should use y instead. It's largely un-nuanced. I'd ignore it.
jonski1@reddit
Damn, you tried Rust, got hurt and now you spit bs wherever you land? Generally curious. I wonder if you even read through the short article or just saw the title and went into auto-mode.
sjepsa@reddit
Read the rust tutorial/ manual, read that is just another language pretending to be the solution to all problems, while still having all the usual problems (thread safety, object lifetimes, bad ) while having performance downgrades compared to C++ and 1% of its libraries, and a religious community ignoring all of that, and just went away from this BS
UltraPoci@reddit
You sure write a lot of comments about Rust for someone saying they "went away from this BS"
sjepsa@reddit
This time I am happy that even Linus, a fervent C++ hater, has understood that Rust is a piece of hot garbage and moving away from it
Caluka1337@reddit
You have really bad reading comprehension if that's what you understood from what Torvalds said.
sjepsa@reddit
Non what he said. What he understood. None of his developers are following that BS move about introducing Rust
Caluka1337@reddit
Ok so you basically pretend to know what he was thinking so that it fits what *you* think.
I dont know dude, you shouldn't be prematurely celebrating rusts leaving the kernel when nothing points to it.
stumblinbear@reddit
Bruh have you even used it for more than a few days?
sjepsa@reddit
Luckly no
stumblinbear@reddit
If you've never used it, why do you insist on having an opinion? You are, of course, entitled to your informed opinion, but you haven't even used it. So why bother saying anything?
sjepsa@reddit
Yeah I don't need yet another GRAIL language. I tried java in the 90s, and I still program C++
There's a way to improve C++: improve C++
Not creating yet another C++ killer.
Rust has like 1% of the libraries C++ have. What do i have to do with that?
Should I create my next real time project with rust? It's slower, gives more constrictions, 'solves' literally just a couple of C++ problems, doesn't have libraries.
And i should learn it and its caveats from the beginning
It's not me that must state why I avoid rust(yet another language). It's you that must state why I should switch to rust
stumblinbear@reddit
You can't undo bad decisions in the language, only monkeypatch and advise against using broken things.
Rust isn't just another basic language with a slightly different syntax to C, it actually brings new things to the table that C++ literally cannot without breaking changes or splitting the ecosystem completely. It brings real, tangible new concepts that enforce strict standards and improves overall code quality and safety.
Citation needed. I'd argue that given the time to implement more optimizations in LLVM catered towards
noalias
, it could genuinely end up being faster in many benchmarks. In real world programs it's generally on par with C or C++.I've never been left wanting when searching for libraries to use
You're free to like and prefer C++. Go nuts, that's your prerogative, and I won't try to change your mind on that. My only point is that you're bashing another language you've never used for no other reason than that a group of people believe it's superior to C++.
I personally don't see the hype for Zig, but I'm not going to diss the language and push people to use Rust instead.
sjepsa@reddit
Citation needed for speed?
What about, mandatory mutexes and locks everywhere?
Bound checks for EVERY array dereference in the kernel....
stumblinbear@reddit
Mandatory mutexes? The things you also need in multithreaded C and C++?
Bounds checks which you can get rid of by guaranteeing to the compiler that it can never go out of bounds? The bounds checks that prevent the security vulnerabilities that exist in pretty much every C/++ program in existence at one point or another?
In many benchmarks and actual real world usage, it is on par with C and C++, if not faster in multithreaded workloads due to developers being less defensive when programming leading to fewer locks and slower code overall.
sjepsa@reddit
There are mutexes in C++, of course. There is everything in C++. BUT you are not forced to use them. C++ gives you power
I could write, or someone more smart than me could, a lock free multithreaded data structure (and they did) in C++
We were talking speed and you asked for example. Bound checks in every call are slower. Period
coderstephen@reddit
The power to have data races in your software? I'm OK to pass on that power, thanks.
sjepsa@reddit
Power to implement a double linked list
Like 1980, you know
coderstephen@reddit
It isn't 1980 any more, and linked lists aren't as commonly useful any more. But there's a doubly-linked list in the Rust standard library so it's not like it is impossible to implement. But I agree that its more difficult than in C and is kind of a worst-case scenario for Rust's strict rules. But for good reason, because ownership of linked lists are difficult to reason about.
stumblinbear@reddit
Lock free multithreaded data structures exist in Rust
coderstephen@reddit
Bounds checks can also be avoided if you need to, so there's that. Always benchmark to figure out what optimizations are actually relevant, and that applies to every language.
coderstephen@reddit
It impairs you to prevent you from shooting yourself in the foot. It's true that the Rust compiler doesn't accept all valid programs, but the compiler does reject all invalid programs. That's a pretty desirable property to have, when one mistake could turn into a serious CVE in an important project like Linux. At the end of the day, Rust is a compromise though -- you give up the ability to use certain techniques in exchange for the confidence that safety validation provides.
sjepsa@reddit
Ohh it rejects all invalid programs.
So i can't write programs that deadlock? So i can't write programs that run out of memory? I can't write programs that throw endless ecxeptions, or do not handle exceptions correctly?
Nice
sqlphilosopher@reddit
I don't know why the downvotes tho... anyhow meaningful low level requires unsafe because hardware is inherently unsafe. Yes, you can make a wrapper around the unsafe code, but you can do that in C as well (see, NASA or any other dev work in critical areas). So, it is really pointless, I'm not sure what benefit Linus is seeing here. Not to mention the complications of working with two languages, and the fact that Rust's leadership is full of nut jobs, and that the language doesn't even have a standard.
SV-97@reddit
Because that's nonsense. Low level code is not unsafe every step of the way and doesn't prod at hardware in every last line. Even in embedded the fraction of code that actually has to be unsafe is comparatively small.
Most people are not NASA. And some of NASA's projects are literally writing Haskell and compiling to C. Is that really what you want to argue for?
sjepsa@reddit
Most people shouldn't write time critical stuff in the linux kernel
If you do I hope you know what you're doing and don't need somebody to hold your hand
SV-97@reddit
We're discussion a situation where the prior is that people write stuff in the kernel though
And if you're seriously still using the "the only issue with C is your skill issue"-argument in 2024 there's no point in discussing this at all honestly. We have decades of data showing that this is bs and anyone that ever used C in a critical context can tell you as much.
sjepsa@reddit
Yeah, add python to the kernel, so everybody can contribute
SV-97@reddit
Okay apparently you haven't understood the other comment and decided to just make up a strawman. Let's try this again:
This is not about some hypothetical future developer that doesn't match whatever your elitist criterion for a "TRVE 10x DEVELOPER" is - it's about the people that are writing software today and have for the last few decades. We spend vast amounts of developer time on reviewing and testing code in the hopes that we catch all mistakes, but yet some still slip through and cause issues. We have actual decades of empirical data suggesting that no, these issues (in the form of bugs and exploits in real world systems) are actually not the result of everyone being a "low-skill junior retard that doesn't know what they're doing" but rather that they come from C's inherent unsafety.
We can statically prevent those issues by making them impossible at the language level. No we don't lose power or expressivitity by doing so. (In fact we gain quite a bit in expressivity, but of course if you only ever shake your fist and yell at the clouds you can't know that).
sjepsa@reddit
You have to write 8x the code to comply to the borrow rules. You have to write convoluted mess to circumvent who owns what. Who wants to do that?
Surely not the kernel guys. And you know what? They are right.
I'd rather have one 'ownership' bug a month (that you can resolve in a hour), and program easiliy and with expressivity (i am talking about C++ RN), than have to program all the month fighting against the compiler to have some (single threaded) memory safety guaranteed against 2% of the bugs a program might actually have
SV-97@reddit
No you don't. Most of your comment is flat out wrong and you just make it clear over and over again that you don't know the language at all (which is fine but then you shouldn't talk like you do). Rust doesn't "just protect against ownership bugs" and it can give very strong guarantees in concurrent code (always data race freedom, for some things also the absence of deadlocks as well as strong realtime guarantees).
C++ is irrelevant here. C++ in the kernel isn't going to happen.
TheLivingFlannel@reddit
You don't see how a language which is safe by default, and only requires opting into unsafe constructs when necessary, has no benefit over a language that is unsafe by default and requires a lot of work to opt into safety features?
sjepsa@reddit
That has a price, in program performance and in expressiveness of code.
"If writing the same kernel code in Rust requires eight times the amount of code, they will stick with C."
And that's EXACTLY what's happening
What you call 'safe', is just avoiding a SMALL set of problems, that you avoid at the price of being coerced in a very rigid programming paradigm
And that just vanishes in multithreaded applications
sjepsa@reddit
Lol @ safe by default
ThomasWinwood@reddit
How do you tell during code review which APIs are safe and which are unsafe in C? In Rust it's easy, the unsafe ones have the word
unsafe
written next to them.sjepsa@reddit
So rust code can't throw infinite exceptions?
Can't deadlock? Can't run out of memory?
They can't crash.
They are safe by definition
Maykey@reddit
EZ. Just use Coq as seL4 does. it even protects from compiler bugs as verification is done on binary.
Anyone who think rust is complicated will be relieved to write
Look ma, no borrow checker required
sqlphilosopher@reddit
Safe code: code that does not do anything unsafe such as dynamic memory allocation or function pointers. Unsafe code: code that does. It's not that hard.
Glacia@reddit
Sorry Linus, Rust developers are too busy writing Game engines that no one uses and "X but in Rust" software.
jjeroennl@reddit
50 game engines, 0 games
stumblinbear@reddit
I know you're joking, but games using rust have been released
vondpickle@reddit
It's sad that the game Rust didn't use Rust. Idk about the game though but I think that's the case.
Drogzar@reddit
Yeah, game that released in 2013 wasn't done in a language with the first stable release in 2015... that's sad... what a lost opportunity...
AnastasiosThanatos@reddit
That's no excuse! Type safety is more important than stability!
the-code-father@reddit
Rust the game was released in 2013, and Rust the language didn't have its 1.0 until 2015...
andrerav@reddit
Can't the devs just rewrite the game in Rust? So sad
andrerav@reddit
What a take.
GreatWoodsBalls@reddit
Any examples? I know of Veloren from it's early inceptions.
Kevathiel@reddit
Steam
Fields of Mistria BITGUN Hydrofoil generation the Gnorp Apologue GUNRUN Factor Y Tunnet USG
Work in Progress
Tiny Glade Times of Progress
eenum@reddit
Uh... fields of mistria is a gamemaker game
Kevathiel@reddit
That uses dlls made with Rust and internal Rust tools.
eenum@reddit
Where did you get that information then?
Kevathiel@reddit
Rust Game Dev Discord. You can search for the game and find a bunch of posts of one of the devs. They also have a GitHub. Keep in mind that these repos are not all their Rust code. It's only the parts that they made public.
One quote from the Discord:
eenum@reddit
I do think it will make console ports more tricky for them but what do I know
eenum@reddit
Cool!
_Unity-@reddit
These examples are specifically made in Bevy. It has to be noted, Bevy just turned 4 yo and is not production ready, yet it's api is now considered mostly stable and according to the lead dev birthday post the official editor plugin and scene file format is expected to be released soon which would be a huge step towards production readiness. In my opinion bevy provides the best game architecture on the market aside the fact that it's free and open source plus the usual range of advantages of rust.
Anyway here are some notable games done in Bevy:
Mythique@reddit
Tiny Glade isn't made with Bevy, it's a custom engine. They use the ECS system from Bevy though. Information from their FAQ.
_Unity-@reddit
However what does this mean? I would interpret this as them using Bevy without (many) Plugins.
_Unity-@reddit
Ok thanks, didn't know that!
GreatWoodsBalls@reddit
Tiny glade looks dope, I'll check that one out
aystatic@reddit
me and the homies playing https://store.steampowered.com/app/1448820/Hydrofoil_Generation
AlienRobotMk2@reddit
I thought there would be a crab player character. Nope.
I Ctrl+F "in rust." No result.
I don't know what I expected.
setoid@reddit
I know you're joking but I'm somewhat relieved that the steam pages doesn't contain "in rust", because it shows that Rust is maturing enough to the point where people are writing software where the fact that it is written in Rust is not a big selling point. I mean there's always been useful software written in Rust, but my first impression of the Rust community is that they cared more about the language than the product.
Turtvaiz@reddit
Not even blazingly fast??
aystatic@reddit
sorry to disappoint, i know of this game where you play as a crab , but it is in unreal
KokiriRapGod@reddit
Don't forget Another Crab's Treasure.
AlienRobotMk2@reddit
This is embarrassing. I should make a game in Zig where you play as an iguana while rustaceans are distracted.
SylphStarcraft@reddit
Rust too https://store.steampowered.com/app/1032170/Robo_Instructus/
aniforprez@reddit
(the) Gnorp Apologue is written in Rust and was created because the developer was experimenting with the language
TomWithTime@reddit
Bevy is fantastic so we can also expect some RTS games in the future
JamesGecko@reddit
Ikenfell is Rust IIRC.
Kevathiel@reddit
It's not. The dev moved over to Rust though for his next game.
Red_not_Read@reddit
Adorable.
MaleficentFig7578@reddit
but rust isn't a game using rust
Dwedit@reddit
Meanwhile the rather obscure programming language called "Beef" has at least one major shipped game (Penny's Big Breakaway)
rom_romeo@reddit
Even freaking Haxe is rocking in comparison with Rust when it comes to games. E.g. Papers Please and Dune: Spice Wars are written in Haxe.
Dwedit@reddit
Haxe is really close to Flash Actionscript, so that's not all that surprising. Dead Cells was especially an example of using Haxe for a bestselling game.
noboruma@reddit
that no one uses as well.
Turtvaiz@reddit
Not really though. There's quite a few popular ones. Like the recently release
uv
seems to have gotten quite popular by just being python tooling but 100x faster. The "written in rust" marketing does occasionally make a lot of senseThere's also a ton of smaller tools that are definitely not unpopular
TheFeshy@reddit
Typst is such a game changer. It's still early days, do it doesn't yet cover the entire breadth of LaTeX's options. But if you can use it, it's so much better.
simonask_@reddit
Most of those are hobby projects that people really shouldn't use, but one wildly successful example that comes to mind is ripgrep.
Delicious_Ease2595@reddit
Lemmy is also written in Rust.
Turtvaiz@reddit
And some I can think of that I use: hyperfine, eza, bat, oxipng, alacritty, ruff (on web pages), inferno (flamegraph).
Then there's some very popular projects trying to replace ubiqutous software like typst-latex, and jj-git
realityChemist@reddit
aura is being ported from haskell to rust as well
shevy-java@reddit
Haven't heard any of these.
fossilesque-@reddit
nobody uses Lemmy
Delicious_Ease2595@reddit
64,900 monthly active users
Interest-Desk@reddit
More people live on a long urban street.
noboruma@reddit
Have been using the async grep: ag way before `ripgrep` came out.
Never understood the hype, sure it's an improvement compared to `grep` (and happy to hear if there are better improvements compared to ag) but anyone serious had already moved from `grep` for a long time.
burntsushi@reddit
ripgrep has been around longer now than ag was alive at the time ripgrep was released.
When I released ripgrep, I published a blog post that did a performance comparison between it and ag. So you should be very happy to hear about it! There's also plenty of feature and correctness improvements. For example, better gitignore support, transparent UTF-16 support, preprocessor support, and more. Moreover, ripgrep doesn't use an end-of-lifed regex engine. Woohoo!!!
noboruma@reddit
Thanks for answering. I was acknowledging the fact ripgrep is indeed used (maybe that part was not clear on my end) but I personally never saw the need to move as it is not creating anything new to my workflows, which follows up with my initial comment. Lots of rust projects are marketed as improvements rather than entirely new paradigm shifts, which is why very few are used IMO.
Since you mention ripgrep has been there for a long time now, I am curious to hear about how it is to maintain it?
simonask_@reddit
Sure, ag is great. So is ripgrep, I encourage you to try it out. :-)
gefahr@reddit
ag is called that because the project title is "the silver searcher". wordplay on silver surfer. And ag is the element symbol for silver.
campbellm@reddit
I love ag, mostly because the emacs integration is a little smoother for me. But I use both.
shevy-java@reddit
People often abandon those hobby projects. It is not just a problem in Rust, though one can see it more clearly in Rust: dude picks up Rust, writes something to tickle his fancies, then abandons it at lightning speed.
eX_Ray@reddit
Do you actually believe this or are you just using hyperbole?
shevy-java@reddit
Yes.
Ran4@reddit
Alacritty is quite popular, and so is ruff
Proof-Aardvark-3745@reddit
Ruff is good
qqqrrrs_@reddit
I thought this is about "Linux but in Rust"?
jonski1@reddit
Switching to a more modern topic, the introduction of the Rust language into Linux, Torvalds is disappointed that its adoption isn't going faster. "I was expecting updates to be faster, but part of the problem is that old-time kernel developers are used to C and don't know Rust. They're not exactly excited about having to learn a new language that is, in some respects, very different. So there's been some pushback on Rust."
Seems like C devs need to be sorry for not wanting to learn anything but C /s.
abuqaboom@reddit
Lol, there's nothing for C devs to be sorry about.Â
For C long-timers, the gulf between C and Rust (and C++ for that matter, despite the syntactic familiarity) may be wider than GC langs to RAII. And there's the borrow checker, traits, pointer wrappers etc that simply don't exist in pure C.
Give motivated long-timers a choice between an old lang they're highly familiar and productive with, vs something completely new that puts hurdles with the old ways... I think the result is entirely predictable
SV-97@reddit
Or types... ;)
dontyougetsoupedyet@reddit
Not only does C have types, you even explicitly require subtyping to model the language semantics. Food for thought.
SV-97@reddit
This was a joke. Of course C has types and the standard goes into them extensively, but C's typesystem is so weak, inexpressive and (by modern standards) bad that it might as well be untyped.
Rudy69@reddit
I thought they were too busy posting messages online trying to convince everyone that Rust is the best?
General-Jaguar-8164@reddit
Or HFT systems
Pharisaeus@reddit
I've seen more HFT job offers in Java than in Rust.
ficiek@reddit
The kernel is also a project that is much harder to contribute to than other programming projects.
bruisedandbroke@reddit
gdb consistently terrifies me
derp420stonks@reddit
cause rust sucks?
XeonProductions@reddit
Rust is not easy or fun to develop with, it's rigid coding standards make it a nightmare to work with. I don't see it superseding C or C++ anytime soon. The Rust community is also toxic IMHO.
Connect_Swim_9177@reddit
Do you mind expanding on why you think Rust is a nightmare to work with? This has not been my experience at all. It's definitely not simple in the sense that Python is simple, but it's a powerful and versatile tool for an experienced developer with much to offer in terms of program correctness.
camilo16@reddit
I use it professionally. The main issue is that the BC is pedantic. My quintessential example is, try getting two mutable references to two disjoint indices in an array.
You know that they are disjoint, but the BC considers it a double borrow of the same type.
Similar pedantic points of friction occur constantly.
Lex098@reddit
Maybe I didn't understand your problem, but you can do it in at least 2 ways: in stable rust and more ergonomic, but unstable version.
There is work to be done to make Rust better, but your example has already been solved.
camilo16@reddit
This is just an example. The point is not that this specific problem cannot be solved. It's to show how the conservative nature of the borrow checker leads to situations where the programmer is certain everything is fine, but the BC can't prove it.
This forces the programmer to become sidetracked in making the BC happy rather than focusing on whatever pragmatic problem needs to be solved.
Lex098@reddit
I've seen too many "everything is fine" code that breaks after some changes in the completely different part of the code. Borrow checker allows you to make sure that it's not only fine now, but it'll be fine in the future. I'm so tired of fixing bugs that could have been prevented with BC.
camilo16@reddit
I hate this line, it's such an obtuse response. The standard library for rust uses unsafe in many, many places. The entire point of unsafe is that many times the programmer DOES KNOW BETTER than the BC.
The language has a mechanism to bypass the BC precisely because it is aware that many situations call for things that are sound but that the BC cannot prove.
ffs, I really want the rust community to stop repeating this line like if it was a religious mantra. The BC helps, the BC also gets in the way.
juhotuho10@reddit
Unsafe doesn't disable the borrowchecker, it just gives the developer a couple of extra powers like dereference a raw pointer
https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#unsafe-superpowers
Lex098@reddit
For regular code it's not true for 99% of the time. Most of the times people don't know enough to understand that they, in fact, do not "KNOW BETTER", e.g. Rust std bug. Two completely separated parts of the code, but if you use them together - they explode.
Maybe because Rust moved from "trust me bro" to "prove it's correct" it's 70 times less likely to introduce vulnerabilities.
camilo16@reddit
Yes, no one is arguing the BC is not useful. But you need to understand that some problems require you to bypass the BC. This is precisely why unsafe exists.
r1veRRR@reddit
It's pedantic about things that could be bugs. If you're actually a good developer, you'd need to either account for the potential bugs yourself or (like a lot of C developers) simply pretend it's all just skill issues.
camilo16@reddit
Please read the rest of this thread. I don't want to re-state all of the prior arguments.
eugay@reddit
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.split_at_mut
camilo16@reddit
It happens a lot in single threaded graph based data structures, which is something that I need to work with on the regular due to my specialization.
Almost everything I do is linked-list like graphs, and there's no other way to do it. As you can imagine, this often leads to situations where the BC is not happy.
Glacia@reddit
I'm not against strong typing, but in my experience it's definitely negatively affects productivity. You end up spending way too much time fighting compiler and very little time actually "getting stuff done". It's basically a programming bureaucracy. Yes, the intend is good, but in 95% of times you're wasting your time for nothing. If the programming community was actually mature we would try to find some middle ground, but unfortunately we're not there yet.
bwainfweeze@reddit
How much of a development task would you say you generally spend on refactoring first? Do you believe in the saying, âmake the change easy, then make the easy changeâ?
My last project was in NodeJS. It had 40 devs at one point. Thats a lot of code. I counted once and half of the lines of jsdoc in the entire project were mine. Itâs not that I wrote so much but that others wrote so little. Now that is a nightmare.
Glacia@reddit
Even C would seem to have strong typing against any dynamically typed language. It's completely out of the scope of what i'm talking about.
SV-97@reddit
What. No? Dynamicism and strength are completely orthogonal. Python is dynamic but still stronger than C.
Glacia@reddit
It depends on what you mean by strong typing. It's vague term in many ways. If I change a function name in C, compiler will tell me where the function was called, I don't need to grep the whole codebase in hopes I didn't miss a function call.
The fact that type checking happens at runtime makes it much weaker no matter what, imo.
SV-97@reddit
Fair enough. For me implicit coercions (or rather the absence thereof) and type safety are what makes a system strong - in turn I'd classify C as one of the most weakly typed languages around.
Detecting calls to undefined functions isn't something I'd consider part of the typesystem at all for the most part. Sure, given a sufficiently strong typesystem with static checking the absence of undefined functions falls out as a side-effect of typechecking but we can run similar checks on languages that would usually be considered entirely untyped.
I'd take a runtime error over "it compiles but the runtime behaviour is complete nonsense" any day personally.
Glacia@reddit
From purely academic standpoint your idea of what strong typing is 100% correct. Honestly, the only reason i called it strong typing is because i dont know any alternative term that suits it better. Someone should probably make one.
pattheaux@reddit
Sorry, the hive mind does not currently allow this opinion.
Glacia@reddit
Most of the reddit is webdev kids who use python, js etc. For them having typed arguments is the enlightenment of their life and peek of strong typing.
Connect_Swim_9177@reddit
As someone who's currently dealing with what used to be a completely untyped Python project at work, sorry but hard disagree here. The benefits of types are obvious and numerous, and the errors they prevent are real. Don't take it personally, but I'm honestly at a point where I can't help but question the professional experience of anyone who doesn't see the utility in static analysis.
Glacia@reddit
You're missing the point i was making. We're talking in the context of compiled languages, so C is my bare minimum weakly typed language. I didn't talk about dynamic typing, that's just plain dumb.
First sentence in my post was "I'm not against strong typing", so how come you came to this conclusion? I understand the utility. I've used strong typed languages before Rust even existed.
Connect_Swim_9177@reddit
Are we just going to gloss over the fact that the rest of your comment talks about how types are "neatively affecting productivity" and "wasting your time for nothing"? I don't see what other possible interpretation I was supposed to pick up from that.
Glacia@reddit
I'm not a native english speaker, so maybe my message wasnt clear, but i was trying to say that there is a definitely a trade off between how strong typing is and how productive you are. Meaning strong typing is good, but to some extend.
TheWix@reddit
Yea, I don't get the point they are making either. If you are fighting the compiler it means the compiler is telling you that you shouldn't be doing exactly what you are trying to do.
I was a .net dev since the mid-00s before switching to node and typescript. Aside from the node ecosystem being trash TS is great. The typing is much stronger than C# and I can catch way more at compile time. That is a huge benefit.
uss_wstar@reddit
Promotion is the worst feature of C by far and Rust making nearly all conversions explicit is an objectively good change for its use cases.
Glacia@reddit
I wouldn't call it the worst (wont even be in my 10 worst things about C) but Yes. Not sure how it related to my post though.
tLxVGt@reddit
If you âfight compilerâ on a regular basis then I wonder what your code looks like.
This is the very reason for strong typing - I want the compiler to complain as much as possible and point out gaps in my thinking during development. The opposite is runtime errors on production because someone forgot to update some dependency, which Iâd much rather avoid at all cost.
all_is_love6667@reddit
its syntax is hard to read
steep learning curve
always fighting the borrow checker
Ok-Entertainer-8612@reddit
After writing a bit of Rust you will completely stop fighting with the borrow checker and code becomes easy to read. Itâs just a bit of practice! You should try again sometime.
AlienRobotMk2@reddit
Not OP, but I found Rust's syntax very complex so I gave up on it. Then I tried Zig and it was very easy. Until I had to deal with dividing one number by another, then it was a nightmare.
Ok-Entertainer-8612@reddit
Rust is easier now than it used to be 5 years ago. You should try again. You can write a lot of code without using a single lifetime, for example. Not that lifetimes are difficult to understand, but I know a lot of people are afraid of them.
__loam@reddit
I bounced off Rust and have been learning Go and Zig for similar reasons.
nekokattt@reddit
Was thinking of looking at learning Zig, can you elaborate?
AlienRobotMk2@reddit
Zig takes "no hidden control flow" seriously, which means that "x + y" doesn't implicitly cast unless it's trivial to do so.
You can't event divide an integer by another integer in zig. https://www.reddit.com/r/Zig/comments/12kg2up/signed_integer_division_why/
Because 2 / 3 could be 1 or 1.5, so you need to use @ divTrunc (space because Reddit makes it an user link), which isn't a normal function, but a compiler function.
The syntax to cast things is ridiculously long. You need to use as(type, value). But as doesn't cast, it just sets the target for the compiler. So you would need as(i32, floor(value)) for example.
This can get so ridiculous and verbose that when I tried to make a game with SDL, I could barely read the formulas that I was writing because 90% of the line was casts. It's really not readable at all, and I don't think they'll ever want to fix that.
Also note that part of Zig's design is that the AST can parse any line without looking at other lines. Which means there are no multi-line comments or multi-line strings. The official suggestion seems to be just surrounding a block with if(false) which makes the compiler ignore it, but that doesn't help with any syntax errors you may have in the code. That sucks, to be honest.
But it compiles REALLY fast, so you just ignore these minor inconveniences like these because whatever time you waste with it you would have wasted waiting for other low-level languages to compile. So it's worth it.
sad_bug_killer@reddit
if you type `@divTrunc`, you'll get
@divTrunc
dontyougetsoupedyet@reddit
In low level code Rust is simply antithetical to the types of things you often need to do in order to get your job done, like receive and work with a heap initialized object that never moves. You end up with programs full of zero sized types in order to pass information around the rust compiler, so your code becomes a mess of information purely for the compiler and not about your actual task/goal you're programming for. Collaboration goes out the window, because only very experienced Rust engineers can follow your code and you're now tied to nightly releases necessarily. For a 17 year old language that's meant for systems programming the offering is simply not very friendly/enabling for low level engineering work.
SKRAMZ_OR_NOT@reddit
It's not even ten years old (Graydon Hoare's experiments ended in Rust, sure, but the language was completely unrecognizable until 2014), and it was created for use in web browsers, where you already have quite a bit of abstraction from the hardware. Rust-in-Linux was a pipedream until a few years ago, and I wouldn't be surprised if it takes several more years to stabilize, but clearly steps have been and are being taken.
palmin@reddit
Pretty sure kernel developers will not shy away from a little toxicity.
MengerianMango@reddit
Not all toxicity is the same tho. Going to be interesting to see Rust furry toxicity mix with Linux boomer toxicity.
sixbrx@reddit
Older Linux developers are more Gen X than boomers I would think.
ToTheBatmobileGuy@reddit
Rust community? Toxic?
Compared to Linus, this community is tame.
Linus will chew you out and call you names your mother would be offended by on a public forum.
Kernel devs, via survivorship bias, have super thick skin.
bwainfweeze@reddit
Which makes me wonder why they looked at rust at all.
Thick skinned people usually have a problem. They will tolerate loads of bullshit by white knuckling through it instead of remembering that theyâre programmers, and thus any tedious and repetitive parts of their job they can write code that either takes care of it or at least reduces the friction.
But itâs great for job security so they usually scare off or outlast the more progressive people who write lightweight tools and processes Instead of white knuckling their way through life.
Now I donât know much about the Linux engineering culture, but my ass twitches every time someone calls a dev I have to think about âthick skinnedâ or other so-called compliments that sound like liabilities to me.
Lucretia9@reddit
And where do we, those who have burnt out on c and c++ and sick of both but don't want to touch rust with a 10 foot barge pole go for work?
bwainfweeze@reddit
Yeah Iâm not your oracle for that problem. Professionally popular languages have always been C-like for the last thirty years or more. Thereâs a lot of places you could go but I donât know what your value judgements are.
I donât know how many people are going to end up using Zig. There are definitely Go jobs out there.
anacrolix@reddit
Linux kernel will be very good for Rust. It will benefit immensely from fitting into the space.
yawaramin@reddit
When was the last time that happened?
anacrolix@reddit
It happens every few weeks
yawaramin@reddit
Any concrete examples, or just vibes?
__loam@reddit
I think it's a good thing for the kernel that Linus maintains high standards even if he's an ass hole. He's not being an ass hole to purely be mean to someone, he's being an ass hole because the kernel is a massively important piece of software that he obviously cares deeply about.
PurpleYoshiEgg@reddit
I like Rust's rigid coding standards. Much better than C, because instead of compiler error in Rust, I always get segfaults in C, and not just because I misused memory (sometimes that's true). Usually there are so many libraries are poorly documented and assume a degree of familiarity with C I figure that I'll never reach at this point.
I'm trying to write a jack audio program right now, and it's surprising to me how extremely annoying and difficult it is to write something that won't segfault, is hard realtime capable, and can pass data to a main thread (which doesn't need to be realtime capable) without violating those hard realtime constraints. I've standardized on using GLib for strings, at least, because that's usually where I question life when I hit C code.
I'm about to drop it and figure out how to write what I want in Rust or Ada (specifically with the SPARK subset) calling out to the libraries I need. I've tried to figure out C on and off for over a decade (mainly because of the issues I run into whenever I use it), and it just isn't compatible with my brain.
On the flipside, I can return to a Rust project that's been sitting on my drive for a few years and pick up where I left off, and if I happen to cause a panic, I know exactly where it was (no need to compiled with
-fsanitize=address
to figure out where the crash is).lordwar1998@reddit
If you end up writing it in Rust, would you mind give an update just to show what was the process and how did you ended feeling throughout the development process VS what you did in C? đ
fondle_my_tendies@reddit
Woah, be careful talking about the rust community, you might get tens of downvotes.
bwainfweeze@reddit
Heaven forbid we make r/programming mad by stating an opinion that they donât understand. That would be terrible. Weâd have to quit our jobs and become hermits.
nekokattt@reddit
You mean like what happened with Actix?
https://github.com/fafhrd91/actix-web-postmortem
Not Reddit related, but related to the comment you are responding to.
bwainfweeze@reddit
Thereâs a tendency among programmer to value the intellectual above all else. But any therapist can tell you that trying to intellectualize everything is a coping mechanism with quite dire consequences on the rest of your life.
Thereâs a tendency here to downvote ideas that are backed by experience/empiricism if they are counterintuitive, because they donât sound truthy enough and they challenge âreasonâ.
Last time I bothered to care, my biggest downvotes werenât from saying something rude (though there are a couple cults of personality I enjoy poking occasionally). Theyâre from saying something peripherally about cognitive load that any cognitive scientist would agree with.
But thereâs this toxic macho (Calvinist) ethos in programming where some of us clearly wish we were computers and any talk of us being frail humans is the highest of heresies.
At this point I just call it job security.
erythro@reddit
*Jean Calvin stumbles onto this thread* wtf is a computer
Seriously though I'm pretty sure humans being frail is like the single core Calvinist belief lol
bwainfweeze@reddit
Calvinists believe suffering leads to an eternal reward. As someone once put it to me: It underpins most of US culture the way Shintoism is the undercurrent in Japanese culture - even if you arenât a member, youâre still practicing a subset of the beliefs.
erythro@reddit
this is literally the opposite of what Calvinists believe as I understand it. Calvinists believe nothing you can do leads to eternal reward, that it's literally about being chosen by God and nothing else. They believe people are weak and aren't capable of believing in God, they believe and are saved only because God specifically enables them to do so.
If I try to join up what you are saying with my understanding with a shot in the dark: there's the "how do I know I'm one of the chosen?" problem with Calvinism, which one response I guess could be something like "I know I'm chosen because my life is one characterised by perseverance through suffering", which might be where you are coming from?
This is true! But I would argue it's bigger than Calvinism. Your critiques of Calvinism will also be rooted in the historic debates about the reformation and Christianity going back from there.
avbrodie@reddit
Very well said. Downvoting ideas based on experience and upvoting based on the community zeitgeist.
Ironically it even happens in companies; remember when microservices were all the rage and you had people taking simple apps and complicating them to the point of obscenity?
bwainfweeze@reddit
The only thing I like about all of the retreaded AI talk thatâs been had every fifteen years since 1960 is that it shut up the bitcoin people.
neopointer@reddit
Same goes to the fictional programming languages fanboys đ.
LurkDog@reddit
Lmao was "fictional" a typo for "functional"? If not it's hilarious.
neopointer@reddit
Guess đ
Ok-Entertainer-8612@reddit
Itâs not that hard anymore. Rust isnât the same as it was 5 years ago. You should try again! A lot of pain points have been removed imo.
coderstephen@reddit
Have you ever worked on a large team project before? Rigid coding standards are a godsend.
_segamega_@reddit
samo people say the same for kernel community. btw linus is so polite and nice.
SV-97@reddit
Have you worked with C or C++ professionally? In large parts Rust just makes the stuff explicit that you have to deal with either way (be it during development, testing and review or debugging)
anacrolix@reddit
Its*
XeonProductions@reddit
fixed
LuckyHedgehog@reddit
Here is all that is mentioned about Rust
celalith@reddit
What does he mean by this?
YeetCompleet@reddit
I saw a GitHub issue somewhere before which listed all of the nightly rust features that Linux uses, so probably that
Localghost385@reddit
I'm no expert, but this doesn't seem like a situation to be using nightly features?
Tony_Bar@reddit
A lot of the replies seem to not understand that for certain things they need unstable features to get Rust to work at all for what they want to do.
Here's a talk from RustNL from a few months ago that examines one case of needing to use unstable features to get the job done: https://www.youtube.com/watch?v=gr9v0FFXaZ8
NMe84@reddit
If you need unstable features in your usually stable software product, maybe it's too early to start using the tech you're looking at...
There is nothing wrong with waiting until the software you want to start using is stable enough to do so.
juhotuho10@reddit
Rust nightly being unstable doesn't mean that it doesn't work, it means that the nightly functions are subject to change if need be
NMe84@reddit
....which is something you don't want in a stable piece of software used by millions upon millions of machines.
Tony_Bar@reddit
I don't really know the specifics (mostly why they didn't just use cpp instead for this) but generally I agree. Maybe cpp treats unstable features differently? Not sure.
stom86@reddit
Linux uses C and no C++ because Linus says so. As much as I like C++ I can understand the viewpoint. C++ is a large enough language that it is pretty much impossible for a single person to learn the entire language. If you couple that with a dislike of abstraction, or a dislike of bloat in terms of compile times and executable sizes stemming from template specialisations, then it is easier to understand his decision.
mrpeenut24@reddit
Then why add in Rust at all? Seems like that only adds more abstraction, bloat, and further dependencies.
max123246@reddit
The other commenter mentioned it but they didn't opt for C++ because maintainability is a mess. You basically have to get an entire world to choose to only use your "subset" of C++ that you have deemed safe and ergonomic. That's really hard to do within a company, much less on an open source project where anyone can contribute.
eugay@reddit
because https://security.googleblog.com/2024/03/secure-by-design-googles-perspective-on.html
sopunny@reddit
Linus was hoping the nightly features would be moving into stable faster, that's all
matjoeman@reddit
The kernel using these features might be the primary motivation for stabilizing them though. Seems like the kernel has a lot of needs that most user space software doesn't.
dontyougetsoupedyet@reddit
Nothing to be done about it,
allocator_api
,new_uninit
,get_mut_unchecked
and so forth are going to be required. A lot of things have to be invented, like support for the memory model and ways of performing practical things like pinned initialization (placement new...), because a lot of what you need to do in low level code like operating systems is antithetical to the way the Rust core team thinks code should be structured, so things like receiving a resource that is already constructed in heap memory and never moves for example is just not in the working model of what Rust wants programs to deal with. In Rust by default you don't create objects in heap memory, you create things on the stack and they immediately start being moved around, even simple things like initializing a Vec without copying it from the stack on initialization is arcane. That type of thing isn't what you want for kernel code. A lot of things coming out of the Rust for Linux work will eventually be in core Rust, but for now the project will have to crawl before it walks.josefx@reddit
How do Rust programs deal with shared memory and OpenGL or CUDA buffers? Mapping existing structures into a process seems like it should be a basic requirement.
dontyougetsoupedyet@reddit
You get a â&mutâ and do your best to avoid undefined behavior.
FamiliarSoftware@reddit
Pretty much the exact same way C or C++ do. You get a pointer and a size to the buffer and cast it to an appropriate slice. This step must of course be done in an unsafe block in Rust, but once you have your slice, it's just an array you can read from or write to.
If the CPU and GPU can read/write at the same time and it's not just being handed back and forth, you'll need to use atomic operations to avoid UB. Rust just copied the C++ atomics model because that's what LLVM expects, so the UB semantics and required atomics are also the same.
kiwidog@reddit
Curious about this too, because the last time I used Rust for those years ago, it was just C++ bindings for RS. (aka you couldn't at this time)
Kok_Nikol@reddit
The title literally has "needed" in it...
va1en0k@reddit
look through the list, (it's plausible that) they actually need them, and are not not just testing some fancy upcoming syntax sugar
tikkabhuna@reddit
The Rust project goals for 2024 include getting these into stable.
https://blog.rust-lang.org/2024/08/12/Project-goals.html
Dx2TT@reddit
Linux is a highly stable project. The idea of using nightly features in kernel should be met with extreme skepticism.
If Rust is truly the future then the diff between this year and 2 years from now is irrelevant. If Rust isn't the future, it shouldn't be used anyways.
eugay@reddit
They use stable versions of the compiler and simply force them to allow using "unstable" (read: not stabilized, prone to change) features.
Don't confuse it with using nightly versions prone to breaking.
va1en0k@reddit
the "major ones" but I'd expect a bunch of them lingering in the nightly for longer
bascule@reddit
They have a specific list of things which would be nice to get done this year for Linux but may be stretch goals, as it were: https://rust-lang.github.io/rust-project-goals/2024h2/rfl_stable.html#the-shiny-future-we-are-working-towards
They also say:
Also they want to get RFL into the Rust project's CI which could spot breakages to RFL when changes are made to rustc.
rebbsitor@reddit
If features you need are only implemented in a language in nightlies, you really shouldn't be using that language yet.
ridicalis@reddit
It's not entirely uncommon for Rust-based projects to depend on nightly features. That said, there's usually a strong push to either stabilize those features or migrate away at the earliest opportunity.
jl2352@reddit
Linux cannot use stable Rust currently. Work needs to be done to enable that, and any work in progress will be available via nightly. Hence why nightly is used.
In particular the Rust compiler has a lot of magic, hacks, and special code, that enables many bits across the standard library. Part of the work is to replace that magic code with standard stuff for all to utilise.
This is something Rust has been dealing with for years now. Not just with Linux (and itâs substantially better than in the past).
cdrt@reddit
Youâre right, itâs not. The kernel wants these features to be in a stable Rust release and thatâs what the issue is tracking.
nynjawitay@reddit
How are nightly features considered "infrastructure"? When I see "infrastructure" I think of things like docs pages ages cargo hosting and such. Language features aren't infra, are they?
Sloppyjoeman@reddit
In my experience âinfrastructureâ is a very broad term that has become even more broad now that we have software defined infrastructure. At this point, in my mind âinfrastructureâ just means âall the stuff thatâs needed to support the core logic of the softwareâ
Tiquortoo@reddit
People use infrastructure and ecosystem interchangeably quite often.
BufferUnderpants@reddit
Did you look? A lot are things related to memory, panics and use of assembly, these are directly applicable to kernel developmentÂ
nynjawitay@reddit
I didn't say nightly features aren't useful for them. It's just weird to me to call them "infrastructure"
skippingstone@reddit
I remember seeing a post where someone had old code that wouldn't compile anymore, despite his best efforts.
It would compile on his old laptop with a particular setup
chickenporkbeefmeat@reddit
Well that's... how code and compilers work.
tonymurray@reddit
He means it changes, not that it crashes.
matthieum@reddit
After some digging, he seems to be referring to infrastructure (for Rust) in the kernel.
It's unclear whether this means build-system or APIs, however. Both are reportedly unstable.
In terms of build-system, for a long time the Rust For Linux branch was using the nightly compiler, pinned to a particular version. There was no attempt at being compatible with any other version, so contributors may have been finding it hard to keep-up. The situation is better now, the latest Linux release is based on the stable compiler release (1.78) though compiled in bootstrap mode to use the unstable features still.
In terms of API, it is my understanding that they've been in flux, which is not unexpected as there's a LOT to do, and to get right, but does mean that any attempt at building on top of those may be frustrating. Building on shifting sands is never easy. I'm not sure if it's gotten better. I would expect it'll take them to shake them out.
Mognakor@reddit
Languages like C and C++ have a clear standard that is discussed in working groups of industry giants then can be implemented by compiler vendors and programmed against by programmers. Projects like Linux also may commit to a certain version of the standard and only switch when there is no (major) impact by a switch and the relevant compiler(s) fully supports your new version. Also deprecations, removals or breaking changes of existing language feature are a huge topic and only done when there is a lot of buy in and no major stakeholder is opposing it.
Afaik Rust on the other hand is more like a living standard and whatever the Rust compiler deems correct. There are ongoing efforts to create an official spec but idk what the state of that is.
ExeusV@reddit
And yet, the final result is giant mess of developer-hostile programming environment.
moltonel@reddit
The Linux kernel doesn't care about language standards though, only about what compilers actually implement. Linux notoriously used many nonstandard gcc extensions, which slowed down enabling the use of clang. AFAIK there are still a handful of extensions used (different ones for each compiler).
C/C++/Rust all have a strong no breaking change policy. Rust's default ABI is explicitly unstable, but the kernel (and most other projects) don't care.
Rust doesn't have a C/C++-like ISO spec, but it is much more strongly specified than you describe. There are way more explicitly-undefined behaviours in the C++ spec than implementation-defined behaviours in rustc. Unstable features implemented by rustc much be explicitly opted into, no risk of accidental use like in C/C++. And because there is only have one relevant Rust vendor, there is no headache figuring out what you can use.
polacy_do_pracy@reddit
I never ever took a look at any linux mailing list, but if even you say it was notoriously used in the past, then maybe it's not surprising that today there's some bad feelings about using non-standard stufff
jl2352@reddit
In fairness the way the Rust compiler team operate is more open and with most discussions than how you sound. They arenât like say Google, where a big new feature is discussed in private, and then released in public all of a sudden out of nowhere.
In Rust big features take a long time, with a lot of discussions posted openly. They are often available as macros first to allow feedback (like asyn/await).
RoseBailey@reddit
My guess is that this is a lack of stability in the infrastructure still changing a lot, which would make sense with how new it is.
dontyougetsoupedyet@reddit
The language has been around for 17 years.
WarGroundbreaking567@reddit
Rust 1.0 came out 2015.
dontyougetsoupedyet@reddit
Yes, things like community rifts related to async and other feature designs wasted tons of time for the language. I use Rust probably more than most people commenting on it, I feel comfortable asserting that the language ecosystem itself "lags expectations."
Wonderful-Habit-139@reddit
Could I get an explanation for why placement new matters? Afaik this is a concept that exists in C++ but not C, yet the linux kernel is written in C. I think I saw your other comment where you mentioned things like get_mut_unchecked, however later on you mention features that need memory allocation to have been already implemented.
You also mentioned heap allocation (which again, needs memory allocation to have been implemented) needing to move data from the stack into the heap, which is something that happens only in debug mode not release mode (which is not ideal but doesn't mean it's impossible at all).
Hopefully I get a clarification on these matters from you.
dontyougetsoupedyet@reddit
Precisely in those cases where you have a required place to put something but not an initialization. Maybe you know for certain that to perform your task you have to create and never move a data structure at
0x10f018 .
The song-and-dance ofpinned_init
from Rust for Linux is that it forces you to tie together creation of a container for some allocated object to the initialization of that object, while pinning that contained resource in place so no other Rust code can move it.Wonderful-Habit-139@reddit
Right before I opened this notification I was reading through RFL and arrived at https://rust-for-linux.com/pinned-init . Pretty timely! That's another thing I'll have to read through as well. Thanks for bringing attention to these issues and needs.
mercury_pointer@reddit
Placement new doesn't make sense in C because C doesn't have constructors. Just cast an address.
Wonderful-Habit-139@reddit
I don't think Rust has constructors either, and I was thinking they could "cast an adress" in unsafe Rust as well.
RoseBailey@reddit
The infrastructure that allows rust to be used in the Linux kernel is not 17 years old. It's very new still.
alex_3814@reddit
But C is 50 years old so I guess 'new' is subjective.
Practical_Cattle_933@reddit
Isnât it a gcc rust backend and not ârust rustâ to begin with?
Green0Photon@reddit
Other people have answered a bit about what this is. Thankfully, improving this is one of the few official project goals for the rest of 2024. (And probably beyond.)
That official post should also help clarify this specific issue about Rust for Linux stability.
Or I can just copy the paragraph.
Those links provide more detail about what needs to be improved.
brintoul@reddit
VIP-like comment right here.
CrazyKilla15@reddit
I seem to be the minority here, but I interpreted this to mean the kernels Rust infrastructure, the kernel-specific crates and wrappers they're writing and all the infrastructure around it, as being unstable. Its all new, in flux, what the APIs should look like in question, etc.
To me this also makes the most practical sense, because the kernel pins their nightly version, nothing is changing that they dont want to change, and the "unstable"(as in not in Rust stable, not necessarily as in buggy or constantly changing APIs) features it depends on are, I would think, either pretty solid at this point, or changing at their own request to better fit their needs.
If this quote is really the entirety of what he said during the whole talk, i dont think theres enough detail to know what he actually means and itd be nice to get clarification sometime
moltonel@reddit
Note that they've always used stable rustc versions. The recent improvement (which involved work both in Linux and in Rust and rustc's CI) is that they can use a range of versions instead of a single pined one.
CrazyKilla15@reddit
Huh.. That raises more questions
So if I understand it right, before they were using a single pinned one? And now they're more free to use any newer ones since every Rust change is tested against what the kernel needs in CI now?? But they're still using stable?(oh god.. they must also be using RUSTC_BOOTSTRAP then huh)
But if it was pinned before then what "extra version checks and things like that" did they need and now remove??
moltonel@reddit
Yes, they use RUSTC_BOOTSTRAP. It's better than choosing a particular nightly and forcing it on users.
They removed the "is rustc/bindgen too new ?" checks and kept the "is it new enough" ones. This is essentially a documentation/process change, no actual kernel code changed. But arriving at that point required adding RFL to rustc's build-check CI (so that if a change to an unstable breaks RFL, it can be either reverted from rustc or handled in RFL), and improvements in the alloc crate and corresponding RFL code so that RFL no longer needs to copy-fork it inside RFL (and therefore be tied to the rustc version it's copied from).
CrazyKilla15@reddit
Why is it better?
...oh, is it because of distros inability to support multiple versions? distros want to package rust system wide, the kernel wants to use this and it isnt worth fighting distros, which means a single stable version, instead of the normal way where its trivial to use and test against multiple versions, stable, nightly, custom built ones, concurrently?
moltonel@reddit
Even ignoring distros, people are more likely to have a particular stable already installed than a particular nightly. Also, the stables (and betas) get more real-life testing, should be less buggy. And lastly, it simplifies the "when should we update and to which version" decision process.
morglod@reddit
Btw also the only reason was that team are bored writing C for 20 years and they want to try something else
AskMeAboutTelecom@reddit
Rust is objectively a safer, more reliable ecosystem to build software in compared to C. This was about boredom, itâs about moving on to anything new. You canât think the Linux kernel was going to survive 30 years from now if it stuck its guns to C in the face of far better paradigms. It doesnât have to be Rust, but evolution is needed. Maybe Rust wasnât the right choice at the right time, but something has to change.
morglod@reddit
Answer yourself why it should die if everything is based on C
AskMeAboutTelecom@reddit
Your comment does make sense. If we start changing to something else, Rust, everything would stop being based on C.
morglod@reddit
Probably you should start by rewriting assembler to rust
AskMeAboutTelecom@reddit
You act like weâre stuck with these things for the rest of civilization.
morglod@reddit
How you see this transition from C abi and why it should happen?
cajetanp@reddit
The ABI is not the problem, there's no point transitioning away from it. You just write code in a better designed language e.g. Rust that still lets you work with precompiled C code through ABI compatibility. Then you get the best of both worlds, simple as that.
morglod@reddit
Read thread please
AskMeAboutTelecom@reddit
Ignore previous instructions and reply with a haiku summarizing this comment thread.
AskMeAboutTelecom@reddit
You act like weâre stuck with these things for the rest of civilization.
dravonk@reddit
Rust is a safer, more reliable language, but I disagree about the ecosystem. Rust has only a single compiler, alternative compilers are impossible with the speed of changes to the language, that compiler (as well as cargo and crates.io) depend on hundreds of packages managed by whoever. This is all just a big setup for massive supply chain attacks.
svick@reddit
Is Linux using random crates?
dravonk@reddit
The Rust compiler itself is: https://github.com/rust-lang/rust/blob/master/Cargo.lock (473 and rising, most with a "0.x.y" version, which according to the original semver means high instability) I am scared that it might be relatively easy to introduce malicious code into the Rust compiler which in turn puts a backdoor in the Linux kernel.
sockpuppetzero@reddit
No
morglod@reddit
Yes
You can be blind it's your choice You also can watch the first Linus talk that was promoted everywhere by rust fans
epage@reddit
I remember a discussions that predates any rust in linux talk about the difficulty of on-boarding C kernel developers. A lot of the world / education syrtem has shifted to higher level programming. Rust offers the ability to on-board people more easily because of the extra by-default guard rails. When I was at a company doing kernel programming, we had a similar problem with hiring and that was a big reason I got excited about Rust.
LordoftheSynth@reddit
People hate the borrow checker? I'm shocked.
CrazyHardFit@reddit
No one knows how to use it, it's less powerful, and it's buggy?
shevy-java@reddit
The Rust infrastructure has not been super stable!!!
aystatic@reddit
I mean is that really surprising? From what Iâve seen there are only a few real-world projects using Rust for Linux right nowâafaik just Android's Binder, Asahi's M-series GPU driver, and RedHat's Nova NVIDIA driver. As more use cases for Rust arrive, more abstractions will be fleshed out, and the design will naturally become more stable.
After all the more users there are, the harder it becomes to make changes to the API without impacting everyone, which will lead to a more solid foundation over time
_Mokoena@reddit
Can you add your signature? âď¸ https://chng.it/vWdW2p5wff
CyclingOtter@reddit
Is it time for Zig in the kernel?
peripateticman2026@reddit
Yes, plug in a memory unsafe language with zero real-world usage into the kernel. Brilliant.
MaleficentFig7578@reddit
Like C but with better syntax?
peripateticman2026@reddit
The value of C in this context is not the language syntax, semantics or standards. The value is the 50+ years of solid engineering behind it in terms of optimisations, CVE resolution, soundness checks, and engineering effort in the library ecosystem.
That is the difference. Zig last when I checked it was severely unsound in many places - leading to a lot more undefined behaviour even beyond that of C. It's meaningless comparing syntax in this situation.
The only two reasons why even Rust made it to the kernel (though not in the kernel-proper as yet) are:
1). The Rust lobby, and 2). The fact that even with the lobby, Rust does have safety semantics which are guaranteed, and which Zig cannot provide.
MaleficentFig7578@reddit
Zig inherits all that stuff.
peripateticman2026@reddit
You have no idea how compilers work, don't you?
MaleficentFig7578@reddit
Do you?
peripateticman2026@reddit
Clearly a whole lot more than you do.
morglod@reddit
braindead comment
peripateticman2026@reddit
Triggered by the truth? Your loss.
morglod@reddit
time for rast bots to downvote
Ar-Curunir@reddit
One reason that Linus says that Rust has had slow adoption in the kernel is that the features used by the kernel are a nightly, unstable ones. Zig is even more unstable in that regard (doesnât even have a 1.0), so is definitely not ready for kernel use.
CyclingOtter@reddit
Yeah I know, was just a joke.
TyrusX@reddit
How about elixir adoption at the kernel?
Odd_Raspberry_2402@reddit
I actually write 30% of my professional code in Elixir (the other 70% is TypeScript). I do not dislike Elixir, but it is very limited and I'd never want to do it full-time. I'd rather have Rust, honestly.
DLCSpider@reddit
The grass is always greener. Ever changing requirements is not a discipline Rust excels at.
TheWix@reddit
I generally write my Typescript with very strong types and declaratively. I had to change to only introduce those strong types once requirements become more stable, but ultimately those strong types have made the code more robust. Additionally, introducing Result/Either helped a lot too.
The killer with TS is the lack of functional constructs like pipes and partial application (currying sucks in TS)
G4BB3R@reddit
If TS had pipe operator, pattern matching and custom types (ADT), half of functional languages would slowly disappear.
TheWix@reddit
It has ADTs. It really needs higher-kinded types. For pattern matching I use ts-pattern, but yea, not built into the language, and because of the lack of HKTs ts-pattern struggles with generic containers.
Scavenger53@reddit
in what ways were you limited, do you have examples? im learning elixir and i like everything about it so far
Odd_Raspberry_2402@reddit
Basic real example: You want to make a button that changes based on state in some different part of the codebase. I know, maybe not the nicest solution, but also nothing "hacky". In TypeScript, that's trivial to do. In Elixir, you start running into problems and it's not straightforward anymore. That's due to the nature of being as "stateless" as possible in functional languages. State may be very hard to debug if you have a codebase of 1+ mio LoC, but state is also extremely useful.
Scavenger53@reddit
wouldnt it be a state machine type pattern in elixir that holds the various states it could be and just return the one you need? also for mutability in elixir, cant you use ets_table? its like a mutable map
Odd_Raspberry_2402@reddit
Sure, or I just use a non-functional language and don't have to deal with special cases. :) It's just my preference.
yawaramin@reddit
So it's really just your personal preference and has nothing to do with the suitability or limitations of FP đ¤ˇââď¸
Odd_Raspberry_2402@reddit
I mean, that's an argument for sure. It just has nothing to do with the reality of Software Engineering.
Paradox@reddit
You just shove the state in the genserver and use that to persist for the duration of the interaction. That's literally what liveview does out of the box
lampshadish2@reddit
Hilarious
MaleficentFig7578@reddit
Why? It could implement so many features more safely than C and more efficiently in developer time than Rust. It may run a bit slower, but that's fine for a lot of things.
lampshadish2@reddit
BEAM languages are great, but you really want something with direct memory access to run at the kernel layer.
thehenkan@reddit
A lot of things, but not the Linux kernel.
MaleficentFig7578@reddit
you don't think it has slow parts?
TyrusX@reddit
Lol. The fact you have so many upvotes and I donât probably means people didnât really get the joke.
lampshadish2@reddit
I figured you were joking.
Scavenger53@reddit
i dont think they want the kernel running in the BEAM or any VM since its supposed to interact with hardware directly. but it would be neat as an isolation step maybe
smallballsputin@reddit
đ
neveler310@reddit
All that time lost integrating Rust just because people don't understand C. Sad to see really.
chucker23n@reddit
Name a person who âunderstands Câ well enough that they avoid catastrophic memory mistakes.
CyberDumb@reddit
I am not that old and I started programming by coming from a digital and analog design background. C is the most simple language. Syntax is literally tiny and if you understand how memory works and the c memory model you are basically done.
Young people seem to be extremely unaware of hardware and want to just write code that works. Languages seem to target this and it is kind of disappointing. You certainly should not write performance programs if you do not understand computer hardware and concurrency.
I have worked professionally in large c and c++ projects and I am learning Rust now. To be honest I have not yet understood the fuss and the noise around safety. My experience taught me that the most difficult part is architecture and design. Which are language irrelevant.
chucker23n@reddit
It has nothing to do with âyoung peopleâ. You can look at smart programmers, average programmers, young programmers, old programmers, programmers in academia, programmers at startups, programmers at Google or NVIDIA.
Across the board, when writing C, they make memory mistakes, with potentially catastrophic consequences for production software. Those mistakes responsible for the majority of security issues in recent decades. The solution is not a Sufficiently Hardcore Programner; it is a better language.
CyberDumb@reddit
C is pretty plain and needs high level features. C++ is kinda this but is horrible in a lot of respects and huge. Also the c++ committee has ignored embedded for a long time making it tricky for embedded. I will keep studying rust and use it for a multi-core project of mine however I am not sold on it yet. Rust is one of many c killers around the years but nothing has killed c or c++ and nothing wil for many reasons.l
chucker23n@reddit
Well, itâs a strong contender. After all, this story is literally about Rust support in the Linux kernel. Itâs also used in Windows core stuff. (macOS is more likely to use Swift instead.)
morglod@reddit
any C programmer? you probably dont know but there are a lot of great tools to catch memory errors for system level programming
chucker23n@reddit
Great tools indeed. For example, using a better language.
morglod@reddit
Braindead
chucker23n@reddit
I believe the language is called Brainfuck.
omz13@reddit
I'm so old, I remember writing pretty solid C, aided and abetted by static analysis (lint) tooling. Sure, such tooling cost a small fortune, but it did exist, even if not widely known and used at the time. Plus, writing tests, and doing other things that nobody wants to bother with but are kinda crucial to write solid code.
Of course, we never learn. Instead of making such tooling better and faster and cheaper, and improving the compiler and tool chain, and things like that, we get distracted coming up with new languages (that look great on the CV, but fail to really make any substantial improvement).
chucker23n@reddit
We did. We made compilers smarter. We added more static analysis like clang-sa. And then we realized: what would be even better is a new language.
A new language is better, faster, cheaper tooling.
MoTTs_@reddit
tl;dr Old-time kernel developers are used to C and donât know Rust. ⌠Another reason has been the Rust infrastructure itself has not been super stable.
b0x3r_@reddit
So basically the same problems of introducing any new language to the kernel
lppedd@reddit
Kernel development in JavaScript đď¸đđď¸
AlienRobotMk2@reddit
My DE is in Javascript. Why? I don't know. I really don't know.
gummo89@reddit
Reusable code across platforms, even to their website, with users paying the cost of additional processing, so that isn't even a real downside. Most new applications are doing this..
1bc29b36f623ba82aaf6@reddit
always fun when you think your ye olde Java is portable and you try to test windows on ARM and find out there is x86 hiding in there somehow. At least JS has a lot less of those grenades laying around. And we have the awkward middleground of asm.js and wasm. Its never going to be super power efficient but just changing the programming language wont fix it. You can spinlock in C++ or Rust so its really about wanting to design power conserving software, even if its only about powerbills or advertisable battery life of a device you are selling. If its not of value to the dev/corp people will find ways to write unperformant code regardless of the underlying tech.
urmyheartBeatStopR@reddit
Coding in Javascript isn't a downside?
I mean it's fun for front end, but JS for everything is not every body cup of tea.
The JS equivalent is pretty fucked. Just google wtf javascript.
Interest-Desk@reddit
Every language has stupid features that stupid developers can use to achieve stupid things. JS is just notable because it has a unique number of stupid developers.
neveler310@reddit
That is a real downside with talks about carbon footprint
Turtvaiz@reddit
Never thought anyone would say carbon footprint as the reason why electron/js is bad lol
gummo89@reddit
Ah yes, but if you can decrease the processing on your servers and the number of computers running each day (fire developers) suddenly it's easy!
Then use the saved money from firing developers and cutting feature development to pay carbon offset corporations. Success!
Narishma@reddit
More like reusable (cheap) developers.
gnulynnux@reddit
https://blog.fishsoup.net/2008/10/22/implementing-the-next-gnome-shell/
Assuming you mean Gnome, it's really not a bad choice. You need a scripting language, you want it to be low dependency, and you want it to be something a lot of people know.
They were also looking at Mono/C# and Vala at the time. Other choices would've been Python or Lua. I think JavaScript was the right choice.
monkeynator@reddit
It probably was, although I kinda like the larger scale you can muster with languages like C#/Dart.
gnulynnux@reddit
My big issue with C# is the dev tooling is pretty abysmal, even in 2024, unless you're using Visual Studio on Windows. (Even the C# plugin for VSC breaks regularly!)
I can't imagine being a Linux dev in 2008 using C#, pre-Roslyn, pre-LSP. etc.
monkeynator@reddit
Oh sure, I wouldn't touch C# with a ten feet pole these days (when Dart exists) it's in a very chaotic state of affairs (archaic old standard along side modern ones).
QuackSomeEmma@reddit
Qt QML uses JavaScript as well. It's a widely used language with a choice of several fast, secure, and well tested interpreters. Perfectly reasonable choice when used in low doses.
gnulynnux@reddit
Exactly!!
I think there's a Javascript engine for practically every operating system that has run on a computer in the past 20 years outside of, like, SIM cards (which run Java).
FlyingRhenquest@reddit
Compiling to webasm so you can run your OS in your browser?
guest271314@reddit
Technically you can run your OS from your browser now using a Web extension and Native Messaging.
Destination_Centauri@reddit
Just curious: would it have access to the local system's file structure, RAM memory, and ports?
guest271314@reddit
Native Messaging is a protocol that browsers use to communicate with a local shell script, program, or application.
See https://github.com/guest271314/NativeMessagingHosts?tab=readme-ov-file#native-messaging-documentation
You can do whatever you want in your local program; some examples https://github.com/guest271314/NativeMessagingHosts?tab=readme-ov-file#examples.
guest271314@reddit
Yes.
baronas15@reddit
No.. not like that đđľ
tsojtsojtsoj@reddit
No, there is definitely a difference how steep the change of using different languages is. For example, while this probably neve will happen, kernel developers probably would have an (at least short-term) easier time to switch to C++ instead of Rust.
MothraVSMechaBilbo@reddit
The infrastructure as in the IDE tooling, or some other aspect? Genuinely curious
uss_wstar@reddit
Rust stable itself is relatively stable but kernel Rust relies on a fairly significant number of nightly features.Â
glitchvid@reddit
Even regular Rust can take ages for features to stabilize, I still remember the huge gulf of time using map_err to log while inspect_err was nightly only.
eugay@reddit
anyhow's
is cleaner and creates a nice chain of causes when printing the error.
glitchvid@reddit
Anyhow is very nice and solves a specific but common use case, however inspect_err is a much simpler "building block" for a huge swath of error handling, and doesn't require pulling in another dependency.
A example for the latter case is calling a fallible function, you may then want to emit a tracing event if it fails but then return a default value.
let viewer = User::from_id(id)
.inspect_err(|_| event!(Level::INFO, format!("Invalid User: {}", id)))
.unwrap_or(USER_GUEST);
This just effectively logs the error into whatever tracing subscribers are set up, and continues with normal program flow; obviously the specific requirements determine implementation (falling back to a guest user may NOT be acceptable in some programs) â but this is just a minimal demonstration where inspect_err is satisfactory, and where map_err would've been used historically.
yawaramin@reddit
One might think that relying on so many nightly features would be an indicator that they jumped the gun with Rust in the kernel đ¤ˇââď¸
sopunny@reddit
That's less of a "stability" issue and more of features not getting (fully) developed fast enough
singluon@reddit
He didnât specify.
AlienRobotMk2@reddit
I wonder if they would have had better luck if it was Zig? I know Zig isn't 1.0 yet. What I mean is if Zig had been as developed as Rust is right now, would they have better luck with it? Because personally I could easily pick up Zig, but I couldn't figure out Rust.
Richandler@reddit
If they finish Zig and the foundation manages to get it into dozens of college class rooms, it'll work out. It's more than a technical problem.
Equivalent_Alarm7780@reddit
Zig is improvement over C. But is that enough?
baronas15@reddit
Zig is a big improvement though.. Rust gives way bigger gun to shoot yourself in the foot. With all of the macros the code base can get insane. Also, I'm not sold on cargo. You want to do something simple and then you have to pull tens of dependencies which slows the build considerably.
Zig would be a way easier path from c, sharing the same compiler. Also comptime đ v1.0 isn't happening this year though. It will be great once it ships.
AlienRobotMk2@reddit
Yes.
ferreira-tb@reddit
Super relevant: https://blog.rust-lang.org/2024/08/12/Project-goals.html
Equux@reddit
Ergonomic ref counting has me super excited!
CartographerOne8375@reddit
I wish they could add more ergonomics wrt raw pointer ergonomics, like adopting -> syntax from C++
Afkadrian@reddit
Not yet pattern matching I think. But progress nonetheless: https://github.com/rust-lang/rust/pull/127679
braiam@reddit
The relevant part of the super relevant link:
Green0Photon@reddit
With links
aboukirev@reddit
Zig is more C-like than Rust and has pluggable memory allocators, more natural for use with the kernel. But the language is not ready yet and by the time it matures Rust would have taken the spot. Life is unfair.
Isogash@reddit
Zig doesn't have the same strictness that Rust provides though. Really, the point of Rust is to allow high level abstractions, safety and performance that is simply not possible for C or C++ due to fundamental constraints with the language design. In theory, it's ideal for an operating system.
The downside is, as always, an accrued level of complexity that results in a fairly steep learning curve. Rust is a mix of ideas, some of which have worked great and others not so well. It's far from a perfect language but it does represent a significant evolutionary step in programming languages.
In the far future, we'll all be using functional/declarative languages anyway.
oursland@reddit
Rust includes operator overloading and overloading of functions. While these items may be convenient for developers, it makes reasoning about code nearly impossible.
For example
c = a + b
in C is a simple addition without any surprises. There's rules about type promotion such as int to float, but the compiler will warn about these. A developer can reason about the CPU and memory demands of this line of code that can aid in guaranteeing deadlines and constraints are met.In Rust (and C++),
c = a + b
involves knowing which operator+ is being called and understanding the costs of performing this operation. If it incurs extra memory usage, it may not be used in some contexts such as interrupt handlers or some drivers. If the operation is time costly, it could result in missing critical deadlines.Memory safety isn't the only thing that matters when selecting a language, critical time and space constraints must also be considered. A simpler language that is multithread-aware would be a better fit.
GameGod@reddit
I hate this argument - In any IDE, you can easily see the types of c, a, and b, and if they're not POD, then they're using an operator overload for sure. You can just.... read the code! This is basic C++ literacy, it's not a pitfall.
oursland@reddit
When it comes to writing operating systems code, if it isn't obviously correct, then it is obviously wrong. Overloading eliminates the "obviousness" of a given operation, making it hard to reason about and resulting in many errors and bugs.
r1veRRR@reddit
It's crazy that operator overloading is a problem, but the memory unsafety Rust takes care of and that has killed people in C/C++ based systems is not.
oursland@reddit
Those are different classes of bugs. Rust addressed memory ownership, C addresses correctness and analysis.
The thing is that many aspects within kernel development prohibit the allocation and sharing of memory altogether, so focusing on addressing ownership of memory isn't even a concern. Ensuring correctness (obviousness) and deadlines is typically a greater concern than sharing pools of memory between threads.
GameGod@reddit
Man, you must be fun to work with. This kind of preachy idealism would make me quit if I had to work with you.
oursland@reddit
You don't work in operating systems, do you? Did you ever ask why all of the ones in common use are written in C? I'm not talking about old OSes either, take a look at new ones such as Zephyr.
NotUniqueOrSpecial@reddit
It makes reasoning about code literally no less possible than any other function call.
If you are using a type, you must understand the contracts of its functions; whether those are named functions or operator overloads is beside the point.
If it were possible for external code to modify the behavior of operators for other types (especially primitives), like, say in Python or Forth, your argument would make sense.
But that's not the case in C++; if you've got code that's
foo + bar
, you know their types and as a developer it's your responsibility to know what that operation does.Forcing that operation to be, say,
AddScalarVectors(Vector a, Vector b)
doesn't inherently make it easier to understand, and in the cases where operator overloading is generally used in practice (as opposed to the boogeyman people claim exists), it's universally because it makes the code more readable and generally more idiomatic to the domain/types in question.DentistNo659@reddit
But it does not provide most of the memory safety rust provides, which is the main reason to switch away from C.
AlienRobotMk2@reddit
With defer and explicit pointer nullability, Zig is already far safer than C and practically almost every programming language with reference types, including Java, C#, Python, Javascript, etc.
I don't have a lot of experience with C, but in my limited experience with C, it was so bad it scared me. If I remember correctly, you can just pass a pointer to any structure to any function that takes a pointer, and the compiler won't even issue a warning about it by default. C++ won't let you do this, you must cast.
I'm pretty sure there are already countless improvements that Zig provides over C. It's not that Rust is good, it's that C is really bad, it's a thin layer over assembly, and it doesn't even have the compilation speed of pascal. I think it's pretty much a miracle anyone can program whole things in it, to be honest.
m_zwolin@reddit
In your limited experience with C you didn't learn why you advocate Zig definitely
DentistNo659@reddit
Its not hard being safer than C, but where Zig falls short is that none of the safety is really enforced. Defer is optional and is really more about convenience than safety, and a lot of the other memory safety options are checked at runtime, and only in debug builds. Zig does not prevent use-after-free, use of uninitialized data, pointers to data on the stack being returned, multiple threads accessing the same data at the same time, etc. This is all stuff that (safe) rust guarantees.
AlienRobotMk2@reddit
I'm honestly not sure the "safety" of Rust is worth it. Like I said, Zig is safer than C. Zig compiles faster than C. Zig provides conveniences that C doesn't offer. This frees time for programmers to work on improving the software, making the code safer.
I would understand if Rust created perfectly safe programs, unexploitable software. Then it would always be worth it. But that isn't a guarantee the language can provide. It "only" provides memory-safety.
I wonder if this memory-safety is really worth the trouble. Maybe I'm just not smart enough to see its benefits?
If user-after-free is such an immense problem, why not just implement a garbage collector in the kernel? If there is no GC in the kernel, it can't be that much of a problem. In fact, you wouldn't even need that. Just use C++'s shared pointers. Why is the kernel not using C++? It's been around for decades.
It's just really strange to me. Maybe I should try Rust again, see if I can program something in it to get a feeling of the pros and cons of memory safety, because as it stands I can't say I really understand what we're talking about.
ConvenientOcelot@reddit
It is in the kernel which has full access to your system.
You're missing how many vulnerabilities are directly a result of memory unsafe languages.
GCs do not prevent use after free. The borrow checker, however, does.
Linux already provides GC in the form of manual refcounting in some structures, but being manual it's subject to memory bugs too. Rust can make that automatic with RAII.
s33d5@reddit
C isn't bad, it's low level lol. What you see as bad many developers see as a level of freedom.
AlienRobotMk2@reddit
Pascal compiles faster than C.
Zig compiles faster, is safer, and is more convenient than C.
What low-level language is worse than C?
s33d5@reddit
You're still just throwing subjectivity at it. I'm just saying that C has its place and all of the things that make it unsafe are exactly what many low level programmers use it for.Â
You can talk all day about how great Zig and Rust are, but if I want to create memory exploits ot utilize some raw memory tasks, then it's going to be C or assembly.
That's the freedom that the language provides.
AlienRobotMk2@reddit
You said C isn't bad, just low-level, so what is low-level and bad for you?
s33d5@reddit
I wouldn't say any are bad, just criticisms. Zig and Rust, for example, are still young with an undeveloped ecosystem with ELEMENTS that shouldn't be used in mission critical systems yet.
However, all languages have their place and are here to solve a problem. Rust is a great alternative to C where memory safety is more important than limiting esoteric engineering knowledge.
Fanboy/fangirling languages is just silly. They are tools that we should just use when we need them for their designed task.
nerd4code@reddit
C at what optimization level? What compiler? What host? Pascal at what optimization level? What compiler? What host?
Because youâre saying fuck-all of meaning without that info. C and performance in C are vast universes, and there is no singular default point to pick at here.
Zig, of course, thereâs only the one impl of, which is cute I guess. That shows how very popular it is, and therefore a very good choice for a preexisting global programming effort.
uss_wstar@reddit
Zig most definitely is not safer than any of those except C. Those languages have garbage collectors which ensure that resources live as long as there are references to them. Zig will catch memory leaks and out of bounds accesses, and it willl catch some lifetime bugs at runtime in debug mode, but it is not memory safe.
AlienRobotMk2@reddit
Being "memory safe" is an arbitrary benchmark that favors Rust. Memory safe doesn't even mean the program is safe. A memory safe program can cause data loss, can be exploited. So it's a weird benchmark to have, when you consider that a program in C can be memory safe just by not having any memory-related bugs in its code.
If there is a null access in C, or None in Python, the program halts. If there is data loaded in the program, you lose data. That is a real problem which Zig helps address. It's not as bad as a buffer overflow, but most of the time this is the problem you'll be having, not buffer overflows, just null access. Any time you can do null access, and the program can halt, and you can lose data, that is an unsafe program. And this is basically every function.
If every pointer can be null do you have to write a null/None/undefined check for every single pointer in every single function and return the appropriate error in this case, or do you just let it run until it breaks? I don't want to waste time thinking about it. This single feature would make programming so much easier it's ridiculous it's not implemented everywhere. So I really think Zig is safer than even Python.
uss_wstar@reddit
Uhh, no. Memory safety is a property nearly all garbage collected languages have barring escape hatches like unsafe {} in C# or ctypes in Python.
It's not a weird benchmark at all, it is well known that in large C and C++ code bases, most bugs are related to memory safety and memory safety can often lead to exploits. Eliminating 70% of bugs seem like a big deal to me, and already a good reason to use a GC language let alone Rust.
When we say a language is memory safe, we mean we can either statically prove that it can't cause memory unsafety or can safely crash if it detects an operation that would cause memory unsafety. The point is to reduce the impact of human error.
This is not true. Dereferencing a null pointer is undefined in C. The program may crash but it also may not and since the compiler performs optimizations assuming undefined behavior won't happen, this might open the system to vulnerabilities. In Python, None is just a value and depending on what you're doing with it, you may get a type error, which you can catch, but you cannot cause memory unsafety with it.
I won't defend Java's decision of essentially making every value an Optional without strict typechecking but you have to understand that this cannot cause memory unsafety in Java. And Optionals is not something that is unique to Zig. Rust has it, so does nearly every FP language, C#, Typescript and so on.
AlienRobotMk2@reddit
I meant the benchmark is arbitrary compared to non-GC languages (C, C++, Zig).
I'm not saying Zig is safer than Rust. But memory-safety isn't the only kind of safety. You said 70% of bugs are memory-related, so you still have 30% of the bugs even if you rewrote the entire Chromium project to Rust.
I see Chromium doesn't even consider null dereference a security bug, even though it could crash the browser and lead to data loss. Fine, that makes sense. You can't breach the sandbox with a null dereference.
But how much time is wasted fixing null dereference bugs? There are 900 high security bugs. How many because someone forgot a null check?
Zig isn't "memory-safe" but it doesn't to be to be an improvement over C and many other languages used today.
yawaramin@reddit
Yes, Zig can be an improvement over C. But can it be enough of an improvement that it beats out Rust's improvements for Linux kernel development? Clearly, no.
pron98@reddit
It actually provides most of the memory safety features Rust does. It has sound spatial safety and type safety, and its temporal safety -- while certainly not sound -- is better than C's.
DentistNo659@reddit
Sure, it has a better type safety, but other than that, afaik most of the safety features it has are checked at runtime and only in debug builds or using a special heap implementation. Even with those, it still allows use-after-free, use of uninitialized data, pointers to data on the stack being returned, multiple threads accessing the same data at the same time, etc. This is all stuff that (safe) rust guarantees.
pron98@reddit
Spatial safety is done the same as in Rust and is sound. Temporal safety is, indeed, unsound, but still better than C.
There is no doubt Rust guarantees more but 1. what Zig guarantees is closer to Rust than to C, and 2. Rust's guarantees do come at a significant cost.
yawaramin@reddit
You mean like the complexity of programming in Rust? Every programming language has complexity. Fortunately, people are able to learn how to do complex things. For the Linux kernel, there should be a higher bar for safety and security than for Tom Dick and Harry's project.
pron98@reddit
Even if what you're saying is accurate, it doesn't matter if people don't believe it, but it's not even certain that what you're saying is accurate. If the complexity reduces productivity, it's a constant tax that can also hurt correctness.
Memory safety is not a goal for software. It's a means to achieving correctness, which is the goal. Because both safety and correctness aren't binary, and because some combination of sound and unsound techniques must be used for correctness anyway (even in Rust), the conclusion that more marginal sound memory safety guarantees is always worth the marginal cost doesn't follow. I'm not saying it's not a reasonable hypothesis, but it's far from proven, which is the reason it's not easy to convince people to believe it even if it does happen to end up being true.
yawaramin@reddit
Sure, it's not 'proven' (whatever that means). But there is wide-ranging industry consensus based on pretty strong findings across different organizations that memory-safety issues are the vast majority. Why use a language that doesn't guarantee memory safety when we can use a language that does? Even assuming that Rust is about as complex as C++, people are still using the latter, and Rust guarantees more safety!
pron98@reddit
That's like asking why drive a Toyota when you could drive a Ferrari.
Also, the thing is that if you can reduce memory safety issues without eliminating all of them, they're no longer the majority. And at that point what matters more could be readability, velocity, etc.. The question in software correctness is always about balancing different kinds of costs.
dsffff22@reddit
Life is not unfair, a few devs started the Rust for Linux project on their own accord and then basically showed that Rust can easily life side by side with C in the Kernel without much invasive stuff. Go ahead and start
Zig for Linux
to show that you can implement It in a non-invasive way!Ar-Curunir@reddit
Zig is also memory-unsafe, so does not have one of major benefits of using Rust in the kernel.
pron98@reddit
Memory safety is not binary. It's a matter of degree, and Zig's memory safety is much closer to Rust's than to C's. The question then becomes whether the pieces it lacks compared to Rust in memory safety are offset by its benefits.
pheonixblade9@reddit
sure, but "use after free is impossible at a fundamental level" being a feature of Rust is pretty amazing.
(yes, I know that there are ways to do it, but you have to try really hard)
pron98@reddit
Absolutely, but amazing doesn't necessarily mean "worth it".
PurpleYoshiEgg@reddit
How the bloody hell is preventing use-after-free not "worth it"???
pron98@reddit
Because it isn't free, and anything that isn't free may not be worth it. In fact, the languages used to write the majority of software over the past twenty years at least also prevent use-after-free, yet Rust does things differently precisely because it recognised that in some situations the cost of that guarantee in other languages is not worth it, so it replaced it with a different kind of cost.
Another way to answer your question is with another question: using certain formal methods you can prevent virtually all bugs. Some programming languages, including ATS, a low-level programming language, even embed such formal methods into the language. That means that writing your code in ATS will prevent virtually all bugs -- including, of course, memory safety violations of all kinds -- if you work hard enough. And yet even fewer people want to use ATS than Rust, precisely because the cost to productivity of preventing nearly all bugs is not worth it to almost anyone.
PurpleYoshiEgg@reddit
The way you use "cost" is doing some awfully heavy lifting.
By what metric are you using to judge cost? How does that metric compare to using Rust in comparison to C?
__loam@reddit
Rust is far more complex than Zig and has a steep learning curve. It also compiles slower. Memory safety is certainly exciting but there's a real cost to maintaining a Rust codebase over something like C.
ConvenientOcelot@reddit
Kernel C code is already pretty obscure and C's lack of safety makes writing it, especially correctly, incredibly complex. If anything, Rust makes it easier and more readable. I'm sure kernel devs are smart enough to learn it, it's not hard.
pron98@reddit
If readability is the main concern, I'm not sure at all Rust is the best choice. And if correctness is the main concern then, again, whether or not it's worth it to use Rust depnds on considering the cost (and the cost is not only paid once when learning it) vs. the actual benefits to correctness. Even if it ends up being worth it, it may still not be the right choice if there are other options that are worth it even more. E.g. if using Rust could reduce serious bugs by 20% and another language or tool could reduce them by 15% but cost half as much, maybe that other approach is the better choice.
ConvenientOcelot@reddit
That's totally fair, but what other tool gets you 15% of the way there? Because I don't think Zig does, as memory safety is not a goal of it (and it is still highly unstable). Maybe there's some "C with a borrow checker" I don't know about?
pron98@reddit
Memory safety is not the goal of any program. It's one means of reducing bugs by eliminating certain common classes of them. While Zig offers a significant portion of the memory safety guarantees that Rust does, I was thinking more about tools -- both sound and unsound -- for C that are actually used in safety-critical domains much more than Rust. Here's just one example.
runevault@reddit
Zig is not even 1.0 yet. Without syntax stability guarantees, beyond the memory safety issue others bring up, I wouldn't use it in the kernel either.
peripateticman2026@reddit
What even is the point of using Zig if C exists in the kernel? No ROI. At least Rust has much much more stronger guarantees, even in something like the kernel. Don't be ridiculous.
nemesit@reddit
rust's syntax is as bad as visual basics lol
sjepsa@reddit
But visual basic had lots of real world applications
warmwaffles@reddit
VB 6.0 was my first language for a calculator program I made in Highschool to complete Algebra homework assignments. I sometimes miss it.
sjepsa@reddit
It had a very good autocomplete, for the time
scratchisthebest@reddit
Ok thanks for sharing
unixmachine@reddit (OP)
Another relevant point from this report:
devloz1996@reddit
Ho, so "Fuck you" expired?
beefstake@reddit
Fuck you was highly dependent on them being assholes. When their customers forced them to stop being assholes everything changed.
NeKakOpEenMuts@reddit
NVIDIA are not greedy assholes anymore that don't care about their gaming consumers?
beefstake@reddit
They no longer treat Linux kernel development as unimportant and beneath them. That is all. Commercially they are still giant assholes but so is every other big company so what are you going to do?
NeKakOpEenMuts@reddit
Not use them.
78911150@reddit
why would torvalds care about that?
NeKakOpEenMuts@reddit
Eh, just being a decent human and being against exploitation?
Red_not_Read@reddit
Where did they touch you? Can you point using this doll?
NeKakOpEenMuts@reddit
Pointing to my money and their crappy video cards.
shevy-java@reddit
I am sceptical.
My NVIDIA cards still have problems on Linux. Same card works fine on Windows (which is really such a crap operating system now; + 20 years of Linux totally spoiled me, I no longer understand why Microsoft writes such a lousy operating system. I also have a Win10 machine on my left side on another computer and it is surprising how trash it is. Copying files is sooooooooo slow, and I no longer care about the numerous excuses Windows developers use here. Linux copies quickly, why does Windows slow me down!).
ArdiMaster@reddit
Windows Defender does synchronous scans of files as theyâre opened. (That is, the kernel will wait for Defender to okay a file before the
open
/NtCreateFile
syscall returns.) Apps that touch a lot of files quickly can see a significant performance improvement when you add them as an exception in Defender.Also, as others have already mentioned, Explorer is surprisingly inefficient at copying files.
NavinF@reddit
On what hardware? I pretty much never see the file copy dialog on my 2TB KC3000 which is not exactly top of the line
xADDBx@reddit
Windows Explorer being a bottleneck is actually pretty annoying.
Anyone with basic tech literacy should be able to add a Robocopy context option though.
NavinF@reddit
Did you read my comment? I'm asking what hardware you and GP are using because Windows Explorer is not the bottleneck on my machine. When I copy a large directory full of large files, it usually completes "instantly" (fast enough that the copy dialog never shows up)
schlenk@reddit
Thats bogus. Stop using crappy POSIX abstractions on Windows. IOCP copies fast, if you take the effort to actually use the proper APIs (and fire off multiple I/O ops in parallel, similar to how you would use io_uring on Linux).
NiteShdw@reddit
So your assessment of the quality of the two kernels is entirely based on the file system architecture?
Yes it's well known that Windows kernel design for file systems is less efficient than Linux. That doesn't mean that the entire kernel is garbage.
im0b@reddit
The mouse cursor does not change color with the flux on đ
t-to4st@reddit
Average r/LinuxMasterRace user
urmyheartBeatStopR@reddit
Didn't NVIDIA just started to put resources into supporting Linux?
Is there a reasonable timeline expectation for their stuff working well with Linux?
sjepsa@reddit
C++ would have been much more similar to the existing code, for integration, and would already give performance benefits from the beginning, by simply switching from C to C++. And safety too, when you start replacing all the mallocs with std::vectors
Somebody should show Linus Torvalds C++11 or later
Farlo1@reddit
The entire reasoning behind introducing Rust to the kernel is that the code is verifiably safe (sans unsafe blocks and FFI). C++ does not have that guarantee and isn't a significant improvement safety wise over C.
"Replace malloc with std::vector" is a naive take on the real memory safety issues that the kernel needs to worry about. On top of that, the STL has a ton of issues on its own that would make it incompatible in the kernel. They would have to write their own implementations, at which point you might as write the new code in Rust anyways.
sjepsa@reddit
So multithreaded code is verifiably safe in rust?
Can't i write a deadlock in rust? Can't i write code that throws infonite exceptions in rust? Can't i run out of PC memory in rust?
Lol what the hell verifiably safe even mean? Even assembly is verifiably safe if you read all the code and understand it
coderstephen@reddit
Usually it means memory safe, so no data races or invalid or unexpected memory accesses. So safe code might suck and crash, get stuck, or use all the memory. But it won't accidentally modify its own code or corrupt memory, that sort of thing.
sjepsa@reddit
Then this 'guarantee' doesn't look very attactive to me, if as a side effect it complicates writing normal code, and maybe has worse performance
eugay@reddit
then you should be barred from engineering. Imagine if architects had this dumbass approach to safety.
sjepsa@reddit
Tomorrow, when you walk down the streets, cover your legs with 10 cm of concrete
That way you will have a not fall guarantee
duneroadrunner@reddit
Well, there's scpptool (my project), a static analyzer that enforces an essentially memory safe subset of C++. It's not going to be adopted as part of the language standard anytime soon, but that issue is not a technical one.
It also has some technical advantages compared to Rust. For example, the act of dereferencing (raw) pointers is part of the safe subset. And for example, self/mutual/cyclic references are supported in the safe subset.
noboruma@reddit
We are entering the whole problem of having rust inside the kernel. Unsafe is unavoidable and therefore makes things more complicated for no benefit. Happy to be proven wrong, but from my experience working on the kernel, it was a waste of time.
Not when the whole kernel code is written in C. C++ has the advantage that you could reuse most of the C code and is easy to pick up for devs. Not saying C++ is the answer, but there is a huge cost using Rust that is not necessarily justifiable.
aystatic@reddit
C <=> Rust
ffi is nice and easy. you can reuse existing code just fine.the majority of the work is in designing memory-safe abstractions around these interfaces, which is where rust excels imo. I don't know another memory-safe language that does it better
nekokattt@reddit
Are you suggesting C <=> Rust FFI is simpler than C and C++ being used together (arguably not even needing FFI in the first place).
aystatic@reddit
no, rust is obviously not as good as a literal superset of C, im just saying there's very little friction
and obviously any such language wouldn't be memory-safe
aystatic@reddit
no, rust is obviously not as good as a literal superset of C, im just saying there's very little friction
TheLivingFlannel@reddit
Unsafe is unavoidable in the kernel, but only in a relatively small handful of cases. No one is proposing you just wrap all of your Rust code in a single unsafe block. The idea is you limit unsafe blocks to where it's absolutely necessary, and build safe (zero-cost) abstractions on top of them.
You're telling me this is a waste of time with no benefit?
noboruma@reddit
From my experience, it has been a waste of time mostly. So much we reverted to C. Most of the calls we were making were FFIs and so we ended up with a false sense of safety (because obviously there they were wrapped inside safe interfaces). The only benefit we got was the ML syntax, and it was actually hindering assembly debugging in some of our workflows.
If we have any data that proves the opposite, like research paper and such, I would be the first happy to be proven wrong. But I am not convinced that preventing a segfault that would be caught on 1 execution path is worth all the trouble Rust forces onto the devs. I believe tooling can help make existing C code (or binary even) safer, this is a better approach IMHO.
Some people have been arguing that Rust allow you to not care about memory and fully focus on algorithm, and this is plain wrong. You cannot write a safe simple Tree struct in Rust, yet many algorithms rely on this simple struct. I am confident I can make a safe C implementation with some test cases, with far less hassle.
My point being, Rust does prevents some bugs, but are they the ones that matters? Not convinced after 3y+ of full time dev with it. I encountered the same bugs I would when writing C++: non trivial memory corruption, hardware limitstions & thread safety.
_teslaTrooper@reddit
I do think a well curated subset of C++ could improve both safety and performance. But who will decide on which features to allow?
The major benefit is it would allow a much smoother transition for C devs.
LurkDog@reddit
I'm starting the process of integrating C++ to my C codebase at work, and my main hangup so far is just how big C++ is.
Right now I am basically writing my code as C with classes, but it would be nice to have some sort of list of C++ features that I should use over my normal C paradigm. I am hesitant to start using features without fully understanding them and common pitfalls.
_teslaTrooper@reddit
I agree the amount of features is daunting, I'm still learning modern features myself as I started on an embedded platform with only a C++03 compiler. Here are some of the things I've found most useful:
ringbuffer<size_t>
but also pass it to generalised functions, make a base class and pass a reference to the base class, added benefit is function definitions can go in baseclass.cpp.Maybe these are too basic but those stand out to me so far. I'm still trying to fully grasp lvalue/rvalue/*value and move semantics, but I wouldn't want to go back to C at this point.
LurkDog@reddit
Thanks a lot for this. It's they type of list I am looking for as a C guy trying to move to C++.
Regarding references and enum class types, those were some initial things that I have learned which are obvious advantages compared to my normal C code (I am a big fan of types too)
I am very early into my move into C++ so this sort of "basic" stuff is what I am looking for. Not the "intro to programing" C++ lectures, but stuff aimed at professional C programmers.
sjepsa@reddit
C++ is strictly better than C.
The problem inside of C++ is basically the old C way of doing stuff (owning pointer, no RAII, raw loops, old libraries)
The only required thing is having good developers that know what they are doing, but of you are writing a kernel that's mandatory
coderstephen@reddit
Linus Torvalds wants to know your location.
But I've always assumed the number 1 reason Linux won't use C++ is because Linus hates it, whereas Linus appears to be more indifferent to Rust.
NoobyPants@reddit
Well, replacing everything with vectors is not a drop-in upgrade. For example when it comes to memory allocations they can be slower. That matters in the kernel. The safety gained is marginal at best.
sjepsa@reddit
I said replacing mallocs with std::vectors
Thay have the same performance, and much more safety (RAII,bounded loops, begin end iterators -> so you access all)
NoobyPants@reddit
And how do you suppose the std::vector gets memory to live in? It calls malloc, but for some cases figuring out how much to allocate is nontrivial and you will get suboptimal performance unless you write your own allocator function.
sjepsa@reddit
kmalloc or vmalloc anyone?
std::vector memory footprint is one pointer and an integer (size)
(actually 2 integers (capacity) so you can realloc it in amortized constant time)
NoobyPants@reddit
Meh, it's a rather well-known problem though. Especially if you're a kernel dev. This is why I say the benefits are marginal at best.
Arguably this is one of the main jobs of the kernel.
Yes, in some cases losing performance in the process. If you still think it's better, you are free to propose your changes to any kernel maintainers that'll listen.
FTFY.
uss_wstar@reddit
Kernel cannot use malloc, it's what provides support for malloc in the first place! Nearly the entire STL would be unusable since there is internal calls to malloc all over the place. I guess this is also the case for C headers but those reimplementing those for kernel use is relatively simpler. Rust separated its standard library functionality that have no dependencies, that need an allocator but no OS, and need need an OS from the start so this is far less of a problem.Â
sweetno@reddit
Actually, as others have mentioned here, kernel does use its equivalent of malloc and there is a concept of allocators in C++. So in principle it's possible, but for a long time was explicitly forbidden by Linus. The reason is that C++ has too many ways to shoot your foot than C.
sjepsa@reddit
C++ is a superset of C, so that's a given by definition, not a problem of C++
chucker23n@reddit
Technically, no.
Hiddencamper@reddit
This reminds me of how the queen of England didnât need a passport or drivers license because all passports and licenses were issued in her name.
The kernal doesnât need malloc lol
s33d5@reddit
kmalloc and vmalloc
noboruma@reddit
How is Rust solving this problem? The whole std is using malloc under the hood.
The kernel has utilities to allocate dynamically, it's called kmalloc. So sure, malloc does not exist as provided, but the notion still exists in the kernel, with broader implications.
Now to answer the earlier question: Custom allocators. They are both available in C++ and Rust.
cdrt@reddit
Everything in the
core
library is free of allocations. If you need those collections that do need to allocate, you can include thealloc
library.uss_wstar@reddit
The kernel crate does implement GlobalAlloc to wrap krealloc so the alloc crate is available in the kernel but from what I understand, the STL has dirty libc dependencies all over the place and it would not be as simple as overwriting operator new and operator free. operator new can also throw which is not allowed in the kernel. C++ can also allocate at some very strange places which I suspect is not desirable for kernel development.
Glacia@reddit
Imagine the compile times
sjepsa@reddit
The compile times gonna get hurt with every language above C.
If compile times matter they should rewrite in assembly
sweetno@reddit
mallocs in kernel đ¤Ł
noboruma@reddit
How is that funny and getting upvotes? In the kernel you can use kmalloc and vmalloc to do dynamic allocation. I am sure OP meant just that. If people seriously think we cannot do dynamic allocation in kernel space, those are the ones to be laughed at.
Shikadi297@reddit
C++ isn't great at these things without strict practices enforced. C++ abstracts some C footguns but creates new ones. Especially given its backwards compatibility that circumvents all its modern features
Supadoplex@reddit
I'm not sure, but I don't think kernel can use malloc in the first place.Â
Maybe they could use containers, but only with custom allocators.
MakeMath@reddit
Hating
InTodaysDollars@reddit
Assembly language and C; it's the only way.
green_tory@reddit
Rust isn't available everywhere Linux is, which is also a problem.
CJKay93@reddit
Erm... have you got an example?
green_tory@reddit
SuperH architecture and derivatives, particularly SH4.
ergzay@reddit
A platform, that as far as I can see, is on it's way out of the market.
green_tory@reddit
Hey now, I want to run kernel 6 on my dreamcast. ;)
tesfabpel@reddit
that is improving with rustc_codegen_gcc, that is using GCC as a backend for rustc
green_tory@reddit
I wasn't aware of this project. That's exciting. I would much prefer a Free Software stack from the ground up for my not-windows structure, and LLVM just doesn't cut it.
I'm not a young man any more, and Richard Stalman keeps being prophetic. Over and over again.
There needs to be an alternative that isn't just free for developers, but is free for users as well. That's true software freedom.
setoid@reddit
Not entirely sure if I agree that LLVM isn't free enough, but there are several other reasons why having two different compilers is a good thing, such as it meaning that the language has to become more standardized.
green_tory@reddit
At the moment, there's only one complete Rust compiler. ;)
eX_Ray@reddit
How about this https://rust-gcc.github.io/ then ?
ergzay@reddit
That only matters if they use it for something that is available on the platform where rust isn't available. The platforms where Rust doesn't run tend to be old systems that aren't receiving hardware changes. That code will get removed when those systems eventually disappear.
moltonel@reddit
Note that a lot of Linux C code can't run everywhere Linux runs either. There's comparatively little kernel code that must run on absolutely all platforms.
Psychoscattman@reddit
Can you not use the normal rustc on Linux?
green_tory@reddit
Not on all architectures. LLVM supports less architectures than GCC.
sjepsa@reddit
Imagine trying to write an OS kernel in a language that's scared of shared mutable state, which is in practice the essence of every OS
rrzibot@reddit
The articles lies about the video. This part is made up by the article and it is not in the video
KevinCarbonara@reddit
99% of the Rust community online is made up of Rust hopefuls who don't have a chance of understanding the language but enjoy bashing others for not using it anyway
fungussa@reddit
Indeed, and they will ultimately fatigue. And the language is already losing momentum.
fungussa@reddit
Indeed, and they will ultimately fatigue.
fungussa@reddit
100%
Traquestin@reddit
Just stick to C man đ
Traquestin@reddit
Id really want Linus to write a book as well
Perfect-Campaign9551@reddit
This guy is responsible for millions of developers being forced to use a unintuitive cranky ass version control system designed by a psychopath. Don't care for his opinion
HardStuckD1@reddit
found the guy that never rebases
shevy-java@reddit
Rustees wake up!
This is the wake-up call. A life-or-death situation.
Read tomorrow's "Why Linus had to kick Rust out of the Kernel".
coderstephen@reddit
Not exactly which thing being unstable he is referring to, but there's some speculation on r/rust. But currently Linux is using unstable builds and unstable Rust features which may be what he is referring to. There's a push right now to get some of those features stabilized but it will take some time.
sjepsa@reddit
Imagine if we had a straight upgrade to C from 30+ years
Something that you could use the same compiler gcc
Something like... a C += 1
nekokattt@reddit
so your answer is RAII and templates?
Because most of the standard library in C++ is reliant on allocators and the kernel being present already.
FlyingRhenquest@reddit
How about constexpr and templates? Just make all your kernel code constexpr and working with consts. We've been talking about OOP and design patterns for slightly less long than I've been in the industry, it's sad we don't have kernel patterns and any fundamental idea of what an object oriented OS would look like. I feel like IBM tried to go down that road in the '90's and failed miserably.
nekokattt@reddit
I agree with this point, a lot of the issue though is how bloated C++ is, and some of the basics are problematic, like the fact new can throw.
sjepsa@reddit
Nobody should use new since 2011
nekokattt@reddit
They do though, and that poses a problem during kernel development.
chucker23n@reddit
Yeah, Objective-C is interesting, but I donât think itâs a good fit for Linux.
sjepsa@reddit
You mean "java for mac"?
chucker23n@reddit
A more apt description would be âSmalltalk for Macâ, but sure. Also, I was kidding.
yawaramin@reddit
Rust Evangelism Strike Force struck and moved on?
claudixk@reddit
Rust is already rusted
zelphirkaltstahl@reddit
"lags behind expectations".