Solod: Go can be a better C
5 hours ago
- #systems-programming
- #go
- #programming-languages
- Solod (So) is a new programming language that is a strict subset of Go and translates to C, designed for systems programming with Go's syntax and type safety but without hidden memory allocations.
- Key features include: Go code translates to readable C11, zero runtime (no garbage collection), stack allocation by default with heap opt-in, native C interop without CGO, and compatibility with Go tooling.
- So supports structs, methods, interfaces, slices, multiple returns, and defer, but omits channels, goroutines, closures, and generics to maintain simplicity.
- The language includes a 'Hello world' example demonstrating how Go code is translated to C, showing struct definitions, methods, and main function implementation.
- A language tour covers variables, strings, arrays, slices, maps, control structures (if/else, for), functions, multiple returns, structs, methods, interfaces, enums, errors, defer, and C interop.
- So emphasizes simplicity, readability, and Go compatibility, with a focus on producing clean, efficient C code.
- Compatibility notes: So generates C11 code relying on GCC/Clang extensions and supports Linux, macOS, and Windows (partial). MSVC is not supported.
- Design decisions prioritize simplicity, no heap allocations in built-ins, fast C interop, readability, and Go compatibility, while avoiding raw performance optimization and full Go feature parity.
- FAQ addresses why So differs from TinyGo, memory handling (stack allocation by default, explicit heap allocation via stdlib), safety (limited safeguards), interoperability with C, stability (not production-ready), and the growing standard library.
- Final thoughts encourage trying So for hobby projects and highlight further reading and subscription for updates.