Monday, May 05, 2008

Ruby to Python bytecode compiler

Kumar beat me to it, but I'll mention it here too: Why the Lucky Stiff published a Ruby-to-Python-bytecode compiler, as well as tools to decompile the byte code into source code. According to the README file, he based his work on blog posts by Ned Batchelder related to dissecting Python bytecode. I wholeheartedly agree with Why's comment at the end of the README file:

  You know, it's crazy that Python
and Ruby fans find themselves
battling so much. While syntax
is different, this exercise
proves how close they are to
each other! And, yes, I like
Ruby's syntax and can think much
better in it, but it would be
nice to share libs with Python
folk and not have to wait forever
for a mythical VM that runs all
possible languages.

2 comments:

Anonymous said...

If Google thinks Python is better, it HAS to be, right? ;-)

I've tried both, I still think as far as the job market is concerned, Ruby ::IS:: Rails, and not much more. Where as Python is all over the place.

Nadav said...

The Python bytecode is not specific to Python. You could implement your own language using the bytecode. Also, did you know that the python bytecode has 'goto' in it ? :) one can add goto to python.