Highlights from This Week in Rust - Issue 444. This week features a juicy post-mortem, open source, open hardware, and lots of news from around the Rust ecosystem. Contributing to Rustacean Station Rustacean Station is a community project; get in touch with us if you’d like to suggest an idea for an episode or offer your services as a host or audio editor! Twitter: @rustaceanfm Discord: Rustacean Station Github: @rustacean-station Email: hello@rustacean-station.org Timestamps & referenced resources [@00:00] Welcome [@00:10] - Introduction [@00:50] - Agenda [@01:23] - Quote of the week This is the difference in approaches of the two languages. In C++ if the code is vulnerable, the blame is on the programmer. In Rust if the code is vulnerable, Rust considers it a failure of the language, and takes responsibility to stop even “bad” programmers from writing vulnerable code. I can’t stress enough how awesome it is that I can be a careless fool, and still write perfectly robust highly multi-threaded code that never crashes. [@03:09] Allen: Rust is both good and bad at marketing [@03:30] - Crate of the week [@04:15] - Tim and Sean discuss parsing in episode 2022-05-26 at 47:10 [@05:10] Official Notices [@05:22] - Announcing Rust 1.61.0 Custom exit codes from main [Note from Tim: I say “termination crate”, but should have said “Termination trait”.] More capabilities for const fn “Basic” handling of fn pointers Add trait bounds to a const fn dyn trait and impl Trait support Stdio handles can be locked directly Several stabilized APIs [@08:07] Highlights [@08:27] - Developer survey: JavaScript and Python reign, but Rust is rising [@09:09] - Sean: “Rust adoption has nearly quadrupled in the last two years, going from 600k developers in Q1 2022 to 2.2m in Q1 2022.” [@13:00] - Redust by Will Nelson [@13:50] Allen: I think the comments are actually more interesting. They are starting to point to something really—I don’t know whether it’s good or bad for the community—where, you know, people start rolling their own crates instead of, say, doing stuff upstream. It kind of goes back to what Tim was complaining about before [Easy Mode for Rust, discussed on This Week in Rust - Issue 441]—well, lightly pointing out to people out there—that okay, now which crate should I use? [@16:20] Tim: Open source is really complicated. You need to talk to people. That’s … challenging. [Laughs] [@16:40] Josh Triplett on Building with Rust, discussing the orphan rule [@16:50] Sean: Rust is not very good at sharing between crates. [@19:07] - Rust: A Critical Retrospective by bunnie Links The Hardware Hacker, bunnie’s autobiography [video] “Shenzhen: An Alternative to the American way of Innovation” [@28:56] A Programmer’s Brain, by Felienne Hermans, about working memory in programmers. [@19:58] - Hacking the Xbox book [@20:04] - [video] Linux.conf.au 2013 keynote discussing Chumby and creating a hardware startup [@20:20] - betrusted.io, a secure communications system that runs the Xous microkernel operating system [@21:07] - Tim: Security-critical applications have issues when they … rely on Rust. There’s one quote I want to pull out of the post, which is: “I’m not sure if there is even a good solution to this problem, but, if you are super-paranoid and your goal is to be able to build trustable firmware, be wary of Rust’s expansive software supply chain attack surface!” [@26:09] - Sean: bunnie I think that you are absolutely, totally, qualified. [@30:17] - Allen: I did see a macro that he put in there. … I forget extact. It was very crazy and I was like, “Come on, no one’s every going to write something crazy like this” and then I took a look at the RFC that Sean’s gonna do and in the comments there was a crazy one like that and I was like, “oh wow, this guy’s point’s valid”. [@30:49] - Hyrum’s Law, named after Hyrum Wright. With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody. [@31:50] Fixing memory leaks by Lily Mara [@34:01] - tracing crate, created as part of the tokio project [@32:33] - “Is it possible to cause a memory leak in Rust?” - Stack Overflow [@33:06] - std::ops::Drop trait documentation std::mem::forget and Box::leak for intentionally leaking memory Out-of memory (OOM) killer internals page from the Linux memory management wiki [@37:54] tracing::instrument::Instrument trait, which fixes this issue [@41:29] Building a Cloud Database from Scratch: Why We Moved from C++ to Rust by Yingjun Wu GAT (generic associated traits) Allen: [C++ vs Rust] is like apples vs apple pie. [@45:50] - [video] Deref and Drop traits by Dan Chiarlone “Smart pointers”, chapter 15 of The Rust Programming Language. std::ops::Deref trait documentation [@46:40] - Optimizing the size of your Rust binaries by Sylvain Kerkour cargo-bloat, for determining the size impact of code and dependencies twiggy, a similar tool for WASM targets [@48:10] - RFC: Add more support for fallible allocations in Vec by Daniel Paoliello and contributors Sean: This RFC is intended as a stop-gap, to unblock on-going work like—I imagine—adding Rust to the Linux kernel while better long-term solutions are explored. “Example: Implementing Vec” chapter of the Rustnomicon, describes how Vec’s memory allocation works in detail Never type reference documentation [@54:40] Tim: I want to bring out a comment that was made to me in private, because I’ve been toying with the idea of becoming a rustc contributor, particularly on the standard library side, and Ashley Mannix sent me a really lovely note, which was: “Rust is also chronically friendly so nobody gets chewed out for making mistakes. They happen. They get caught. They get patched. You learn something new. It’s ok.”. [@55:51] - How we use Rust, SQLx and Rocket for Oso Cloud by Steve Olsen Other items [@57:20] Meetups [@57:31] Major release announcements DataFusion 8.0 IntelliJ Rust plugin 2022.1 [@57:40] Join us in the #this-week-in-rust channel of the Rustacean Station Discord server Credits Intro Theme: Aerocity Audio Editing: Aleksandar Nikolic Hosting Infrastructure: Jon Gjengset Show Notes: Tim McNamara Hosts: Tim McNamara, Sean Chen, and Allen Wyma.