Callable Objects in Java, C#, Rust, and C++
summary
Compares how Java uses lambdas and a runtime method handle to adapt arbitrary method names, how C# exposes a fat pointer called a delegate, and how Rust uses retrospective implementations and trait object fat pointers to attach callability to existing types. Shows C++ additions — function_ref, a move only function type and a non type template parameter that builds a pointer‑to‑member thunk at call site — that reproduce those capabilities and actually reduce indirection and boilerplate. The library change compiles and interoperates with existing code and yields measurable ergonomic gains.
AI-written summary · about
chapters (7)
- 0:00Callable objects overview
- 8:03Java functional interfaces
- 27:19C# delegates details
- 40:07Rust traits and callables
- 53:28C++ type erasure
- 1:04:39C++23 function_ref
- 1:14:04Summary
related talks
59mLambdas from First Principles: A Whirlwind Tour of C++""
05mC++20 Lambdas: Familiar Template Syntax
31mCo- and Contra-: Adding a Little Variance
35mLet’s Talk About Rust
50mWhat’s really going on under the hood? The hidden life of method calls.
01h 29mHigher-order functions and function_ref
01h 25mC++ Concepts vs Rust Traits vs Haskell Typeclasses vs Swift Protocols
42mCode Reflection
