Rust NYC: Jon Gjengset - Demystifying unsafe code

Channel:Rust Programming Language · Length:29:24 · Published:2020-03-10 · Views:26887

Watch on YouTube

Summary

Jon Gjengset's Rust NYC talk explaining what `unsafe` in Rust actually means, why it is dangerous, and why it is sometimes necessary. He works through the Rustonomicon to separate fair concerns from overblown ones.

Why HN recommends it

HN recommends it as the best calm explanation of unsafe Rust, from a speaker commenters trust on the topic.

There's a great new talk by on Gjengset on youtube that tackles just this question — HN, 2020

C, C++, Rust, Go & systems languages · Security & hacking

Subtitles (excerpt)

Uh, so my name is John for those of you who don't already know me from one medium or another. Um, so one thing I keep observing about the Rust community is how we're all like allergic to unsafe code or we think that unsafe code is just totally fine and not nothing to worry about. Um, and I wanted to take a little bit of time to talk about what unsafe is because I think a lot of where the community's um, lack of alignment on this particular topic comes from a fact that unsafe is a bit of a mystery to many of us. And I think I want to solve that problem. Um I'm not of the illusion that I can solve this problem in like 25 minutes, but I will try. Um so in this talk I'm going to try to demystify unsafe. I'm not going to teach you how to write correct unsafe code, but I am going to try to explain some of the reasons why you might actually want unsafe and some of the reasons why you should be careful about unsafe. And it is not something you should use sort of willy-nilly. Um, you could also sum up the the this talk basically as it's just C versus its certain doom. Um, neither of these extremes are correct. And it's very important that we all agree on this. Like writing unsafe is not just writing C code.

On Hacker News

While I might agree that it's easy if you use a reference counter, this is not going to be as performant as the typical linked list written in C, which is why the standard library uses unsafe for its implementation of stuff like this. If it were "easy" to just write correct `unsafe`, then it would be easy to do it in C as well. Note that the converse to this isn't necessarily true! People I trust… — saghm, 2024-12
There's a great new talk by on Gjengset on youtube that tackles just this question: Rust NYC: Jon Gjengset - Demystifying unsafe code [VIDEO] — Sammi, 2020-04
The rustnomicon is a very good resource. It's less of "the unsafe book" and more "the advanced book", covering lower-level details and advanced concepts that aren't touch on by the book. One gripe I have is that it kind of pushes the idea that unsafe is bad and evil, which is not true at all: > The Dark Arts of Unsafe Rust > THE KNOWLEDGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS… — ibraheemdev, 2021-05

Related videos