logoalt Hacker News

flipgimblelast Sunday at 6:14 PM1 replyview on HN

Because to use lambdas you're asking the language to make implicit heap allocations for captured variables. Zig has a policy that all allocation and control flow are explicit and visible in the code, which you call re-inventing the wheel.

Lambdas are great for convenience and productivity. Eventually they can lead to memory cycles and leaks. The side-effect is that software starts to consume gigabytes of memory and many seconds for a task that should take a tiny fraction of that. Then developers either call someone who understands memory management and profiling, or their competition writes a better version of that software that is unimaginably faster. ex. https://filepilot.tech/


Replies

do_not_redeemlast Sunday at 6:24 PM

Nothing about lambdas requires heap allocation. See also: C++, Rust

show 1 reply