Hacker News new | ask | show | jobs
by josephg 31 days ago
Right; because in zig the default behaviour is to leak memory. Rust adds an invisible free() call. Leaking is something you have to do explicitly.

I understand zig's philosophy here. But I prefer rust's default behaviour.

2 comments

Zig fails unit tests if there's a memory leak in those tests.
yeah, IMO generally explicit is better. It's hard to take something implicit and increase the visibility (I'm aware there are tools to show you lifetimes in rust). But another option is to statically analyze the code (or the IR) and have something else check that you aren't leaking.