In ScalaMono.scala:
Then,
Edit: Weak Mono/JVM comparison removed.
Update: wks asked me to try calculating some larger Fibonaccis to normalize runtime startup cost when comparing Mono to JVM performance:
Mono: 0.42s total
JVM (IcedTea6 1.8): 84.45s total
Go, Mono, go!
15 comments
Would you try “until 20″ or more and time it again? I know JVM is slow on start.
None of the code shows up in an RSS feed (at least, not the feed from Planet Ubuntu). I don’t know if there’s anything that you can do about this, but I thought I’d let you know.
wks, there you have it :)
mpiroc, thanks for the heads up. I’ll see what I can do.
Try a different JVM:
$ time scala Fib
14930352
real 0m1.504s
user 0m1.670s
sys 0m0.190s
$ scala -version
Scala code runner version 2.8.0.RC1 — Copyright 2002-2010, LAMP/EPFL
$ java -version
java version “1.6.0_17″
Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)
This is on a kind-of-old 2.2GHz Core 2 Duo Macbook.
But it’s great to see working Scala code running on Mono. Was it hard to make work?
I had no idea that there was a Scala for .NET until now.
I would advise those guys to use System.Reflection.Emit as a codegen engine.
Erik, thanks for pointing out a better JVM. If I write an app with Scala on HotSpot, can I distribute it freely (e.g. with Debian)?
It was fairly straightforward to get Scala up and running on Mono, but it could be easier. I really think Scala+Mono(+MonoDevelop) is a Killer App.
Is Scala on .NET being continued? This
page http://www.scala-lang.org/node/168 mentions Scala 1.4 but the current version of Scala is 2.7.7 / 2.8.0 RC2.
Bishop, I sure hope it is! It has so much potential.
I was using Scala 2.7.7 as far as I know.
David – Yes. First, you don’t write the app with HotSpot, you run it with HotSpot. The VM executes the bytecodes put out by the Scala compiler. Second, Sun’s JVMs have been available for free download for as long as I can remember. Third, for quite a while now, the JVM has been open source under the GPL with the classpath exception.
You could also try native compilation of the bytecodes with gcj. I don’t think anyone’s tried that with Scala recently. I think the last time it didn’t work so well.
Regarding continued development of Scala on .NET, IIRC Microsoft is currently funding some work at EPFL on that.
Erik, thanks for clarifying. I wonder why I didn’t have a better performing JVM in the first place. If I get more involved with Scala, maybe I can bring this up at the next Ubuntu Developer Summit.
Doesn’t `scala scalaMono` compiles the files before running it? It could explain the big differnece in start up time.
Use something like this next time http://www.pastebin.fi/?N2YwZW
Elazar, no I compiled the .scala files first and ran scala on the main class file.
I got it now!
No HotSpot for scala applications extending the Application trait. See http://suereth.blogspot.com/2009/08/avoid-applicaiton-trait-in-scala.html Why don’t you try it with `def main` instead?
Remove ‘extends Application’, add a main method around println. The difference between no HotSpot and HotSpot:
ScalaMono: 53.766s
ScalaMonoMain: 0.554s
Ouch!