News for hackers. Stuff that matters.
Re:Dijkstra was right – recursion should not be difficult by Terr_ on Monday August 07, 2017 @07:06PM (#14952035)
> it's easier to take advantage of the fact that the programming language is already providing us a call stack

Exactly, I think this point is often overlooked, because folks get stuck thinking about the syntax of what they're writing rather than how it works under the hood.

Re:Dijkstra was right – recursion should not be difficult by SOLAR_FIELDS on Monday August 07, 2017 @08:25PM (#14952426)
It's nice unless your language has a limiting call stack. JVM languages are notorious for this. You can increase the size of course, if you have the right amount of machinery. Else it's time to explore tail call recursion and other "anti-unrolling" strategies.
Re:Dijkstra was right – recursion should not be difficult by joshlemer on Monday August 07, 2017 @09:04PM (#14952646)
Some languages on the jvm (namely scala) do have tail call recursion, meaning that in many cases recursion can use constant stack space
Re:Dijkstra was right – recursion should not be difficult by chii on Monday August 07, 2017 @09:14PM (#14952691)
I thought you had to manually mark the method (and/or the recur site) for scala to do tail call optimisations.
Re:Dijkstra was right – recursion should not be difficult by andrioni on Monday August 07, 2017 @09:24PM (#14952743)
It does the optimization by default, the annotation is to ensure it raises a compilation error if it actually fails to optimize.
Re:Dijkstra was right – recursion should not be difficult by lomnakkus on Wednesday August 09, 2017 @07:26AM (#14967492)
Indeed, and it should be noted that it's quite limited in when it can actually apply the optimization, i.e. self-recursion only (I believe).
Re:Dijkstra was right – recursion should not be difficult by Terr_ on Tuesday August 08, 2017 @12:13AM (#14954186)
I think a useful litmus test is to consider the worst-case depth of whatever you're building. I often feel safer writing my own userland stack, even for stuff like DFS in an interview.

You can't always know how much of the implementation stack will already be used by whatever calls your code, after all. It's a weird kind of "shared resource".

Re:Dijkstra was right – recursion should not be difficult by chii on Monday August 07, 2017 @09:16PM (#14952701)
Most languages don't limit stack size at the language level, but at the impl. This is true for Java and for C++.