<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-24248206.post4474110263473978366..comments</id><updated>2012-01-04T16:59:28.181+01:00</updated><category term='parser generator'/><category term='case study'/><category term='DSLs'/><category term='helios'/><category term='slides'/><category term='left factoring'/><category term='javascript'/><category term='nordic coding'/><category term='domain-specific languages'/><category term='kotlin'/><category term='jdt'/><category term='autosar'/><category term='conference'/><category term='Java multi-line strings'/><category term='xpand'/><category term='scoping'/><category term='extension methods'/><category term='CG2011'/><category term='Galileo'/><category term='itemis'/><category term='UML modeling brumm brumm'/><category term='GSoC'/><category term='Languages'/><category term='git'/><category term='eclipse modeling itemis'/><category term='DSL'/><category term='DSL code generation eclipse xtext slides'/><category term='xtext'/><category term='eclipse'/><category term='Eclipse EclipseCon Modeling Xtext'/><category term='Guice'/><category term='code generation'/><category term='presentations'/><category term='language design'/><category term='builder API'/><category term='guicecon'/><category term='emf index'/><category term='JVM'/><category term='scala'/><category term='OSGi'/><category term='eclipsecon'/><category term='java'/><category term='democamps'/><category term='refactoring'/><category term='english'/><category term='webinar'/><category term='Java testing performance'/><category term='example'/><category term='protocol buffers'/><category term='left recursion'/><category term='jax 2010'/><category term='website'/><category term='lambda'/><category term='fowler'/><category term='api design'/><category term='packrat'/><category term='java.scala'/><category term='oaw eclipse xtext'/><category term='android'/><category term='expressions'/><category term='MDSD'/><category term='xtend'/><category term='groovy'/><category term='eclipse summit'/><category term='index'/><category term='xbase'/><category term='modeling'/><category term='kiel'/><category term='release'/><category term='automotive'/><category term='http://www.blogger.com/img/gl.link.gif'/><category term='xtend 2'/><category term='internal DSLs'/><category term='oAW'/><category term='codegeneration'/><category term='OpenJDK'/><title type='text'>Comments on Sven Efftinge's Blog: Groovy, Scala, Java, Xtend - a stupid comparison</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.efftinge.de/feeds/4474110263473978366/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html'/><author><name>Sven Efftinge</name><uri>http://www.blogger.com/profile/11751196715155150517</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_Ii_da0jTxAY/SNxsRY6r26I/AAAAAAAAABk/WzYcCAnzC9Q/S220/foto-openbc.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-24248206.post-8747489510329037988</id><published>2012-01-04T16:59:28.181+01:00</published><updated>2012-01-04T16:59:28.181+01:00</updated><title type='text'>Indeed, if you change &amp;quot;+=&amp;quot; to &amp;quot;&amp;lt;...</title><content type='html'>Indeed, if you change &amp;quot;+=&amp;quot; to &amp;quot;&amp;lt;&amp;lt;&amp;quot; in the Groovy version you get 256ms, @8X better performance than the rigged, errr, supplied benchmark ;-)&lt;br /&gt;&lt;br /&gt;Still, slower than the statically typed versions, but then again, Groovy&amp;#39;s mandate to-date has not been to provide raw number crunching power. The right tool for the right job.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/8747489510329037988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/8747489510329037988'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html?showComment=1325692768181#c8747489510329037988' title=''/><author><name>virtualeyes</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1553676912'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-3390804640465232926</id><published>2011-12-21T10:48:28.737+01:00</published><updated>2011-12-21T10:48:28.737+01:00</updated><title type='text'>@all: Thanks for the feedback. I incorporated it a...</title><content type='html'>@all: Thanks for the feedback. I incorporated it and wrote an update post : http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-updated-stupid.html</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/3390804640465232926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/3390804640465232926'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html?showComment=1324460908737#c3390804640465232926' title=''/><author><name>Sven Efftinge</name><uri>http://www.blogger.com/profile/11751196715155150517</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_Ii_da0jTxAY/SNxsRY6r26I/AAAAAAAAABk/WzYcCAnzC9Q/S220/foto-openbc.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1100628811'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-917609833070775784</id><published>2011-12-21T01:23:43.173+01:00</published><updated>2011-12-21T01:23:43.173+01:00</updated><title type='text'>Your Java version wouldn&amp;#39;t compile for me: &amp;qu...</title><content type='html'>Your Java version wouldn&amp;#39;t compile for me: &amp;quot;y&amp;quot; needs to be an Object, not a Comparable.&lt;br /&gt;&lt;br /&gt;Also You could write the Java version 3 lines shorter if you use Arrays.asList(new Object[] { &amp;quot;foo&amp;quot;, 23, true } as a poor man&amp;#39;s List literal. Java isn&amp;#39;t always as verbose as everybody is claiming ;-)&lt;br /&gt;&lt;br /&gt;10000 iterations are probably not enough for a comparison: If I go from 10k to 100k iterations, the Scala version needs 5x time -- the Java version only 2x.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/917609833070775784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/917609833070775784'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html?showComment=1324427023173#c917609833070775784' title=''/><author><name>Henning</name><uri>http://www.blogger.com/profile/03987292593686204383</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-459848060'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-4878093365601898250</id><published>2011-12-21T01:07:25.667+01:00</published><updated>2011-12-21T01:07:25.667+01:00</updated><title type='text'></title><content type='html'>This comment has been removed by the author.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/4878093365601898250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/4878093365601898250'/><author><name>Henning</name><uri>http://www.blogger.com/profile/03987292593686204383</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.contentRemoved' value='true'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-459848060'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-714482153377410531</id><published>2011-12-21T00:40:45.659+01:00</published><updated>2011-12-21T00:40:45.659+01:00</updated><title type='text'>Sven, you found an example in which Groovy cannot ...</title><content type='html'>Sven, you found an example in which Groovy cannot do different than look bad. Groovy uses a fair amount of caching to get method invocations fast, but your code makes this caching not work at all. So your test there makes no argument about dynamic dispatch in general, just for a case, in which Java would look also very bad, if you would reproduce it there. The thing is only you cannot easily do that. In Java the method is preselected during compilation, the maximum you can get there is that you produce a scenario in which Java has to interpret.&lt;br /&gt;&lt;br /&gt;As for the Groovy program, there are some things that you could use to make it faster, but there is a big conceptual difference between the Groovy program and the others. In the Java version you make a foo(Object) method and in there check by instanceof. That means you will get only one method. In Groovy those methods are all existing and there exists no dispatcher method. &lt;br /&gt;&lt;br /&gt;Imagine a class with those three foo methods written in Java. Then in Groovy you can still run your test. I dare to say that in Xtend you cannot make this work without a dispatcher method somewhere  - and your dispatch keyword is implying that - thus I assume you cannot make this then work using a Java class.&lt;br /&gt;&lt;br /&gt;But let us not stop here... let us assume that you write the base class in Java, where it knows foo(String) foo(Object) and foo(Boolean). Using this class the Integer variant would call the foo(Object) method in your code. Now extend that class in Java with a foo(Integer) method and Groovy would no longer call foo(Object) but foo(Integer).  &lt;br /&gt;&lt;br /&gt;I doubt you can easily simulate that case.&lt;br /&gt;&lt;br /&gt;Anyway.. coming back to your test. The call site caching in Groovy works by assuming that the parameter types do not change in most cases. In your case they change on each call, thus part of the performance problem. &lt;br /&gt;&lt;br /&gt;In the Java case you are not testing method call performance at all, instead you test the performance of ArrayList#add. And the list operation dominates the Groovy program as well, since the Groovy program uses +=, which does create a new list each time. If you change it to &amp;lt;&amp;lt;, then it will also use ArrayList#add and performance should be somewhat factor 5 better. Then Groovy is still 10 times slower than the Java version of course. But at least not those 50x, and would you force Java in interpreted mode, it would have about the same slow down.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/714482153377410531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/714482153377410531'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html?showComment=1324424445659#c714482153377410531' title=''/><author><name>Jochen "blackdrag" Theodorou</name><uri>http://www.blogger.com/profile/15853173707470873265</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1359481583'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-1323114631190254595</id><published>2011-12-21T00:15:25.446+01:00</published><updated>2011-12-21T00:15:25.446+01:00</updated><title type='text'>And in Clojure (without any mutable datastructure)...</title><content type='html'>And in Clojure (without any mutable datastructure):&lt;br /&gt;&lt;br /&gt;(defn foo [x]&lt;br /&gt;(cond&lt;br /&gt;(number? x) &amp;quot;Number&amp;quot;&lt;br /&gt;(string? x) &amp;quot;String&amp;quot;&lt;br /&gt;(= (class x) Boolean) &amp;quot;Boolean&amp;quot;))&lt;br /&gt;&lt;br /&gt;(time (println (count &lt;br /&gt;(map foo &lt;br /&gt;(apply concat &lt;br /&gt;(repeat 10000 [&amp;quot;foo&amp;quot; 23 true]))))))&lt;br /&gt;&lt;br /&gt;Prints:&lt;br /&gt;30000&lt;br /&gt;&amp;quot;Elapsed time: 194.046477 msecs&amp;quot;&lt;br /&gt;&lt;br /&gt;The Java version needs 31ms on my machine.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/1323114631190254595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/1323114631190254595'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html?showComment=1324422925446#c1323114631190254595' title=''/><author><name>Stefan Oehme</name><uri>http://www.blogger.com/profile/17311392191635575113</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-68H371rqXJk/AAAAAAAAAAI/AAAAAAAAGfo/CpAkuyqYxQM/s512-c/photo.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-221834357'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-2014885990263541459</id><published>2011-12-21T00:00:30.530+01:00</published><updated>2011-12-21T00:00:30.530+01:00</updated><title type='text'></title><content type='html'>This comment has been removed by the author.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/2014885990263541459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/2014885990263541459'/><author><name>Stefan Oehme</name><uri>http://www.blogger.com/profile/17311392191635575113</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-68H371rqXJk/AAAAAAAAAAI/AAAAAAAAGfo/CpAkuyqYxQM/s512-c/photo.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.contentRemoved' value='true'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-221834357'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-8686136002844570445</id><published>2011-12-20T22:11:20.827+01:00</published><updated>2011-12-20T22:11:20.827+01:00</updated><title type='text'>Hey Sven, 

