From: Charles O Nutter Date: 2006-07-26T22:57:11+09:00 Subject: Re: For performance, write it in C ------=_Part_7692_21471802.1153922228482 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I'll lob a couple of grenades and then duck for cover. - Write it in C is as valid as write it in Java (as someone else mentioned). Java is at least as fast as C for most algorithms. On the JRuby project, when we need to clone a C extension or library from Ruby, we typically write it first in Ruby (to get something running quickly) and then reimplement it in Java (for performance). The sad truth beyond the numbers and quantitative comparisons is that a dynamic typed language with no primitives is almost certainly going to be slower than staticly typed with with everything-is-an-object. Toss out your favorite super-fast dyntyped language if you will...I'm speaking in generalities. - Write it in C is also as dangerous (in the grand scheme of things) as write it in Java, because it has the potential to tie you to a specific platform. For better or for worse, there's a lot of Windows machines out there, and practically none of them have compilers. That means anything you write in C will have to be pre-built for those platforms, or users are SOL. Java suffers from the same fate...a Java VM is required...but if you're running JRuby you probably have already made that plunge. There's a balance to be struck between tying yourself to fast native code or accepting slow interpreted code. You pay a very specific price either way. All this said, there's truth to the idea that we shouldn't *have* to write platform-level code to get reasonable performance, and every effort should be made to improve the speed of Ruby code as near as possible to that of the underlying platform code. On JRuby, we are working on various compiler designs to turn Ruby code directly into Java bytecodes and methods, cutting out the overhead of node-by-node interpretation. Early returns show as high as 65% gains for some algorithms. We're also looking at modifications to the parsing process to structure the AST in ways that makes it easier to interpret. We in particular have to compete with a vast world of Java code and Java coders, and although we'll never match the performance of raw Java we endeavor to get as close as possible. -- Charles Oliver Nutter @ headius.blogspot.com JRuby Developer @ www.jruby.org Application Architect @ www.ventera.com ------=_Part_7692_21471802.1153922228482--