'Rust makes coding fun again': Why Linux is moving away from C, according to Greg Kroah-Hartman

https://www.zdnet.com/article/greg-kroah-hartman-linux-kernel-rust/

84 points · 20 comments · view on lemmy.world

20 Comments

Grail@multiverse.soulism.net · 33 pts · 43d

"Programming is fun again"

jerkface@lemmy.ca · 18 pts · 43d

C was "fun" once. Hell, C is becoming so obscure, it's fun again!

victorz@lemmy.world · 8 pts · 43d (12 replies)

If anyone has some insight: is Rust more or less verbose than C, generally? Like if Linux would be rewritten in Rust, would the LOC increase or decrease, e.g.?

psud@aussie.zone · 23 pts · 43d (5 replies)

It's easier than C, it's safer than C, the compiler is more helpful than GCC

I think it's fun

Less verbose? I don't think so

Lines of code about the same

For someone starting out as a programmer for low level programming I would recommend rust

victorz@lemmy.world · 3 pts · 43d (4 replies)

For the same purpose, would you recommend Rust over Zig?

mschae@discuss.mschae23.de · 12 pts · 42d (1 reply)

As someone who has used both (but not for any serious, large projects), I'd say they target different audiences. First and foremost, Zig is not memory-safe in the way Rust is. On the other hand, Zig is way easier to write than unsafe Rust. Rust comes with a lot of features and libraries, while Zig is an intentionally small language, almost minimalistic (kind of like C, but modern).

There are lots of different tradeoffs being made, so yes, I'll give the boring answer and say they are good for different kinds of projects :)

If it's specifically low level programming (I'm envisioning programs where you need fairly direct control over memory, IO, etc.), you'd probably quickly need a lot of unsafe in Rust, which can quickly get very complicated to use safely. So I'd probably recommend Zig for that purpose.

victorz@lemmy.world · 5 pts · 42d

I should've known it's a "it depends" answer. πŸ˜† It's programming languages after all. πŸ˜‰

Thanks for the insight though, I appreciate it! πŸ™

psud@aussie.zone · 1 pts · 42d (1 reply)

I know nothing about Zig

victorz@lemmy.world · 1 pts · 42d

Alright, thank you.

HaraldvonBlauzahn@feddit.org · 13 pts · 43d (3 replies)

I think at the lowest level, it is very similar.

But with a bit more abstraction, Rust is somewhat less verbose, especially when the same efficiency is required. Thinking im iterators / loops or generics, or enumerations / sum types. Also, the module system, build system, integrated unit tests, and compiler messages are huge gains for productivity.

victorz@lemmy.world · 3 pts · 43d (2 replies)

Cool, thank you. Might tackle Rust next year then.

This year I'm getting into OCaml. 😊

syklemil@discuss.tchncs.de · 4 pts · 43d (1 reply)

OCaml should transfer pretty well to Rust. Rust can feel like an ML dressed up in C's braces.

Similarly, if you can write in Haskell without having to reach for IO, then you can probably satisfy Rust's borrow checker with no more effort.

victorz@lemmy.world · 2 pts · 42d

Thanks for that insight. I did some small delving into Haskell years ago, but I found the tooling to be so awkward, and "monads" so confusing and poorly explained everywhere, that I eventually gave up trying to learn more.

But OCaml seems pretty nice. Familiar, but with hopefully better tooling. 🀞

fubarx@lemmy.world · 12 pts · 42d (1 reply)

Rust has a lot more 'batteries included' than C, and the memory ownership model works a lot better than garbage collection or C's YOLO model. It also has built-in async/await. But you're pretty much in the same boat as C when it comes to multiprocessing or thread-safety.

Anyone building a long-running backend service would be wise to take a serious look at Rust. Personally, I'm glad Linus is open to change and isn't digging his heels in on this one.

victorz@lemmy.world · 4 pts · 42d

I agree with you on Linus. Very pragmatic here, and for the benefit of all in the case of Rust in the kernel.

And thanks for sharing your insight!

Uncut_Lemon@lemmy.world · -14 pts · 43d (4 replies)

Fun because you like rewriting existing code?

Fun because you already have test suites you don't have to rewrite?

Fun because you feel morally superior by writing fresh code, even though the old code is running critical applications in production?

Fun because you think your smarter than the engineers that lay the ground work before you?

Fun because you like hunting bugs you created thinking you know better, while calling your rewrite superior.

ScientifficDoggo@lemmy.zip · 5 pts · 42d (1 reply)

Imagine taking someone else's joy THIS personally...

Tempy@programming.dev · 2 pts · 42d

I think it's more to do with, are you really examining your feelings and understanding where they are coming from? Working with something new, that puts you back in the place of having to learn stuff again, is often enjoyable, not because of the thing you are using, but because it's new and your brain, despite what people think, likes learning new things.

I'm glad people feel like they are having fun with rust. But the Rewrite it in Rust crowd are just creating more work for the sake of it.

And I'm a fan of rust.

But hey ho, if they want to spend their time recreating stuff we have excellent options for, who am I to stop them. I just think there are better things they could spend their time on.

ISO@lemmy.zip · 2 pts · 41d

Fun because you like rewriting existing code?

Rust4Linux is not a "rewriting" endeavor.

Fun because you already have test suites you don’t have to rewrite?

See previous point.

Fun because you feel morally superior by writing fresh code, even though the old code is running critical applications in production?

Can you point to where "moral superiority" was used as a reason for using Rust in the Linux kernel?

Can you point to an example where Rust code in the kernel caused breakage in "critical applications in production"?

Bonus: Do you think "critical applications" closely follow mainline?

Fun because you think your smarter than the engineers that lay the ground work before you?

Who were the engineers that came before Greg Kroah-Hartman?

What ground work exactly are you referring to?

How does Rust code in the kernel relates to this?

Fun because you like hunting bugs you created thinking you know better, while calling your rewrite superior.

Better than whom?

What rewrite?

Where was it stated that the fun was in hunting more bugs?

Bonus: Do I actually prefer it if someone other than the original coder is hunting bugs?


And to finish with a meta question:
Why the likes of you feel the need to share opinions based on fictional events regarding matters your clearly completely clueless about?

jimmy90@lemmy.world · 0 pts · 42d

yes all of those things are true

you catch on quick. also we extend test suites and our coding style is adopted by C coders because of its god-like superiority

it's fun watching rust succeed over bad old C everywhere it is used isn't it?

HIGH FIVE