The Solod project develops a subset of the Go language, translated into the C language.

The programming language Solod (So) has been introduced, providing a subset of the Go language that is transpiled into a representation in the C language (C11), suitable for compilation by GCC, Clang, and zig cc. A key difference of Solod from Go and Tinygo is the use of manual memory management, operating without a garbage collector, automatic memory allocation, and reference counting. The transpiler for Solod is written in Go and is licensed under the BSD license. It supports operation in Linux, macOS, and Windows.

The language supports structures, methods, interfaces, slices, returning multiple values from functions (for example, result + error code), generics, and deferred calls. To simplify, the language does not support channels, coroutines, or closures. During development in Solod, existing LSP servers, linters, integrated development environments, and code editors that support Go can be utilized, as well as the 'go test' toolkit.

Code written in Solod can integrate with applications in the C language (C can call functions in Solod and vice versa) and does not require attaching a runtime. Key application areas include system programming with capabilities close to C, but with Go-style syntax and type checking. Solod can also be used to port Go libraries for use in C projects. Go packages like strings, io, bytes, mem, slices, etc., have been ported to C. In addition to the set of ported Go libraries, programs written in Solod can use wrappers over the standard C library libc.

By default, all memory is allocated on the stack, but through the Alloc / Free functions of the standard library, memory can be allocated on the heap. Garbage collection and reference counting are not used, but Solod provides mechanisms for type checking and emergency termination when accessing out-of-bounds arrays. However, checks for dangling pointers and failure to free memory are not performed. The primary method of identifying memory issues is the use of AddressSanitizer (-fsanitize=address) in modern compilers.

In terms of performance, programs compiled in Solod are generally faster than those written in Go. For instance, the performance of functions from the Byte package is one and a half times faster with identical memory consumption. Working with byte buffers is 1.3 times faster for reading and 2-4 times faster for writing. In the Map package, fetching by integer keys is 3.4 times faster, though modifying keys is slower by 1.6 times. Fetching by string keys is on par with Go, but modification is slower by 1.5 times. Parsing and formatting integers are twice as fast, while floating-point operations are faster by 1.5/1.2 times. String functions are 1.3 times faster, and string creation is 2-4 times faster with a 10-20% reduction in memory consumption.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster