Porting Go's strings package to C (antonz.org)
The post describes how Anton Zhiyanov ported Go’s core bytes and strings implementations to C as part of a broader Go-into-C subset project. It covers translating supporting packages like math/bits and unicode/utf8, handling cases like Go vs C operator precedence, and implementing non-allocating operations by reinterpreting byte slices as strings and using libc functions such as memcmp. For allocating APIs like Repeat and Builder/Buffer types, it introduces an explicit allocator interface (with a system-allocator default) and uses it to make allocations visible and controllable, then notes benchmarking against the original Go behavior.
April 05, 2026 11:55
Source: Hacker News