← Back to context

Comment by Animats

11 hours ago

Did Python ever get tail recursion? There was a big controversy years ago. Guido didn't like it. But apparently something went in.

Enthusiasm for tail recursion comes mostly from LISP and LISP-adjacent people - those who learned to program from SICP.[1] This is neither good nor bad. Even MIT doesn't use SICP any more, though.

(The classic 20th century "programming should be hard and programmers should suffer" books:

- Structure and Interpretation of Computer Programs, Abelson and Sussman.

- Fundamental Algorithms and Semi-Numerical Algorithms, Knuth.

- Algorithms + Data Structures = Programs, Wirth.

- A discipline of programming, Dijkstra.

These are mostly of historical interest now, but at one time, knowing those defined a real computer scientist. Today, it's more important that your LLM has been trained on them.)

"Love the lambda." - footer of original article.

[1] https://archive.org/details/Sicp.2nd

Python still doesn't have tail recursion, and uses a small stack by default.

I'll note that in modern imperative languages is harder than it looks to figure out if calls are really in tail position, things like exception handling, destructors etc. interfere with this, so even as a SICP fanboy I'll admit it's fair enough that some languages don't want to bother.

  • > and uses a small stack by default.

    It does not, it sets low recursion limit which is a rather different thing.

> Did Python ever get tail recursion? There was a big controversy years ago. Guido didn't like it. But apparently something went in.

No. The only thing that went in is moving Python frames off of the C stack, but since afaik the recursion limit did not change it has essentially no impact on user code unless you play with said recursion limit.