4 ms·
Most of it is supported in Scala, without much problems.
by soc88 15y ago
Most of it is supported in Scala, without much problems.
- rbehrends 15y agoScala's compiler has to jump through quite a few hoops to get it done (e.g., trampolines for some forms of tail recursion). It also can't fix the overhead issues involved with, say, complex numbers (which may or may not get fixed in the future [1]). Try to do a simple Gaussian elimination on a 1000x1000 matrix of complex numbers, for example. The indirections and per-object overhead are bad for your processor cache. [1] https://blogs.oracle.com/jrose/entry/value_types_in_the_vm https://blogs.oracle.com/jrose/entry/value_types_in_the_vm
- soc88 15y agoThat's why I said: > Most of it is supported in Scala scalac does not use trampolining. It rewrites tail-recurisve calls into “loops” (or jumps if you look at the bytecode). This is a case where the JVM lacks the necessary feature. There are experiments with value classes in Scala, which might allow you to use arrays of primitive numbers for them, but currently it looks like it won't happen for 2.10 because it can't be made work good enough in some corner cases like reflection, toString, equality, ...
- rbehrends 15y agoNo, Scala cannot optimize all forms of tail recursion (such as mutually tail-recursive functions). In that case, you have to use scala.util.control.TailCalls to do it via trampolines. The proposed value classes in Scala do not solve the overhead problem for complex numbers. As specified in SIP-15, they have exactly one field, and basically are designed to give you information hiding for classes with a single field without boxing overhead. Edit: By the way, you don't have to sell me on Scala. I have been using it since 1.x (I have forgotten the exact version number).
- soc88 15y agoSorry, if I appeared as I tried to sell you something. > No, Scala cannot optimize all forms of tail recursion (such as mutually tail-recursive functions). In that case, you have to use scala.util.control.TailCalls to do it via trampolines. I guess we are just nick-picking each other here. :-) I think be both understand what the compiler can do, cannot do, what it does automatically and what not. Have you seen the Complex implementation which uses an underlying Long as Floats? (Sounds ugly but seems to work quite nicely.) The biggest problem at the moment is putting value types in an array. Currently it seems like some ugly clutch/work-around ill be used. I hope SIP-15 gets either rejected or delayed until there is a better solution, Because the difference between an array of references and an array of primitives really matters imho.