4 ms·
Forgive me for asking what may be a very stupid question: Can someone explain to me the need for a Ruby interpreter built on top of Python? He mentions perfor
by nlh 14y ago
Forgive me for asking what may be a very stupid question: Can someone explain to me the need for a Ruby interpreter built on top of Python? He mentions performance in the announcement, but is this really going to be faster than, say, MRI? Thanks in advance.
- ConstantineXVI 14y agoIt's not vanilla Python but RPython, and presumably to take advantage of the PyPy toolchain to get similar results in Ruby as PyPy has in Python.
- dochtman 14y agoYes, because it's actually implemented on top of PyPy, which is a very modern run-time with a state-of-the-art JIT and good garbage collectors.
- pyre 14y agoRPython is a subset of Python that is used to build PyPy. If you want more information on it, I would do some reading on the structure of PyPy. To be clear, this isn't "Ruby running on top of Python." This is "Ruby specified in RPython."
- llimllib 14y agoThink of Pypy as somewhat like LLVM, except the language it's built on is a subset of the python language, called RPython. Although the most well-known language implemented in the pypy "vm" is python, the toolchain is completely language agnostic. So, this is more akin to Apple writing a C interpreter on top of llvm than it is to building a ruby interpreter on top of python.
- fijal 14y agoPyPy is totally not like LLVM in many regards. It targets a very different demographics. Some differences: * RPython comes with a good garbage collector * the language where you specify what's going on is RPython in which you write an interpreter. Then you get a JIT using a few hints. This is difference than "interpreter in C + compiler to LLVM" scenario by quite a bit. * RPython comes with a set of data structures that are higher level (lists, dicts, etc.) and is a GCed language. JIT is also well aware of those.
- fusiongyro 14y agoDo you know what an analogy is?
- llimllib 14y agoThere's no need to be a jerk.
- knowtheory 14y agoYeah, although there may be other ways to phrase your admonishment which people will be more receptive to. "C'mon dude, don't let flaming beget flaming."
- fijal 14y agoI'm actually not a native speaker, so indeed, I might not know. I checked in the dictionary though. This is an analogy, but not a very good analogy, because of the reasons that I pointed out. Are you disagreeing with any particular reasoning there? Or should I just say "they're similary, but"?
- knowtheory 14y agoWell, so you're right and you're wrong. You're right that the analogy doesn't quite capture everything here. On the other hand the analogy gets across most of the point. I would have said "That's mostly right, but the interesting thing about sharing code on a VM is access to VM features and code shared on the platform, not just that it's possible to decouple a front end from a VM." or something to that effect.
- fusiongyro 14y ago"They're similar, but" is much better than "is totally not like." The point of the analogy is to give a high-level view, not to achieve 100% accuracy at the lowest levels of detail.
- sirclueless 14y ago
- senorprogrammer 14y agoThanks for that simplified explanation. As someone not familiar with Python and Pypy I was having a tough time getting past the "Ruby on Python is efficient?" block; the analogy to LLVM is helpful indeed.
- knowtheory 14y agoSo, lets talk about JRuby. JRuby is a Ruby implementation on the JVM, and its really awesome power is actually that you can wrap and interface with Java libraries, and still write all of your app code in Ruby. If Topaz was able to give me the ability to access NLTK, but still write in Ruby? I'd be overjoyed.
- fijal 14y agoSo that would be a very cool project to merge python <-> ruby (or any other interpreter written in RPython). It requires quite a bit of work to pull it off the ground though. I would be happy to provide guidance on that, but I definitely won't do it myself (just yet).
- halostatue 14y agoIt's also worth noting that this is (mostly) possibly with RubyPython running in Ruby against a CPython2 dynamic library. Zach Raines did 99% of the heavy lifting (I've got a very small part to the whole project, and no time to work on it right now), and it works pretty nicely overall.
- masklinn 14y ago> If Topaz was able to give me the ability to access NLTK I doubt that's going to happen. Topaz is not a Ruby running on the CPython interpreter, the Topaz VM is developed in RPython. As far as I know, RPython doesn't provide that capability either (between VMs coded in RPython), which fijal seems to confirm.