News for hackers. Stuff that matters.
Re:HLVM -- the High-Level Virtual Machine by cabalamat on Tuesday February 16, 2010 @05:10PM (#1130060)
> Clojure has run into a lot of problems due to the JVM, probably the most famous one being the lack of tail call optimization.

What in particular about the JVM prevents Clojure from being able to do tail-call optimization? My (admittedly naive) understanding of TCO is that it involves turning tail recusion into a loop, and Java can certainly handle loops OK.

Re:HLVM -- the High-Level Virtual Machine by crux_ on Tuesday February 16, 2010 @05:51PM (#1130173)
> My (admittedly naive) understanding of TCO is that it involves turning tail recursion into a loop

This is close, but not the full story.

TCO turns tail recursion into a GOTO (well, a goto-with-arguments). In the case of a single function which tail-calls itself, this becomes a loop, but for multiple functions that are mutually recursive, that's not the case.

Note that the issues with the lack of TCO boil down to efficiency: there are ways of faking TCO atop a runtime that does not support it (meaning deeply tail-recursive code will run, rather than overflow the stack), but they come at with a runtime cost.

Re:HLVM -- the High-Level Virtual Machine by WilliamLP on Tuesday February 16, 2010 @05:50PM (#1130170)
I'm naive too, but apparently there are use cases for TCO for state machines where the tail calls are between various functions, not necessarily in a simple loop.