Allocation Efficiency in High-Performance Go Services
segment.com
segment.com
Anyway, the choice of Rust vs Go should not be based on a single factor like "Rust is not garbage collected". Especially since many common coding patterns require some form of garbage collection, even in Rust!
What Go lacks is the ability to explicit state that a value must live in the stack, leaving it implicit and open to escapes.
Using the first example in D, x will definitely be stack allocated.
import std.stdio;
void main()
{
auto x = 42;
writeln(x);
}Would that be a recipe for a "segfault"? Do all these languages allow segfaults to happen?
MODULE Crash;
IMPORT SYSTEM;
VAR
source: LONGINT;
sourceAddress: INTEGER
source2: LONGINT;
BEGIN
source := 23;
sourceAddress := SYSTEM.ADR(source);
SYSTEM.GET(sourceAddress, source2);
(* .... *)
END Crash.
The issue is that any module that imports SYSTEM is considered unsafe by the compiler.However in some of those languages those type of assignments are only allowed in unsafe code, for example in Modula-3 you can only do that in an unsafe module package and the target variable has to be declared as UNTRACED REF.
https://golang.org/cmd/compile/#hdr-Compiler_Directives
Does that actually work?