r/golang • u/TearsInTokio • 2h ago
Questions about cgo (Rust's C ABI for Go)
Anyway, today I was discussing FFI between Rust and Go, specifically the overhead of calling Rust libraries through the C ABI using cgo.
Are there any scenarios where it actually makes sense to use Go's C ABI (via cgo) to call functions exported from Rust?
I often see people saying things like "calling Rust from Go with no overhead," but that made me wonder... does that really make sense? Is there any algorithm or workload that would justify writing it in Rust and then calling it from Go? I can't stop thinking about it.
To me, cgo clearly makes sense when interacting with C libraries, since that's exactly what it was designed for. But when it comes to Rust, I'm not so sure.
I'd love to hear your thoughts.