views:

481

answers:

5

What's the importance of having an interpreter for a given language written in the target language (e.g. PyPy)?

+2  A: 

I'm sure there are many different reasons for doing it. In some cases, it's because you truly believe the language is the best tool... so writing the language interpreter or compiler in the language itself can be seen as a form of dogfooding. If you are really interested in this subject, the following article is a really amazing read about the development of squeak. The current version of squeak is a smalltalk runtime written in smalltalk.

http://users.ipa.net/~dwighth/squeak/oopsla_squeak.html

kasperjj
The Squeak VM isn't really written in Smalltalk - rather in Slang. Slang is just C with a Smalltalk syntax.
Martin v. Löwis
+6  A: 

It's not so much about writing the interpreter in itself - more about writing the interpreter in a high-level language, not in C. Ideally, doing so allows to change details of the implementation, and making the interpreter more modular.

For the specific case of PyPy, writing the interpreter and the core objects in (R)Python allows to retarget PyPy for targets (C, JVM, .NET, JavaScript, etc), and also allows to replace aspects such as the garbage collector.

Martin v. Löwis
A: 

An added benefit is that if you implement good debugers and IDEs for your target language, they also work for your source language.

JBF
A: 

You can proof this way that the target language is serious business, because being able to make it compile something is a sign that it is a good language.

Ok, C++ and Java produce compilers as well... so maybe that argument is only half as good as it may seem.

StormianRootSolver