Hacker News new | ask | show | jobs
by dragonwriter 4813 days ago
> Sure, recursion is possible in Java, but it's rarely used because of the inevitability of hitting a StackOverflowError given a sufficiently large value of n.

That's a good reason for not using recursive algorithms in production Java code, but it doesn't make Java unsuitable for teaching CS including recursion (Python, which IMO is a much better general purpose teaching language than Java, faces the same problem; plenty of intro CS classes that cover recursion well use Python.)

> Teaching recursion doesn't make a whole lot of sense unless you're using a functional language where loop iteration is not the paradigm.

It makes perfect sense independently of what is idiomatic in the language: teaching CS using a language isn't teaching the idioms of the language. Teaching iteration and recursion in the same language is useful, particularly because doing so is useful in underlining that recursion and iteration are different approaches for the same problems, even though in most languages one of the two options will tend to be more idiomatic.