Solod: Go Subset with Manual Memory Management and C Compilation
Solod (So) is an open-source project providing a subset of Go that's transcompilable to C11. The code compiles with GCC, Clang, or zig cc without a runtime or garbage collector. The transpiler is written in Go under the BSD license and supports Linux, macOS, and Windows.
Manual memory management eliminates GC, automatic allocation, and reference counting. Memory is placed on the stack by default, with the heap available via Alloc/Free from the standard library. Type checks and bounds checking for array overruns are built-in, but dangling pointers and leaks are not tracked. For debugging, AddressSanitizer is recommended (-fsanitize=address).
Supported Constructs
Solod retains key Go features for convenience:
- Structs and methods.
- Interfaces.
- Slices.
- Multiple value returns (result + error).
- Generics.
- Defer.
Channels, goroutines, and closures are absent—the focus is on determinism and performance.
Integration with existing Go tools: LSP servers, linters, IDEs, go test. Solod code can be called from C and vice versa without a runtime.
Libraries and Use Cases
Go packages ported to C:
- strings
- io
- bytes
- mem
- slices
Wrappers over libc are available. Main use cases:
- Systems programming with Go syntax and C-level typing.
- Porting Go libraries to C projects.
- High-performance applications without GC overhead.
Performance
Benchmarks show advantages over Go:
| Operation | Speedup vs Go | Memory Consumption |
|----------------------------|------------------|--------------------|
| Byte functions | 1.5x | identical |
| Byte buffers (reading) | 1.3x | - |
| Byte buffers (writing) | 2–4x | - |
| Map (int key get) | 3.4x | - |
| Map (int key mod) | 0.6x (slower) | - |
| Map (string key get) | on par | - |
| Map (string key mod) | 0.67x | - |
| int parsing/formatting | 2x | - |
| float | 1.5/1.2x | - |
| String functions | 1.3x | - |
| String creation | 2–4x | -10–20% |
Solod is suited for mid-level and senior developers seeking a balance between Go's expressiveness and C's low-level control.
Key Points
- No GC: manual memory management for predictable performance.
- C Interop: direct calls without runtime.
- Go Tools: compatibility with the ecosystem.
- Performance: 1.3–4x faster than Go in key operations.
- Checks: bounds checking and type safety without runtime overhead.
— Editorial Team
No comments yet.