Over the last few months, I’ve been working (on and off) at translating the Brotli compression library into Go. (The result is at github.com/andybalholm/brotli.) I’d like to share what I’ve learned.
I tried various tools: rsc/c2go, elliotchance/c2go, Konstantin8105/c4go, and a tool that I developed myself (leaven). I kept coming back to rsc/c2go because it produces the cleanest, most readable output. But I was frustrated by its limitations; there are so many C constructs that it can’t handle. Finally I realized that the only way a C-to-Go transpiler can produce readable output is to limit itself to the subset of C that maps to Go fairly cleanly. And the way to deal with that is to progressively refactor the C project into that subset of C. In practice, it turned out to be a two-sided process. I worked on c2go to make it handle more of the constructs used in brotli, and I refactored the brotli codebase to get rid of things c2go couldn’t handle, until the two converged. My fork of rsc/c2go is at github.com/andybalholm/c2go; the README contains some more of my thoughts on the transpilation process, and a general summary of how to go about translating a C project. Andy -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.