|
|
|
|
|
by gnull
15 days ago
|
|
> So is for Go developers who want systems-level control without learning a new language. And for C programmers who like Go's safety, structure, and tooling. Wut? Also, how do you preserve garbage collector semantics without garbage collector? |
|
- Everything in the language is statically allocated or stack-allocated. You have to call a malloc / free function to get heap allocated things
- The language is not memory safe (you can't return slices, pointers, or interface types from a function if the thing was created inside the function, unless you used heap allocation)
- Interfaces (the only variable size struct Go has) are implemented by creating a struct of function pointers. Arrays and maps (the non-struct variable size types) are implemented as stack-only and maps are limited to 1024 keys. You can opt into heap-based arrays / maps in the standard library to bypass this.