Gophercamp2026
Back to all sessions

Transpiling Go to Rust and Others

by Przemyslaw Delewski

About this Session

Abstract Goany (https://github.com/pdelewski/goany) is a transpiler that takes a subset of Go and compiles it to C++, C#, Rust, JavaScript, and Java, allowing developers to write portable libraries once using familiar Go syntax and tooling. In this talk, attendees will learn why Go's simplicity makes it uniquely suited as a transpilation source, how to design a minimal yet practical language subset for cross-language compatibility, and what trade-offs arise when mapping Go constructs to fundamentally different languages. Talk Description Have you ever implemented the same logic twice because one component was written in Go and another in a different language? This is a common problem in polyglot systems, and existing solutions — C bindings via FFI, IDL-based code generation, or transpilers like HAXE — each come with significant trade-offs: adoption barriers, serialization overhead, or the need to learn an entirely new language. This talk introduces a different approach: using Go itself as the source language for cross-language transpilation. https://github.com/pdelewski/goany is not a theoretical exercise — it is a working project that already transpiles Go code to five target languages. During this session, I will show practical examples of transpiled code, including a C64 emulator and a GUI demo running in the browser, and walk through the design decisions behind building such a tool. But building a transpiler is only half the challenge — the other half is deciding what to transpile. I will cover: - The problem: why reusing logic across language boundaries remains painful, and why existing approaches (FFI, Protobuf/gRPC, HAXE, FusionLang) fall short in certain scenarios - Why Go is a great fit: its small, well-defined spec, comprehensive standard library, and strong tooling make it an ideal transpilation source — unlike custom languages, every goany program is a valid Go program - Designing the subset — what to include and why: the guiding principle behind goany's subset is to include only constructs that produce nearly one-to-one correspondence between input and output in every target language. I will walk through the reasoning behind what made the cut (primitives, slices, structs, multiple returns, methods, loops, conditionals) and what was deliberately left out (goroutines, generics) with examples of how each decision affects the generated code. The subset is intentionally a work in progress — it started minimal and is gradually expanding as new constructs prove they can be mapped cleanly across all targets - How goany works: a walkthrough of the transpiler architecture — parsing Go's AST, mapping the chosen subset to target language constructs, and producing readable output in C++, C#, Rust, JavaScript, and Java - Live demos: a C64 emulator and a GUI application running in the browser via JavaScript transpilation, demonstrating that this focused subset is already sufficient to build non-trivial, real-world applications - Challenges: dealing with memory model differences, producing idiomatic output, and the ongoing tension between expanding the subset and maintaining clean transpilation The key insight of this talk is that designing a transpiler subset is not about supporting as many features as possible — it is about finding the largest common denominator across target languages, and evolving that denominator over time as you learn what works. Attendees will walk away with a concrete framework for thinking about cross-language compatibility, practical knowledge of building tools on top of Go's AST packages, and a new perspective on how Go's deliberate simplicity enables use cases that more complex languages cannot.