the Groovy code is too slow for the wo...</title><content type='html'>Hey Sven, &lt;br /&gt;&lt;br /&gt;the Groovy code is too slow for the work it should do. Please change the line &lt;br /&gt;absoluteResult += foo(y)&lt;br /&gt;&lt;br /&gt;into absoluteResult &amp;lt;&amp;lt; foo(y)&lt;br /&gt;&lt;br /&gt;The &amp;lt;&amp;lt; operator is much faster. I am not sure if the += construct always create a new list with the old values + the new one.&lt;br /&gt;&lt;br /&gt;Thorsten</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/8686136002844570445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/8686136002844570445'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html?showComment=1324415480827#c8686136002844570445' title=''/><author><name>Thorsten Kamann</name><uri>http://www.thorsten-kamann.de</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1677461610'/></entry><entry><id>tag:blogger.com,1999:blog-24248206.post-7129611571905586173</id><published>2011-12-20T21:45:43.183+01:00</published><updated>2011-12-20T21:45:43.183+01:00</updated><title type='text'>Hi Sven.

If you want maximum performance in Scala...</title><content type='html'>Hi Sven.&lt;br /&gt;&lt;br /&gt;If you want maximum performance in Scala you need while loops. For &amp;quot;loops&amp;quot; are &amp;quot;just&amp;quot; syntactic sugar for fold left and filter.&lt;br /&gt;&lt;br /&gt;I rewrote your little program to use while loops and the java utils collections and the scala version was as fast as java - but nearly as ugly to :-D&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Anyway - keep the great work with Xtend!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/7129611571905586173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24248206/4474110263473978366/comments/default/7129611571905586173'/><link rel='alternate' type='text/html' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html?showComment=1324413943183#c7129611571905586173' title=''/><author><name>jfr</name><uri>http://www.blogger.com/profile/15073523818126201196</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.efftinge.de/2011/12/groovy-scala-java-xtend-stupid.html' ref='tag:blogger.com,1999:blog-24248206.post-4474110263473978366' source='http://www.blogger.com/feeds/24248206/posts/default/4474110263473978366' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-437047045'/></entry></feed>
