would it be possible to convert a scripting language like Python or Ruby so that it compiles directly to machine code? if so would it be as fast as Pascal/Delphi? would it be possible to give languages like Python the option to declare types statically to override the dynamic typing?
Every language can be compiled, every language can be interpreted.
The thread is now over, you can go back to /g/.
Name:
Anonymous2011-02-03 20:35
Yes. Psyco already does that: it takes portions of code that are repeatedly executed and compiles specialized versions of them to machine code. Also, search for Pyrex on your favorite seach engine.
And no, it wouldn't be as fast as Pascal, based on the history of specializing compilers for dynamic OO languages. The fact that Python's dynamic dispatch is a series of hashtable lookups instead of a single table access for every (method call|messsage dispatch) puts such a dent on performance that apparently no amount of optimization (as far as we know) can completely eliminate.
>>18
Has been proved that any language, interpreted or compiled, can be slightly faster than any other language, interpreted or compiled, given the correct choice of benchmark