Hacker News new | ask | show | jobs
by tlb 1460 days ago
I ran out of JS stack, walking the dependency graph of a big computation. Dependency graphs can be very deep relative to their overall size. It was a big pain to rewrite with an explicit stack of to-be-visited nodes.

TCO wouldn't have saved me, though. It just needs a big stack. Node defaults to just under 1 MB, which doesn't go very far.

2 comments

That's interesting and quite valid, haven't thought of this. And I agree, recursion is often more intuitive and concise for these things.
Rewriting a recursive function into a for-loop can be mind boggling, but you often end up with more simple code.