From: Dan Sugalski Date: 2002-02-13T11:09:49+09:00 Subject: Re: Ruby performance on the Language Shootout At 4:58 PM -0800 2/12/02, wrote: >In article , >Dan Sugalski wrote: >>At 8:12 AM +0900 2/13/02, Phil Tomson wrote: >>>I haven't taken a look at the Great Computer Language Shootout page for >>>about a year - I checked it out today. About a year ago, Ruby's >>>performance ranked between Perl's and Python's (with Python at the low >>>end). Now it looks like Python beats Ruby pretty consistently. Is this >>>because Python is bytecode interpreted and they've made improvements to >>>their VM? >> >>FWIW, bytecode interpretation doesn't really matter for speed > >purposes. I'd look elsewhere for any speed issues. > >Can you give us any more details? There aren't a whole lot, since generally a language implementation chooses one or the other and goes that way. And when a change is made, it's usually part of a major rewrite and it's tough to do a comparison. >Is it true then that interpretation via >walking an AST (as Ruby does) is as fast or faster than compiling to a >bytecode and running it through a VM? In a compile-and-go environment, walking an AST is usually faster by just a hair, since you can keep pointers around that you'd likely throw away making bytecode. >(since you don't have the extra >step of creating bytecode, it would seem to be potentially faster) -if >so, then why are bytecode VMs so popular? Bytecode VMs allow you to freeze code to disk and load it back in again, which is the place they tend to win. (If they do, which they often don't) You can also do some optimization that's more difficult with plain ASTs. There's also the disconnect between the parser and the interpreter engine, which can be a good thing. You get a tight interaction which can make optimizing one piece or the other a bit tricky. Plus you need to be really good to keep it all in your head at once. -- Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai dan@sidhe.org have teddy bears and even teddy bears get drunk