Wednesday, February 27, 2008

What is Parrot?

Parrot is a virtual machine for dynamic languages like Python, PHP, Ruby, and Perl. A dynamic language is one that allows things like extension of the code base, subroutine and class definition, and altering the type system at runtime. Static languages like Java or C# restrict these features to compile time. If this sounds like an edgy idea, keep in mind that Lisp, one of the prime examples of a dynamic language, has been around since 1958. The basic paradigm shift to a dynamic languages leads the way to other more advanced dynamic features like higher-order functions, closures, continuations, and coroutines.

When we started Parrot, there wasn't much respect for dynamic languages in the commercial software world. We used to get asked why anyone would bother creating a virtual machine for dynamic languages. (I recall a very entertaining conversation with the .NET developers, years ago.) All that has changed in the intervening years, and the big VM players now proudly proclaim their support for dynamic languages. They haven't quite got the idea yet, but they're making good progress, and the fact that they wear "dynamic language support" as a badge of honor tells me what a powerful effect Parrot has had.

Mozilla is all about "driving innovation for the open Web". Parrot is all about driving innovation in virtual machines and programming languages. Parrot's architecture is fundamentally different than the JVM or CLR. It's register-based rather than stack-based, uses Continuation Passing Style as the core means of flow control, and provides a powerful set of tools for compiler writers, based on recursive descent parsing and tree transformations.

If you look back over the history of programming languages, you'll be astounded at how few new features have been added in the past 30 years. One reason behind the slow progress is that simply implementing a state-of-the-art programming language with full support for standard features like garbage collection, an object model, events, exceptions, etc. takes so long that most people stop there and don't bother to invent new features. Parrot targets that problem by providing the standard feature set, so language implementers and language designers can skip ahead to the interesting and new features.

Another reason for slow progress is patterns of adoption. A language isn't particularly useful without libraries, and libraries aren't written until enough people are using the language that it's worthwhile to spend time developing libraries. Most new languages never gain a significant user base because they're too isolated to solve real-world problems. Parrot targets that problem by allowing languages to share libraries. A brand-new language has access to all the libraries of Python, Perl, Ruby, etc. and can start solving real problems right away.

Lowering the time required to create a fully-featured language opens the door for more rapid evolution. Once you've spent 10 years implementing a language and building up useful libraries, you're pretty heavily invested in the syntax and particular set of features you started with. But if you only spend a week, it's no great loss to radically change the syntax or implementation (or even scrap it and start over) when you find a better way to do it.

Our push this year is the 1.0 release of Parrot. What that will mean for you is a solid core virtual machine, with stable APIs, ready for production use. What that means for the development team is that our time this year is spent on finalizing design documents, polishing subsystems, cleaning up the code base, and in some cases replacing prototype implementations with production implementations.

2 comments:

Nicholas Clark said...

They haven't quite got the idea yet

What key parts are they missing? The DLR blog entry that you link to makes it sound like that DLR is attempting to provide much the same feature set and environment as Parrot to the language implementor, so what sets Parrot apart, and ahead? I'm guessing that the answer is another blog posting in itself.

Unknown said...

Thanks for bloging about parrot.