Comment by phh
1 day ago
> > Tail recursion IME is a bigger foot gun
> This is true for some languages, but not all.
Useless anecdote that tail-recursive can be a foot gun even in Scala.
I did a (screening) job interview at Datadog, they asked for "give the spare change back on that amount of money" exercise (simple variant), "in whichever language you want". I did my implementation in tail-recursive Scala (with the annotation). I ended up trying to explain that tail-recursivity doesn't explode in memory for the rest of the call (and failed)
> I ended up trying to explain that tail-recursivity doesn't explode in memory for the rest of the call (and failed)
I count that as a successful interview – They sent an interviewer who doesn't understand how tail recursion enables tail call elimination, and is either unwilling or unable to listen when is is explained to them. Sounds like the company would be a bad fit for somebody whose go-to approach is to implement the solution that way.
I've always struggled with not seeing this as 'sour grapes' on my part when I think like this. No matter how many friends and peers tell me I dodged a bullet. Even with my experiences with ignoring red flags. Rejection still sucks.