I like Rich Hickey's short summary from the lambda-the-ultimate mailing list:

"Of course it's possible to do TCO on the JVM, providing one is
willing to superimpose some language-specific
trampoline/CPS/heap-based-stack/interpretive/etc mechanism on top of
the native calling mechanism of the JVM. This may involve tradeoffs
with performance and/or interoperability."

So, it is all about the JVM providing some support so that every
language doesn't have to implement these tricks on their own in their
own way. Because the JVM doesn't have some kind of story for this
functionality, people tend to over-react with statements like:

"Hence there is a very strong argument that Scala is not a real
functional programming language: these languages have regarded tail
calls as an essential feature since Scheme was first introduced over
two decades ago."

"Clojure shares with Java a lack of TCO."

"Erlang doesn't fit the JVM [... because ...] The JVM lacks tail
recursion. See previous point [about lack of Closures] and multiply
the impact by 1000. Erlang uses tail recursion all the time. Halfway
measures, like Clojure’s recur keyword, will not suffice."

Now these quotes are starting to get dated and should be read in
context but even some small progress in this area would takes us
forward enormously. Otherwise, it is arguably a bad idea to use a
functional style (together with the JVM) in production scenarios.

Some interesting background links:
http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html
http://blogs.sun.com/jrose/entry/tail_calls_in_the_vm
http://debasishg.blogspot.com/2006/03/non-java-languages-on-jvm.html

Cheers, Paul.

On Wed, Jun 17, 2009 at 1:11 PM, Joshua Marinacci <[email protected]> wrote:
>
> I guess I always thought tail recursion was a compile time trick, not 
> something to be done in the JVM. Is it that people want tail recursion added 
> to the Java language?
> On Jun 16, 2009, at 8:03 PM, Michael Kimsal wrote:
>
> My understanding is people want this in the JVM so that it's standardized, 
> and worked on by core people.  I may be misinterpreting the call for it, but 
> I take it as similar to the 'invokeDynamic' stuff that is coming up in Java.  
> That same sort of behaviour is being attempted in things like Groovy 
> already.  If it's a standardized part of the core JVM, then everyone can stop 
> working on their own implementations and share in the continued development 
> that those features can enjoy because they are centralized.
>
> Anyone with more insight on why TCR should be in the core JVM itself and not 
> in external projects?
>
>
> On Tue, Jun 16, 2009 at 10:57 PM, Joshua Marinacci <[email protected]> wrote:
>>
>> Is there a reason why this needs to be added to the JVM? Couldn't functional 
>> languages on the JVM implement it in their own compiler (Scala, Lisp, 
>> Scheme, etc.)
>> -j
>> On Jun 16, 2009, at 5:53 PM, Paul King wrote:
>>
>> If you want to apply a functional style to your programming, even relatively 
>> simple algorithms
>> which intuitively shouldn't require many resources bomb out early without 
>> tail call optimizations.
>> It isn't the end of the world but you have to choose less 
>> expressive/declarative solutions to
>> your problems which as well as being less elegant are much harder to 
>> understand/maintain.
>> Cheers, Paul.
>>
>> On Wed, Jun 17, 2009 at 8:20 AM, Joshua Marinacci <[email protected]> wrote:
>>>
>>> Okay.. seriously dudes! I've been hearing this request over and over. Of 
>>> all of the things missing from the Java platform (and they are many, 
>>> believe me), why is *tail recursion* the make or break feature for the 
>>> future of the Java platform? Seriously?! Tail Recursion?!  Not fixing 
>>> applets or modularity or starting up 18 times faster, but tail recursion!? 
>>> WTH!
>>
>>
>>
>>
>>
>>
>>
>
>
>
> --
> Michael Kimsal
> http://jsmag.com - for javascript developers
> http://groovymag.com - for groovy developers
> 919.827.4724
>
>
>
>
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to