I've read about meta-circular interpreters on the web (including SICP) and I've looked into the code of some implementations (such as PyPy and Narcissus).

I've read quite a bit about two languages which made great use of metacircular evaluation, Lisp and Smalltalk. As far as I understood Lisp was the first self-hosting compiler and Smalltalk had the first "true" JIT implementation.

One thing I've not fully understood is how can those interpreters/compilers achieve so good performance or, in other words, why is PyPy faster than CPython? Is it because of reflection?

And also, my Smalltalk research led me to believe that there's a relationship between JIT, virtual machines and reflection. Virtual Machines such as the JVM and CLR allow a great deal of type introspection and I believe they make great use it in Just-in-Time (and AOT, I suppose?) compilation. But as far as I know, Virtual Machines are kind of like CPUs, in that they have a basic instruction set. Are Virtual Machines efficient because they include type and reference information, which would allow language-agnostic reflection?

I ask this because many both interpreted and compiled languages are now using bytecode as a target (LLVM, Parrot, YARV, CPython) and traditional VMs like JVM and CLR have gained incredible boosts in performance. I've been told that it's about JIT, but as far as I know JIT is nothing new since Smalltalk and Sun's own Self have been doing it before Java. I don't remember VMs performing particularly well in the past, there weren't many non-academic ones outside of JVM and .NET and their performance was definitely not as good as it is now (I wish I could source this claim but I speak from personal experience).

Then all of a sudden, in the late 2000s something changed and a lot of VMs started to pop up even for established languages, and with very good performance. Was something discovered about the JIT implementation that allowed pretty much every modern VM to skyrocket in performance? A paper or a book maybe?

  • 3
    Money. The money that used to be poured into C++ and Fortran now is poured into the HotSpot, CLR, Mono, V8, Nitro, SpiderMonkey, etc. Sep 30, 2013 at 23:54
  • I can only guess, but I think it is just improvement over time, like described here joelonsoftware.com/articles/fog0000000017.html
    – Doc Brown
    Oct 1, 2013 at 6:01
  • 1
    RE how PyPy can be faster than CPython: It isn't written in Python, it's written in a quite different language that can be AOT-optimized effectively.
    – user7043
    Oct 1, 2013 at 10:08
  • 1
    @Gomi It's not about how similar the implementation language is to the implemented language. There are JavaScript, Lisp, Prolog, SmallTalk and Ruby interpreters written in RPython and they get exactly the same goodies PyPy offers. The only reason RPython is based on Python is that it was created by a bunch of Python enthusiasts. The features of RPython that make PyPy fast have nothing to do with Python: Automatic JIT compiler generation, the garbage collectors, etc. - and yes, most of that could in principle be done using other languages. You'd have to create a whole new compiler though.
    – user7043
    Oct 1, 2013 at 15:29
  • 4
    -1 because you seem to have at least 3 different questions here: (a) Why are meta-circular implementations so good? (b) Are VMs efficient because of type information, and is introspection beneficial for performance? (c) How come VM popularity surged in the late 2000s, and how come they all of a sudden have good performance? I think it's better to ask those questions separately.
    – Oak
    Oct 2, 2013 at 6:39

1 Answer 1


2 out of 3: There is no relationship between "meta-circular" and "high-performance" language runtimes. Meta-circular runtimes which achieve high performance do so by JIT-compiling to native code, and running the native code. There is no reason why your hi-perf Python runtime has to be written in Python, or Lisp in Lisp, etc. But if you think that your language is more powerful, expressive, etc. than the others, why not use it to write its own runtime? Or if you don't think that your language is somehow "better" than others, why are you going to the trouble to implement it at all?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.