Hacker News new | ask | show | jobs
by Jtsummers 1261 days ago
Python doesn't offer tail call optimization, which makes it a poor fit for a lot of the instruction you'd want to provide on recursion. Especially paired with its default recursion limit (1000?) which means you can't run to any interesting depths anyways, tail recursion or not.

Besides, if you're studying CS at a halfway decent school you'll learn a half dozen languages before graduating anyways (if not more), what's one more to you?

2 comments

Teaching recursion doesn't mean teaching to do everything with recursion, though. Normally with a language like Python (or, back in my school days, Pascal), you learn stuff like loops first. Recursion is demonstrated on use cases that are not easily done by a loop - e.g. drawing a snowflake.
I was actually not doing a CS major so I would have prefered learning Python. Ended up learning it on my own, so much more useful as a language.

Also, we did not even learn tail call optimization :) so while the argument is valid (I guess it's easier to learn scheme than erlang, ocaml, etc.) it wasn't in my case.

If they were teaching you recursion with Scheme and didn't teach you about tail calls and tail recursion, then you got cheated. That's usually the second thing you learn about recursion in Scheme after learning how to make recursive calls. It's essential to actually making efficient recursive routines in Scheme.