5 ms·
I'm surprised Torvalds is so sanguine about Rust. Maybe it's age but I remember his epic gamer rant about how he would never allow C++ in the kernel. Either Rus
by Longlius 4y ago
I'm surprised Torvalds is so sanguine about Rust. Maybe it's age but I remember his epic gamer rant about how he would never allow C++ in the kernel. Either Rust is significantly better than C++ in his view, or he's accepted that C is likely not going to be the dominant systems programming language forever and opted for the least dangerous alternative.
Guess I should start my 5th attempt at finally getting good at Rust.
- bestouff 4y agoGet good at Rust, the answer will come.
- vbtemp 4y agoTo the OP: This is the correct answer.
- pjkundert 4y agoI’m a C++ guy from back in the 90’s CFront days. I love Rust; I’d do any new project in Rust instead of C++. It’s worth the effort to learn.
- agumonkey 4y agoHow did it affect your coding ? do you use different patterns / idioms ? are you more ambitious due to less bugs ? do you design / prototype differently ?
- ardel95 4y agoRust is significantly better than C++. And I say that as somebody who has done many years of C++ development.
- lijogdfljk 4y agoI love that it draws so many different types. I'm a Python/JS/Go programmer historically. Rust is closer to Go to me. Of course it's not Go, but i'm far from a migrating C/C++ dev. Hell i only know a pinch of C++ from when i was first learning the trade.
- runevault 4y agoI always had the impression Linus saw C++ as C but more complicated/worse. Rust is DIFFERENT by creating guarantees that are harder to get around and if you do try by using the functionality available in unsafe blocks it is clear as day to anyone and everyone who looks at the code.
- Tolexx 4y ago>Guess I should start my 5th attempt at finally getting good at Rust. I guess i should do the same too but I have really and man the language is not easy to grok. These days it also feels like if you don't know Rust, you are somewhat "old school".
- vbtemp 4y ago> Either Rust is significantly better than C++ in his view Do you remember the Paul Graham essay on the Blub programming language? (http://www.paulgraham.com/avg.html http://www.paulgraham.com/avg.html) C++ is kind of like the Blub language. If you know C++ well enough, you can do anything you need to do, so something like Rust just seems too esoteric and weird and pretentious. Fortunately, I spent many years using Rust recently (coming from primarily a C background) and when I'm on a project using C++, it just feels too weird and rudimentary and horribly over-complicated. To end with a quote from the PG article: _But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub._
- Jensson 4y agoPaul Graham favored Lisp, which gives programmers limitless freedom to implement whatever they want, Rust is the opposite side of that. C++ is full of footguns and it is easy to make mistakes, but it is also one of the most powerful and expressive languages out there.
- seg_lol 4y agoRust gives you data race freedom and memory safety and a myriad of other great correctness preserving qualities like Options, `unsafe {` and a high quality type system. Not to mention that it is blazingly fast.
- Jensson 4y agoYes, Rust is much easier to write and faster to learn than C++. This makes Rust better for many cases, but you can't really say it is more powerful. C++ templates are hard to learn and understand, but they are one of the most powerful constructs we have in any programming language, I miss them when I work in other languages.
- 4y ago
- jahewson 4y ago> significantly better than C++ You say that like there’s some scalar measure of “better”.
- tialaramex 4y agoSurely it's implied in context that this is better for developing the Linux kernel, by Linus and Linux kernel developers ?
- masklinn 4y ago> Either Rust is significantly better than C++ in his view Probably this one: - Rust has the clear goal of memory safety, which is an active issue in the kernel (see: Kees Cook's Kernel Self Protection Project), even more so when it comes to drivers which are a lot more variable in quality and have very variable levels of oversight, which is why those are the primary use case. - Rust has a much more expressive type system, especially without the need to go into template weeds. - Rust has a lot less implicit behaviours. - Rust features tend to be more orthogonal and mis-interact less with one another. - While Rust has a fairly steep learning curve, short of unsafe it doesn't kneecap you, if it doesn't like what you're doing (right or wrong) it tells you, it doesn't go off into the weeds doing the wrong thing.
- btreesOfSpring 4y agoAll great points. It is also a young enough language that significant kernal dev can have significant influence on the future of the language itself. CPP's future seems to be predicated upon its past adoption.
- tialaramex 4y agoAnd while there are no shortage of C++ programmers who've said "just use C++" over the years, not too many actually lifted a finger to make it happen - the people who wanted Rust for Linux actually built Rust for Linux. https://rust-for-linux.github.io/docs/kernel/ https://rust-for-linux.github.io/docs/kernel/ Out of that, core is basically just what you get from Rust's core itself, alloc is similar to Rust's provided alloc but is fairly heavily customised to meet the requirements of the kernel and of Linus. But kernel is custom code for the kernel specifically. Overall that's a lot of effort. We didn't see a similar effort for C++. Would that have overcome Linus' reluctance? Well, it can't if it doesn't exist.
- npigrounet 4y ago
- est31 4y agoLinus had been positive towards Rust way before those projects started, way more than he was towards C++. C++ had plenty of kernels written in it, he still didn't want it near his tree. Rust is just a better language in his eyes for kernel purposes than C++ and I absolutely agree with him.
- endorphine 4y agoMy view is he's being pragmatic. Why switch from C to C++? The expected value from such a change isn't worth the effort. Rust though? That could make the kernel more secure in the long-term and rule out a whole class of bugs. This makes sense.
- unrealhoang 4y agoI think the main point is Rust takes much less time to learn to be able to contribute to a complex code base at the caliber of Linux. With safe abstraction on top of unsafe, the seasoned/guru developers can build building blocks for intermediate/beginner to confidently use and contribute on the higher level.
- sam0x17 4y ago> Guess I should start my 5th attempt at finally getting good at Rust. The thing that finally made Rust click for me was doing a usb HID project. Suddenly all the machinery around ownership and multi-threading made sense and I was able to get things done, and I could suddenly also do all the things I previously attempted to do in Rust.
- brundolf 4y agoI think it's both. I remember reading at one point (not sure if it was quote or speculation) that the difference is C++ adds a lot of abstractions that: - Have hidden costs - Have sneaky failure-modes C just... doesn't add any abstractions. And then Rust adds abstractions, but makes a concerted effort to avoid ones that have these two problems
- nyxtom 4y agoI think a lot of it comes from the fact that he realizes there is a demand for kernel maintainers in the future and the C expertise isn't there as well. If you can get maintainers to come in that are Rust devs then they can work on things without introducing significant issues due to some of the default safety guarantees and guardrails that Rust provides while at the same time having approximate to near performance parity