Presumably Javascript is compiled to some kind of byte-code to run on the V8 Engine? Is Python a similar enough language that we can imagine Python being compiled to the same byte-code and run on the V8?
Any projects trying to do this?
V8 is fast due to the JIT, Crankshaft, the type inferencer and data-optimized code. Tagged pointers, NaN-tagging of doubles. And of course it does normal compiler optimizations in the middle. The plain ruby, python and perl engines don't do neither of the those, just minor basic optimizations.
The only scripting language which beats Javascript (v8) in speed is Lua AFAIK. And yes, it is faster than Python.
The V8 API provides functions for compiling and executing scripts, accessing C++ methods and data structures, handling errors, and enabling security checks. Your application can use V8 just like any other C++ library.
As far as I know, there are no projects that specifically target the V8 virtual machine. However, Pypy and the erstwhile Unladen Swallow (now merged into the py3k-jit branch of the main CPython tree), both attempt to just-in-time compile Python into native code, similar to what V8 does with Javascript.
As @something says, pyjamas allows you to write Python code and translate it into Javascript, much like GWT does with Java. Any code translated thus would have the same benefits to running under V8 as any other Javascript code.
V8 doesn't actually have a general purpose bytecode. There's a regexp byte code, but support is not usually compiled in. There's a deserialization byte code and a relocation information byte code, but both are implemtation details and you can't use them for anything.
So what you are looking for is something that compiles to JS source code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With