this post was submitted on 17 Apr 2021
32 points (94.4% liked)

Linux

49493 readers
1040 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
all 9 comments
sorted by: hot top controversial new old
[–] [email protected] 8 points 3 years ago
  • sigh * time to learn rust
[–] [email protected] 5 points 3 years ago (3 children)

As someone who knows no rust, what makes rust so appealing for writing the Linux kernel as opposed to all the languages that have existed since C++?

[–] [email protected] 16 points 3 years ago

Well, most programming languages since C++ were just straight-up unusable in a kernel.

The likes of Java, Python, Haskell need a kernel already up and running, so that they can start their virtual machine to execute your code.
And even some languages that don't need that, like Go, were unusable for kernel development, because you have basically no control over memory allocations.

Ada probably failed to gain popularity in kernel development, because there were only proprietary compilers at first, so it never gained much mind share in the open-source community in general.

And besides that, a large part of it was that C wasn't that bad yet (in comparison to the then-modern programming languages).

But Rust is also just really fucking good. We haven't seen a low-level language with that much funding in decades. And it has a type system that rivals the most competent high-level languages (Haskell, OCaml, Scala etc.).

In particular, it also promises to eradicate memory-related bugs which make up about 70% of vulnerabilities in the kernel.

There's also this post to the Linux Kernel Mailing List, which explains why or why not Rust (doesn't compare it much to other languages): https://lkml.org/lkml/2021/4/14/1023

[–] [email protected] 10 points 3 years ago

Rust eliminates a lot of memory safety problems at compile time. Roughly speaking once you allocate memory and assign a variable to it, that variable "owns" said memory. A variable owning memory is responsible for its lifetime and just like in many other programming languages once it goes out of scope, the memory is released.

So far so boring. What makes Rust different is the borrow checker. It ensures that all references (equivalent to pointers in C) to some memory (in this case not owned), are always valid. Like that it is impossible to access invalid blocks of memory in (safe) Rust. You never have to wonder who is responsible for deallocating memory and you never have to fear dangling pointers as those simply do not exist in Rust.

I am sure there is much more to it, but this is certainly one of the arguments.

[–] [email protected] 6 points 3 years ago

Mostly memory safety vs other systems languages. I'm not super knowledgable on the details as I'm a hobbyist pythonista, but I've been looking through the Rust book to slowly learn it for projects that might be better than using Python.

[–] [email protected] 3 points 3 years ago

Linus in 2022: sorry guys, no releases this year, we've been chasing a runaway borrow around the kernel instead of facepalming unexpected memory allocation issues :D

[–] [email protected] 2 points 3 years ago (1 children)

I hope Bjarne does not hear of this

[–] [email protected] -1 points 3 years ago

Kotlin and Rust are going to run the world a decade from now.