Skip to content

Comment on Curious C++ Lambda Examples: Recursion, constexpr, Containers C++23 includedparent

Comments

For my job involving C++, it doesn't matter which is faster. Just doing whatever is more readable, and since I'm usually doing a DFS/BFS func, it's nice being able to easily toggle that by popping from front vs back. When I'm not, I'd rather have a readable stack trace if something goes wrong and not have to deal with the oddities of recursive lambdas.

In Python, the issue is the easily reachable max recursion depth. Tail recursion isn't optimized.

In Erlang, you use recursion even just to iterate through a list. It's fine, the language is made for that.

My comment was in response to your 'better performance' point. I agree with your other points of course.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.