Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Misconceptions about loops in C. Parent comment
Modern compilers optimise this for you, exactly as you said.
Back in the 80s compilers didn't do this. There really was a difference between the machine code emitted for a naive loop and a tail call loop.
A lot of advice to rewrite naive loops to do tail calls is based on that 1980s compiler behaviour, not on the optimising 2020s compiler behaviour.
There are no comments on this comment yet.
Modern compilers optimise this for you, exactly as you said.
Back in the 80s compilers didn't do this. There really was a difference between the machine code emitted for a naive loop and a tail call loop.
A lot of advice to rewrite naive loops to do tail calls is based on that 1980s compiler behaviour, not on the optimising 2020s compiler behaviour.