tag:blogger.com,1999:blog-5819005.post105676046631802602..comments2024-03-16T02:17:55.433-07:00Comments on Programming and politics: JavaOne Talk: Performance Comparisons of Dynamic Languages on the Java Virtual MachineAnonymoushttp://www.blogger.com/profile/08698131967747444207noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-5819005.post-26985654165010913552011-07-22T07:40:24.035-07:002011-07-22T07:40:24.035-07:00Putting on a conference like JavaOne is no small t...Putting on a conference like JavaOne is no small task. The centerpiece of the conference is, of course, the technical sessions, and numerous reviewers spend a great deal of time combing through the proposals. This year, we had over 1300 proposals -- more than five times as many proposals as we had slots!Generic Viagrahttp://www.iservepharmacy.com/noreply@blogger.comtag:blogger.com,1999:blog-5819005.post-79038475368791030222009-06-29T13:27:54.265-07:002009-06-29T13:27:54.265-07:00I saw some serious problems with the algorithms us...I saw some serious problems with the algorithms used. The first Scala one was unrecognizable as a Scala program -- this is the first time I actually saw "while" being used in Scala outside a "while(true)" loop.<br /><br />On the second algorithm I note that Fan uses compareIgnoreCase, which is also available at the very least to Java, but in Java (and some others), it is used a .toLowerCase instead. This causes repeated creation of new strings, while compareIgnoreCase doesn't, saving quite some time.<br /><br />Scala's second algorithm not only suffers for the same reason, but doesn't even make use of BufferedSource instead of Source, so as to be more directly comparable to Java. Also, the File definition is useless, and the whole algorithm is a bit suspicious, though I don't know how much difference in performace could be had. Anyway, flatMap should have been used instead of foreach, the assignment to words dropped, sort appended after flatMap, and the whole thing used as initializer for words. A convertion to projection might be indicated after getLines, but I don't think so.<br /><br />Converting to List should probably only be done after sort -- split will return an array, which I suspect will have better sorting performance, and split already return arrays.<br /><br />These are nits, though. The toLowerCase vs compareIgnoreCase issue isn't.Danielhttps://www.blogger.com/profile/07505997833685327219noreply@blogger.comtag:blogger.com,1999:blog-5819005.post-12863602545734093042009-06-29T07:48:48.938-07:002009-06-29T07:48:48.938-07:00You could make the Scala example far more concise ...You could make the Scala example far more concise (if you use recursion):<br /><br />def primes(n: Int): List[Int] = {<br /> def nomults(s: Int, xs: Seq[Int]): List[Int] = (for (x <- xs if x % s != 0) yield x).toList<br /> def sieve(xs: List[Int]): List[Int] = {<br /> if (xs.isEmpty) xs<br /> else {<br /> val p = xs.first<br /> val nxs = nomults(p, xs drop 1)<br /> p :: sieve(nxs)<br /> }<br /> }<br /><br /> val odds = nomults(2, 2 to n)<br /> 2 :: sieve(odds)<br />}<br /><br />println( primes(100) )<br /><br /><br /><br />And even that's not as concise as possible. As the code above will get screwed up, you can view it <a href="http://froth-and-java.blogspot.com/2009/06/sieve-of-eratosthenes.html" rel="nofollow">here</a>.Anonymoushttps://www.blogger.com/profile/01366131922305820386noreply@blogger.comtag:blogger.com,1999:blog-5819005.post-39195049452002092332009-06-05T17:10:15.360-07:002009-06-05T17:10:15.360-07:00Good question Matthew. The JVM used was HotSpot 1....Good question Matthew. The JVM used was HotSpot 1.6.0_14, 64-bit for Windows. The 64-bit JVMs are server JVMs only, no client mode. Each test ran with 2 GB of heap, to minimize (eliminate) any garbage collections. Also, each test had a "warm-up" as well, where the same computation that was done in the main algorithm was executed in a loop to induce JIT. However, Charlie pointed out that on the word sort, I probably did not run a long enough loop on the warm up, as is evidenced by the humps at the beginning of the graphs.Anonymoushttps://www.blogger.com/profile/08698131967747444207noreply@blogger.comtag:blogger.com,1999:blog-5819005.post-26345406844984608762009-06-05T16:24:43.444-07:002009-06-05T16:24:43.444-07:00Interesting stuff.
Just out of curiosity, what JI...Interesting stuff.<br /><br />Just out of curiosity, what JIT mode did you use to run these performance profiles (i.e. server, client, interpreted)?Matthew Hallhttps://www.blogger.com/profile/15193859932143053469noreply@blogger.com