u/MrEchowin r/rust • Recommends
On “Result<(), Box<dyn Error>> vs anyhow::Result<()>”
#dynamicdispatch#vtable#dyntrait
51K subscribers • 6 videos on Hallway
Intermediate. Assumes working knowledge.
140K views3 years ago3 recommendations
Programming languagesSystems programmingRustC++Performance and optimization
Logan Smith compares how Rust and C++ implement dynamic dispatch, exploring vtables, wide pointers, and manual pointer management.
Rust and C++ both have built-in (but different-flavored) support for dynamic dispatch, and both also let you open the hood and implement it the other way that's not built-in. In this one we look at both languages' approaches, weigh the pros and cons, and ultimately come away seeing that they're both the right choice in different situations (isn't that just so unsatisfying and typical). Special guest appearances from vtables, vptrs, wide pointers, thunks, unsafe code, drop glue, virtual destructors, the Rule of Three, and me re-recording the live coding section like 5 times because I kept messing it up. the Sean Parent talk - youtube.com/watch?v=QGcVXgEVMJg godbolt to the demo - rust.godbolt.org/z/6YrK3vhGj dyno - github.com/ldionne/dyno NonNull - doc.rust-lang.org/stable/std/ptr/struct.NonNull.html thunk - en.wikipedia.org/wiki/Thunk std::function - en.cppreference.com/w/cpp/utility/functional/function std::any - en.cppreference.com/w/cpp/utility/any I use the amazing Manim library for animating these videos, and I edit them with Blender and Audacity. manim.community/ blender.org/ audacityteam.org/What people say. Recommended for its clear explanation of how dynamic dispatch and dyn Trait work under the hood in Rust compared to C++.
u/MrEchowin r/rust • Recommends
On “Result<(), Box<dyn Error>> vs anyhow::Result<()>”
u/ZZaaacccin r/rust • Recommends
On “Visualizing Rust's Vtables: How dyn Trait Works In Memory (Comparison to C++ CRTP & virtual functions)”
u/ZZaaacccin r/rust • Recommends
On “Which parts of Rust do you find most difficult to understand?”
u/MalbaCatoin r/rust • Recommends
On “What's the role of manual pointer and vtable management in Anyhow?”