À la carte: mix and match C, Rust and Go!
summary
Practical recipe and working code for replacing or mixing a C library with Rust or Go: a small toy name builder library implements objects, callbacks and error reporting and the repository contains a working implementation. Uses bindgen + Cargo build.rs to generate Rust bindings, cgo lookup table trick to pass Go callbacks to C, and boxed pointers for C↔Rust object handles. Two surprising lessons: calling Go from C is uncommon but possible, and most glue code is mechanical and suitable for code generation; examples work but aren’t production-tested.
AI-written summary · about
chapters (23)
- 0:00Intro
- 0:37Goal
- 1:07What we want
- 1:20Complexity
- 2:19Disclaimers
- 2:57Fun Name Builder
- 4:52Interface
- 5:20Why
- 5:50Error API
- 7:44Rest
- 7:58Rust
- 8:10Go
- 8:21Rust bindings
- 8:46Rust build script
- 14:22Go bindings
- 14:33Go flags
- 18:10C flags
- 18:30Static Linking
- 21:44Go from C
- 22:03Structure
- 29:05What we learned
- 30:51Shoutouts
- 31:21Questions
related talks
25mRust and C++
08mLightning Talk: C++ and Rust Bindings - Mixing It Best With CMake
53mC++/Rust Interop: A Practical Guide to Bridging the Gap Between C++ and Rust
31mEmbedding Rust in C/C++
01h 42mGo Vs Rust Round Table
28mC2Rust: Migrating Legacy Code to Rust
41mWe can have nice things
06mHow We Replace Common C and C++ Libraries
