A different serde
*And now for something completely different* A bit about how serde works well, a bit about how serde doesn't work well, and a bit about a different, questionable way of doing things Visit https://sdr-podcast.com/episodes/a-different-serde to see the show notes and transcript! Sponsor: CodeCrafters is a service for learning programming skills by doing. Visit our referral link at https://app.codecrafters.io/join?via=sdr-pod to start your free trial. If you upgrade, you'll get a discount and a portion of the sale will support this podcast. [00:00:52] A different serde [00:02:41] Serde has some problems - can I do it better? [00:03:39] How serde works: [00:04:55] The visitor pattern [00:08:18] Problem: this generates a LOT of code [00:11:34] Problem: the visitor pattern is recursive [00:14:03] Postcard: more flexibility than we need [00:16:06] Postcard-forth [00:23:47] Turn ser/de into a “stack machine” [00:27:02] Good things first [00:30:02] Serialization benchmarks # Shownotes - serde https://serde.rs/ - Diagnostic and Statistical Manual of Mental Disorders DSM https://en.wikipedia.org/wiki/Diagnostic_and_Statistical_Manual_of_Mental_Disorders, delayed sleep phase disorder https://en.wikipedia.org/wiki/Delayed_sleep_phase_disorder - David Tolnay @dtolnay https://github.com/dtolnay - James' Bluesky post https://bsky.app/profile/jamesmunns.com/post/3ktsi3xdgy62u - tokei - a tool for counting lines of code https://github.com/XAMPPRocky/tokei, cargo-expand https://crates.io/crates/cargo-expand - Return value optimization RVO https://en.wikipedia.org/wiki/Copy_elision#Return_value_optimization and named return value optimizationNRVO https://en.wikipedia.org/wiki/Copy_elision#NRVO - postcard-forth https://github.com/jamesmunns/postcard-forth - speed benchmarks https://github.com/jamesmunns/postcard-forth/?tab=readme-ov-file#rust-serialization-benchmark - size and compile time benchmarks https://github.com/jamesmunns/postcard-forth/blob/main/source/rp2040-demo/results.md - tool for generating a lot of nested types https://github.com/jamesmunns/postcard-forth/blob/main/source/stress-gen/src/main.rs - Atkinson Hyperlegible https://fonts.google.com/specimen/Atkinson+Hyperlegible - type erasure https://en.wikipedia.org/wiki/Type_erasure, the void type in C and `void*` or 'void star' pointer https://en.wikipedia.org/wiki/Void_type, opaque pointers https://interrupt.memfault.com/blog/opaque-pointers - `offset_of!` macro https://doc.rust-lang.org/core/mem/macro.offset_of.html, `offset_of!` for enums https://github.com/rust-lang/rust/issues/120141 - Virtual Method Tables, or vtables https://en.wikipedia.org/wiki/Virtual_method_table - monomorphizing generic functions to create a vtable in `tokio` https://github.com/tokio-rs/tokio/blob/c07257f99f92c5d6773fc0827bcfd77e43f0fd46/tokio/src/runtime/task/raw.rs#L47-L60 - "splatting" in Python https://www.bitecode.dev/p/the-splat-operator-or-args-and-kwargs - `reprRust` https://doc.rust-lang.org/nomicon/repr-rust.html, `reprC` https://doc.rust-lang.org/nomicon/other-reprs.html, Experimental `reprcrabi` https://github.com/rust-lang/rust/issues/111423 - Foreign function interface FFI https://en.wikipedia.org/wiki/Foreign_function_interface - Forth programming language https://en.wikipedia.org/wiki/Forth_programming_language - the `stacker` crate https://github.com/rust-lang/stacker, setjmp/longjmp https://en.wikipedia.org/wiki/Setjmp.h - rkyv https://crates.io/crates/rkyv, Rust serialization benchmark https://github.com/djkoloski/rust_serialization_benchmark - chrono https://docs.rs/chrono/latest/chrono/, nalgebra https://docs.rs/nalgebra/latest/nalgebra/ - miri https://github.com/rust-lang/miri - rust-lang RFC: Unsafe Set Enum Discriminants https://github.com/rust-lang/rfcs/pull/3727 - Blog post: Building Plain Old Data from Scratch https://onevariable.com/blog/pods-from-scratch/
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.