26 Feb, 2009, David Haley wrote in the 21st comment:
Votes: 0
I see. I thought you were talking about more general cases than what you explained just now. I think your usage of the term "equivalent C code" might have thrown me off because we're really not talking about equivalent code anymore. Also, the "sometimes" you used seems to in fact be for very specific cases.

I agree though that having access to runtime information is extremely helpful – this has been something that highly dynamic languages have been doing for a while. Self comes to mind as a good example of this (that kind of went unnoticed, for whatever reason(s)).

If it comes to it, I would agree that for the average application and programmer, the good JIT engines would do a better job than the C compiler. But I disagree that people who care and know what they're doing would be left in the dust – there are tools that generate the kind of statistics you talked about, for example.

Also, there is something to be said for being far faster in general than on one specific case, if you're writing code for a more or less general purpose library.

elanthis said:
We've had this debate before. ;)

I remember talking about Lua with you one way or another, but I couldn't remember if we talked about the saneness of the language syntax/semantics. :shrug: :smile:
26 Feb, 2009, Tyche wrote in the 22nd comment:
Votes: 0
Actually it's pretty easy to generate code that outperforms the gcc compiler, so it's not at all hard to imagine some jit doing it.
Just for shits and giggles…

Check out my fancy Ruby compiler/jit that simply destroys gcc both on size and performance.

$ cat hello.c
main() { printf("Hello World\n");}
$ gcc -O3 hello.c -o hello.exe

$ ruby -e 'File.open("hello.com","wb"){|f| f.write "\xba\x0b\x01\xb4\x09\xcd\x21\xb4\x4c\xcd\x21Hello, World\r\n$"}'

$ ls -la
-rwxrwxrwx 1 tyche None 26 Feb 26 01:00 hello.com
-rwxr-xr-x 1 tyche None 8902 Feb 25 23:02 hello.exe

Apparently Ruby generated code is 98% smaller and more than 5 times faster than C generated code!!!
Q.E.D.

In a parallel universe similar to ours, yet oddly different, someone is asking on a coding forum…
"How is possible that a C jit can be faster than a BASIC executable?"
20.0/22