Academics vs. Engineers: PyPy vs. V8

It's interesting to see how academics attack a problem and how engineers do it. In this post I'll take a look at the two approaches.

The two fighters

In the red ring corner you have PyPy - an implementation of Python in Python itself. The project is ambitious and at some points obscure (for example, they dig into Prolog to get some experience with JIT compilation).

In the blue ring corner you have V8, the JavaScript VM that's used in Google Chrome. The lead of the project is Lars Bak, who has more than 20 years of experience implementing virtual machines.

Their status?

PyPy has been underway for a long time (around 6 years) without producing anything that can be used in production. Their goal is quite ambitious and their ways of exploring the space is at some places innovative and uncommon. Their end-goal is to produce a fully compatible Python implementation. So far they don't have a fully compatible Python, but only a subset.

V8 has not been that long underway and they have a solution now that beats old JavaScript implementations by large margins. Their end goal is a working JavaScript implementation that's very fast - - and so far they have succeeded in their goal. In V8 they use some old research, like hidden classes that was used in Self in 1989. The Google team mostly focuses on the implementation and not so much on the theory.

The conclusion

It's two very different ways of attacking a problem. The academics attack it to gain new insights, while engineers attack the problem to solve it using currently available knowledge. It should be noted thought that engineers might also gain new insights while solving a problem, Lars Bak has for example 18 patents in VM technology.

Code · JavaScript · Life · Python 14. Jun 2009
12 comments so far

Look at Unladen Swallow,it is the V8 way of getting python faster.
While i really like PyPy,it is really complex beast,but i think in this case it is not a 100% academic project since they have a goal of creating a really fast python implementation for production use.

Uriel, why do you think Unladen swallow is the "v8 way" of getting python faster?
I'm not sure but I believe v8 compiles javascript to machine code "upfront", while inline caches patch the code as it runs to optimize it.
However, Unladen Swallow is based in Cpython. They aim to port it to LLVM, which allows for more optimizations, but I don't see many similarities with the v8 way. I might be wrong though...

It's not true that PyPy only implements a subset of Python. Except for a few obscure CPython implementation detail (like reference counting), PyPy is fully compatible with CPython 2.5.2. If it's not, that's a bug.

You really have no idea about what PyPy is and how it works.

Go read the documentation. V8 isn't really that impressive, PyPy on the other hand is. It also has a much, much larger scope.

Benjamin:
I don't really know anyone that uses PyPy in production. Other than this, PyPy only seems to be faster than CPython on some corner cases - - which for production systems makes PyPy pretty irrelevant.

Uriel Katz:
I agree that Unladen Swallow is the way engineers would attack the problem of optimizing Python. And so far they have already succeeded, since they have a faster implementation than CPython and RPython. This said, the Unladen Swallow team might not get the insights that PyPy team has achieved/will achieve.

Anyhow, this post is really about two ways of attacking a problem - - with two different outcomes. I am not saying that the way engineers work is a better way of solving problems, since PyPy team might have gained some knowledge that could be used to implement languages much better.

An example: who would have thought that optimizing Self in 1989 with hidden classes would be beneficial 19 years afterwards to optimize JavaScript...

It would be wrong to forget that Armin Rigo is working on PyPy, otherwise known as the principle behind Psyco, which a lot of people will let you know is far more than some academic exercise: they depend on it for their businesses to continue running. :-)

Very good article again. Thanks for that.

PyPy is about 10% consistently faster than Python 2.5.2.

It's important to add that, in terms of results achieved, it's not fair to make this comparison, at least considering Google hires the best engineers in the world and must have put real money on this project.

This comparison is somewhat disingenuous. While your claims that V8 has certainly produced a much more usable product than pypy, you're neglecting the developers.

V8 is being created by people who are most likely paid full time for their contributions to V8. This is not the case of the V8 engineers.

Also the goals are different, V8 is made by a company who needs a fast javascript VM as soon as possible, Pypy are done by a group of individuals who want to explore the possibilities regarding the execution of dynamic languages as well as building a runtime so that python hackers can hack using python.

AFAIK PyPy is funded by the European Union (and some universities?), so they haven't worked for free. Anyhow, I don't think the difference is made because of money, but because of different ways of looking and solving a problem.

I think its important to note the key difference in the goal of these projects. Implementating a language in itself is a time honored and important step in the maturity of a language. I don't think the goal of the pypy implementation is the speed or quality of the implementation. It's merely a proof that a language is mature enough to implement itself.

cheers,
Tickmarkt

Post a comment
Commenting on this post has expired.
© 2000-2009 amix. Powered by Skeletonz.