dave bonner is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.

When i lern a new language i implement factorial in recursive just for fun.
But i just noticed something: in Python 3.5 64 bit, the biggest factorial i can calculate before maximum recursive length is 988!.

But in Pharo 5.0 32 bit i just calculated 100000! recursively.

That seems like a to big of a difference to be explained by efficiency of the code/language.

@turi looks like it's a purposeful guard to avoid stack overflows.

stackoverflow.com/a/3323013/11

@rascalking I bet the very conservative limit of ~1000 recursions is from a very early age of programming.
I will have to research what limits Pharo has in place.

dave bonner @rascalking

@turi i'd imagine it's more a matter of a failsafe...ensuring that you get an exception you can catch, handle, and log, rather than just letting the interpreter crash. 1000 is plenty for most programs, and if you need more than that, you can explicitly up the limit.

· Web · 0 · 1

@rascalking Yes i guess so.

Pharo on the other hand has NO limits at all. In fact, the standard implementation of factorial is recursively and faster than the iterative implementation.

Quite the difference in approach.

@turi yah. it sounds like pharo doesn't use a stack at all (at least it's execution model doesn't assume it?). neat.

stackoverflow.com/a/37119489/1