HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

Rust NYC: Jon Gjengset - Demystifying unsafe code

Rust Programming Language2 HN recommenders · recommended in 2 months, 2020-2024
YouTube
27K views · 6 years ago · talk · evergreen

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.

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

C, C++, Rust, Go & systems languagesSecurity & hacking#rust#unsafe#rustonomicon#memorysafety#jongjengset

3 comments from Hacker News

@saghm2024 · in “Compiling C to Safe Rust, Formalized”

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 way more to write unsafe Rust code than me than me have argued that unsafe Rust can be harder than writing C in some ways due to having to uphold certain invariants that don't come up in C. While there are a number of blog posts on the topic that anyone interested can probably find fairly easily by googling "unsafe Rust harder than C", I'll break my usual rule of strongly preferring articles to video content to link a talk from youtube because the speaker is one of those people I mention who I'd trust more than me to write unsafe code and I remember seeing him give this talk at the meetup: ▶ this video

RecommendsView on HN
@ibraheemdev2021 · in “The Rustonomicon”

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 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF UNLEASHING INDESCRIBABLE HORRORS THAT SHATTER YOUR PSYCHE AND SET YOUR MIND ADRIFT IN THE UNKNOWABLY INFINITE COSMOS. I know it's a joke, and I laughed when I first read it. Unsafe is dangerous and requires care, but unsafe == evil is definitely not true. Jon Gjengset said it well in "Demystifying Unsafe Code" [0]: > 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 is totally fine and not nothing to worry about, and I wanted to take a little bit of time to talk about what unsafe is because I think a lot of where the communities lack of alignment on this particular topic comes from a fact that unsafe is a bit of a mystery to many of us Learning about unsafe is useful, and at time necessary, it's not inherently evil, nor should it be used too freely. [0]: ▶ this video

CitesView on HN
@Sammi2020 · in “How to speed up the Rust compiler in 2020”

There's a great new talk by on Gjengset on youtube that tackles just this question: Rust NYC: Jon Gjengset - Demystifying unsafe code ▶ this video

RecommendsView on HN
RustConf 2020 - Closing Keynote by Siân Griffin39:03

RustConf 2020 - Closing Keynote by Siân Griffin

Rust Programming Language
10K views • 6 years ago
Implementing (part of) a BitTorrent client in Rust4:09:16

Implementing (part of) a BitTorrent client in Rust

Jon Gjengset
115K views • 3 years ago
RustConf 2017 - Closing Keynote: Safe Systems Software and the Future of Computing by Joe Duffy42:45

RustConf 2017 - Closing Keynote: Safe Systems Software and the Future of Computing by Joe Duffy

Confreaks
2K views • 9 years ago
The Why, What, and How of Pinning in Rust3:03:54

The Why, What, and How of Pinning in Rust

Jon Gjengset
87K views • 7 years ago
Rust at speed — building a fast concurrent database52:54

Rust at speed — building a fast concurrent database

Jon Gjengset
225K views • 7 years ago
Is It Time to Rewrite the Operating System in Rust?1:09:18

Is It Time to Rewrite the Operating System in Rust?

InfoQ
310K views • 7 years ago
Rust: A Language for the Next 40 Years - Carol Nichols55:08

Rust: A Language for the Next 40 Years - Carol Nichols

ChariotSolutions
367K views • 7 years ago
Crust of Rust: Lifetime Annotations1:33:23

Crust of Rust: Lifetime Annotations

Jon Gjengset
299K views • 6 years ago
Lars Bergstrom - Beyond Safety and Speed: How Rust Fuels Team Productivity22:19

Lars Bergstrom - Beyond Safety and Speed: How Rust Fuels Team Productivity

Rust Nation UK
18K views • 2 years ago
Hacking with Andrew and Brad: tip.golang.org1:02:49

Hacking with Andrew and Brad: tip.golang.org

The Go Programming Language
99K views • 11 years ago
Microsoft is Getting Rusty: A Review of Successes and Challenges - Mark Russinovich34:41

Microsoft is Getting Rusty: A Review of Successes and Challenges - Mark Russinovich

Rust Nation UK
46K views • 1 year ago
GoingNative 2012 - Day 2 - Clang1:00:54

GoingNative 2012 - Day 2 - Clang

aghuttun
13K views • 13 years ago
Going Native 2012 Keynote Stroustrup1:29:49

Going Native 2012 Keynote Stroustrup

savage309
33K views • 14 years ago
Carbon Language Successor Strategy: From C++ Interop to Memory Safety - Chandler Carruth - CppNow 231:38:57

Carbon Language Successor Strategy: From C++ Interop to Memory Safety - Chandler Carruth - CppNow 23

CppNow
24K views • 3 years ago
Crust of Rust: async/await2:34:01

Crust of Rust: async/await

Jon Gjengset
246K views • 5 years ago
GopherCon 2014 Inside the Gophers Studio with Blake Mizerany48:19

GopherCon 2014 Inside the Gophers Studio with Blake Mizerany

Confreaks
8K views • 12 years ago
Dconf 2014 Day 2 Keynote: The Last Thing D Needs -- Scott Meyers54:55

Dconf 2014 Day 2 Keynote: The Last Thing D Needs -- Scott Meyers

The D Language Foundation
19K views • 8 years ago
Vibe coding complex changes in Rust2:59:08

Vibe coding complex changes in Rust

Jon Gjengset
55K views • 1 year ago
CppCon 2015: Bjarne Stroustrup “Writing Good C++14”1:40:46

CppCon 2015: Bjarne Stroustrup “Writing Good C++14”

CppCon
351K views • 11 years ago
Zig Roadmap 2023 - Andrew Kelley43:20

Zig Roadmap 2023 - Andrew Kelley

Zig SHOWTIME
77K views • 4 years ago