From: Hugh Sasse Staff Elec Eng Date: 2001-08-03T00:24:00+09:00 Subject: [ruby-talk:19032] Re: Perl/Python/Ruby common backend (Perl6), and benchmarks. While we are looking at virtual machine technologies I'd like to suggest the following. NOTE: I know very little about the design and implementation of effective virtual machines, so this won't be very profound, and I won't be able to answer the questions it raises. The Lua programming language [1, 2] is based on a virtual machine and has a respectable enough performance for use in gaming environments [3]. There is a script of the game of life which Lua comes with. It runs on an ANSI terminal. Its speed impressed me. It seems to me that there might be things in the design worth examining. Now, there are lies, damnd lies, and benchmarks, and in some simple cases (ScriptPerf [4]) Lua outperforms Ruby. But this turned out to be more interesting than is usually the case for benchmarks written by people who don't fully understand a language. Many of the ScriptPerf benchmarks were written with many loops. In the cases where blocks were used I got a little speedup when I pre-declared things, as we have discussed before. However, what interested me was that the benchmarks with for i in (1..count) ... end Were about 12.??? seconds whereas (1..count).each {...} were about 14.??? seconds (for counts of 500000) I expected the case where the Range did all the looping to be faster. I thought that as iterators are good style in Ruby that they'd be fast. What is the reason behind this? Is this something that is likely to change? I'm not so worried about performance that I need this changed, Hugh [1] http://www.tecgraf.puc-rio.br/lua/ [2] http://www.lua.org/ [3] http://www.tecgraf.puc-rio.br/lua/uses.html [4] http://www.chat.net/~jeske/Projects/ScriptPerf/