News for hackers. Stuff that matters.
Re:Rust will likely not support tail call optimization by derleth on Wednesday April 10, 2013 @08:19PM (#5529115)
> The JVM doesn't have an equivalent instruction; you can only jump around inside a single method, not to the beginning of another method.

OK, why do functions in the source language have to translate directly into methods at the JVM level? Purely for debugging?

Re:Rust will likely not support tail call optimization by kragen on Wednesday April 10, 2013 @08:50PM (#5529214)
The JVM also doesn't (I'm fairly sure) have an indirect JMP instruction, which means you can't compile a polymorphic source-language method call into a JMP inside of a single generated method. Instead you have to use a call to a method. That means that tail-calls to functions passed as parameters (rather than functions that can be statically bound at compile time) can't use JMP.
Re:Rust will likely not support tail call optimization by happy_dino on Thursday April 11, 2013 @06:11AM (#5530961)
The “JVM” can use any instruction it wants to use.

If you want a runtime with proper tail calls, use a implementation which supports it.

Re:Rust will likely not support tail call optimization by kragen on Thursday April 11, 2013 @03:30PM (#5534203)
I'm talking about the bytecode instructions standardized in the "JVM" specification. The "JVM" has to implement the semantics of the instructions found in your bytecode program, or your program won't run. Your bytecode program can only use bytecodes defined in the "JVM" specification, or it won't run on the "JVM".
Re:Rust will likely not support tail call optimization by happy_dino on Thursday April 11, 2013 @08:03PM (#5535705)
There is no need or reason to change or add any bytecode instructions to support proper tail calls.

Take standard class files and execute them on a runtime with proper tail calls. Done. Works.

Re:Rust will likely not support tail call optimization by kragen on Friday April 12, 2013 @06:35AM (#5537670)
Which JVMs support proper tail calls? Doesn't this violate requirements of the JRE?
Re:Rust will likely not support tail call optimization by happy_dino on Friday April 12, 2013 @07:01AM (#5537755)
For instance oss.readytalk.com/avian. Why should it?
Re:Rust will likely not support tail call optimization by kragen on Friday April 12, 2013 @08:32AM (#5538057)
Because the security manager needs to be able to introspect the stack. Avian isn't a JVM; it's "designed to provide a useful subset of Java's features" and can run some Java code.
Re:Rust will likely not support tail call optimization by abecedarius on Monday April 15, 2013 @01:16AM (#5549887)
It's actually possible to implement the stack inspection in a tail-call-friendly way (along the lines of Racket's continuation marks IIRC), though AFAIK nobody does it.
Re:Rust will likely not support tail call optimization by happy_dino on Friday April 12, 2013 @08:40AM (#5538079)
> Because the security manager needs to be able to introspect the stack.

Not allowing certain “optimizations” in security-sensitive contexts is perfectly fine. In fact, this is exactly what Avian, the CLR (and pretty much everyone else) is doing.

> Avian isn't a JVM; it's "designed to provide a useful subset of Java's features" and can run some Java code.

Now you're talking about legal aspects. Frankly, I'm not interested in discussing those.

Avian is a JVM for all practical purposes. If you disagree, please provide a test-case which runs on HotSpot but not on Avian.

Re:Rust will likely not support tail call optimization by tomku on Wednesday April 10, 2013 @09:19PM (#5529339)
JVM interop. You can't call a Scala function from Java unless it's somehow addressable as a Java method, so Scala implements functions in terms of Java methods. The JVM, for better or worse, is largely built around Java's object model - you can do your own weird stuff, but you won't easily be able to interop with Java code or benefit from HotSpot's optimizations.
Re:Rust will likely not support tail call optimization by kragen on Wednesday April 10, 2013 @11:53PM (#5529896)
For better or worse, Scala does do quite a bit of work to go beyond Java's object model.