News for hackers. Stuff that matters.
Re:Applying NASA coding standards to JavaScript by jacquesm on Thursday January 08, 2015 @01:27PM (#8857925)
You nailed it. Tail calls have constant memory footprints, non-tail-call recursion (assuming the language runtime and/or compiler are able to recognize these situations and convert the tailcall into an adjustment of the variables in scope in the current stack frame followed by a jump).

If we'd be worried about our ability to analyze these then we wouldn't be able to optimize away that special case to begin with.

I do find that to my imperatively trained eyes it always screams 'stack overflow' at me and then I have to remind myself that will be optimized away.

It'd be nice if environments that provide tail call optimizations could be set to fail compilation if any non-tail-call recursion is detected.

Re:Applying NASA coding standards to JavaScript by DannyBee on Thursday January 08, 2015 @01:54PM (#8858114)
"If we'd be worried about our ability to analyze these then we wouldn't be able to optimize away that special case to begin with. "

Most compilers require you tell them, specifically, that it can tail call everything, before it will do it (i'm talking more about GCC and LLVM here, which are generic compiler frameworks). It will do some tail call optimization, but only fairly basic cases, exactly because it can't analyze what will happen.