News for hackers. Stuff that matters.
Re:Next steps for Rust in the kernel by packetlost on Wednesday September 21, 2022 @09:29AM (#32924869)
I was very put off from Rust because of the people acting out those stereotypes that I've encountered whenever the topic comes up. But then I decided to just learn it (partially driven by work requirements), and it's honestly great. I don't think we should be rewriting a ton of software just because there's better compiler-level safeguards, but it does make it much harder to shoot yourself in the foot without realizing it. There's some issues, dynamic linking isn't really supported. I've had good luck with various embedded targets, having trialed STM32F4s, RP2040, ESP32-C3, and am waiting on getting an NRF52840. Surprisingly, the ESP32-C3 is the best out of the box experience I've had, but library support is just not there.

IMO Rust is a really good language, and it deserves it's place in the toolbelt of most systems programmers. It's not always the right choice, but it's usually a good choice.

Re:Next steps for Rust in the kernel by gspr on Wednesday September 21, 2022 @10:14AM (#32925440)
> dynamic linking isn't really supported

This is one of my few big gripes with Rust too, but it should be pointed out that it's dynamic linking with other Rust code that isn't really supported. Dynamic linking with e.g. C libraries is a breeze.

Re:Next steps for Rust in the kernel by zozbot234 on Wednesday September 21, 2022 @11:10AM (#32926252)
You can of course link with Rust code that exports a pure C ABI. Such code works just like a shared library coded in C/C++.
Re:Next steps for Rust in the kernel by ok123456 on Wednesday September 21, 2022 @11:31AM (#32926555)
I'm not sure how useful that would be since people pin specific version of libraries with Rust. They don't care about ABI stability so even if you could just update links to a library, the interface would be horribly broken.

Part of the discipline of writing C++ and C libraries is writing around a stable interface, that you can link against. In C++ that means using the pImpl pattern.

Re:Next steps for Rust in the kernel by gspr on Wednesday September 21, 2022 @12:13PM (#32927310)
> They don't care about ABI stability so even if you could just update links to a library, the interface would be horribly broken.

Which is, of course, the actual gripe we're discussing. The lack of dynamic linking is just a consequence.

Re:Next steps for Rust in the kernel by ok123456 on Wednesday September 21, 2022 @02:50PM (#32929626)
If there's an exploit/problem in, say, a crypto library, Rust's ecosystem seems less resilient. Instead of just updating the library system wide, you have to get everyone to rebuild their applications with a safe version of the library (if it's even possible).

This has happened and will absolutely happen again. Just being "memory safe" will not prevent protocol errors, bad IVs, preventing timing attacks, or the other subtle things involved when doing cryptography on the wider internet.

Re:Next steps for Rust in the kernel by brundolf on Wednesday September 21, 2022 @05:19PM (#32931658)
On the other hand- crates.io + the toolchain make it way easier for fixes to propagate outward into the ecosystem, and then for new builds to be created with them (even for multiple platforms at once)

There's a huge list of tradeoffs between dynamic and static linking, and Rust is betting that in today's world, with modern tooling, internet availability, hardware speeds, and memory size, the benefits of static linking outweigh the costs. I guess time will tell

But- traditionally Linux has really leaned into the opposite approach, so it'll be interesting to see how that dissonance plays out, and whether one or both is forced to compromise, as Rust gets more embedded in the Linux ecosystem

Re:Next steps for Rust in the kernel by gspr on Thursday September 22, 2022 @07:15AM (#32937332)
> On the other hand- crates.io + the toolchain make it way easier for fixes to propagate outward into the ecosystem, and then for new builds to be created with them (even for multiple platforms at once)

As a Rust fan who subscribes to the classical Linux distro model (and even exclusively gets his Rust crates from there), I disagree. What you suggest comes with a cost, namely having to accept software in constant flux. To me, that cost in unacceptably big.

I write a bit more about this gripe here: https://news.ycombinator.com/item?id=32925491

Re:Next steps for Rust in the kernel by gspr on Thursday September 22, 2022 @07:01AM (#32937227)
I wholeheartedly agree. It's the one worry I have with a language that I otherwise love.

(Of course the problem is technically hard, or possibly unsolvable, so I don't blame the Rust folks for its existence.)

Re:Next steps for Rust in the kernel by consp on Wednesday September 21, 2022 @10:02AM (#32925293)
> But then I decided to just learn it (partially driven by work requirements), and it's honestly great.

I did for work as well and in my case I do not want to touch it again for quite a while. Cargo is a terrible system with all kinds of hidden and possible broken dependencies you introduce and everything depends highly on the version of rust you use. It's not even close to mature enough to consider using except for test projects. It doesn't fix programmer errors despite every rust user trying to convince me otherwise that all imported crates are perfect.

I like the idea of the language somewhat but the entire ecosystem ruins it for me.

Re:Next steps for Rust in the kernel by packetlost on Wednesday September 21, 2022 @10:17AM (#32925480)
> I did for work as well and in my case I do not want to touch it again for quite a while. Cargo is a terrible system with all kinds of hidden and possible broken dependencies you introduce and everything depends highly on the version of rust you use

I've encountered none of this. Of course Cargo is going to have broken libs, it's just a package repo like npm, pypi (+ pip), etc.. The differences between "editions" is pretty large, but I haven't seen much reason to not use the latest release in most cases. The tooling out there is very good at supporting multiple toolchains simultaneously (though, not in the same project, necessarily).

> It doesn't fix programmer errors despite every rust user trying to convince me otherwise

No engineer who knows what they're talking about will ever say this. You're either spewing lies or are believing the words of people who have no idea what they're talking about, neither of which are good. Rust helps prevent a specific class of memory errors that are very common in C (and to a lesser extent, C++). It still gives you the `unsafe` escape hatch that lets you do almost anything you can do in C.

> It's not even close to mature enough to consider using except for test projects.

Our production hard-realtime control system begs to differ.

Re:Next steps for Rust in the kernel by kouteiheika on Wednesday September 21, 2022 @10:49AM (#32925963)
> Cargo is a terrible system with all kinds of hidden and possible broken dependencies you introduce and everything depends highly on the version of rust you use.

Can you give a concrete example of this?

Re:Next steps for Rust in the kernel by maherbeg on Wednesday September 21, 2022 @11:57AM (#32927050)
What language and ecosystem do you like using? I'm curious as to what ecosystem isn't terrible unless it's just C with vendored dependencies.