Comment by openuntil3am
13 hours ago
Closures are a complicated mess. Functional programming languages hide the mess with garbage collection.
13 hours ago
Closures are a complicated mess. Functional programming languages hide the mess with garbage collection.
Machine code and LLVM are complicated messes. Higher-level language hide a lot, but sometimes issues pop up, even in Rust e.g. inline heuristics (https://nnethercote.github.io/perf-book/inlining.html).
This isn't the right framing IMO. Closures actually aren't complicated with GC for the same reason structs with references aren't complicated, at least as far as the programmer is concerned. You could say functional languages "hide the mess" there too, but even if you take that perspective, it's nothing to do with closures in particular. Closures are just one of the things that need memory, and memory management is tricky without GC.