Interim Grant Report: Meta-model Improvements and Natively Typed Attributes

Jonathan Worthington writes:

This is a report on the progress that I have made with my current Hague Grant,
Meta-model Improvements and Natively Typed Attributes.

My previous Hague Grants - and much of the work on Rakudo up until the Rakudo Star release - have had a focus on implementing Perl 6 language features, gradually building towards a compiler with more and more coverage of the language. Since the Rakudo Star release, the focus has shifted somewhat. While there are still missing features - implementing some of them are part of this grant - for many potential users, features are no longer their primary adoption blocker when it comes to Rakudo. Instead, issues like speed and memory usage are much more critical. At the same time, we also need to handle Perl 6's language extensibility goals, provide better feedback to users when they make errors, and be able to better support development tooling.

My work on the grant started with a period of research and design work, along with
prototyping so I could experiment with how to factor a new meta-model core. Along the way I laid down the details of how to actually achieve the things I had set out to do in the grant. I also came to realize that various other pieces of the compilation model would also need to change in order to deliver not just the explicit deliverables, but also on the spirit of the grant - that this is the basis for a great deal more optimization, extensibility, static analysis and feature development.

On the one hand, this has led to the grant taking rather longer than initially anticipated. On the other hand, the things that I've been dealing with along the way are issues that we'd only have had to take on at some point in the future anyway; once it became clear how closely connected they were to the work in the grant, it made sense to take them on as part of it.

At this point, the work to get 6model working on NQP (deliverables 1 and 2) is essentially complete and can be found in the NQP repository. Since various classes in NQP could also make use of natively typed attributes, this feature has been implemented in NQP, which means that a lot of the work needed to provide them in Rakudo - part of deliverable 4 - is already completed. I also have some concrete progress on deliverable 5, which invovles enabling custom meta-object implementations for packages. In fact, there aren't really any built-in, hard-coded defaults any more; the default meta-objects to use are simply imported by the default lexical setting and thus seen in all programs. However, it's possible to write a module that, when used, will provide a different set of meta-objects. I suspect the exact details of how that's factored will change a bit, but the key thing is that it's now possible in NQP, and of course will be in Rakudo.

Perhaps the most significant change in terms of the compilation process is that we now construct many things during compilation, then re-use them at runtime. Before, Rakudo was much more straightforward: it took in Perl 6, emitted Parrot Intermediate Representation, and then ran it. This is far simpler to actually implement, but also restricted implementing a wide range of optimizations. Now meta-objects are constructed as we parse. This means the compiler has a great deal more information available to it in order to make optimizations - even in the face of user defiend meta-objects. The same information is also useful for error reporting, and will be of interest to those who want to build developer tools.

Since these changes are fairly large and drastic from an internals point of view, we decided that this should be a new version of NQP, so nqp-rx users can migrate at their own pace. However, for users using NQP to build compilers, the changes are unlikely to cause much breakage. Even a grammar with actions as extensive as the ones Rakudo uses only needed very minor modifications to build with the updated NQP.

Under the hood the meta-model core is very minimal - even more so than I had first anticipated when I wrote the grant proposal. It supports gradual typing, representation polymorphism and, of course, meta-object programming. Since the core is very minimal, it's also attracted interest from other language developers building compilers for the Parrot VM, as well as interest from the Parrot developers themselves.

Over the course of the grant so far, I have blogged about my work, and also spoken about it at various workshops and conferences, 1, 2, 3 4. I will be presenting the latest details of it at both YAPC::Russia and YAPC::Europe.

Work is currently progressing with deliverable 3 - getting Rakudo to use the new meta-model and the many other enhancements and bits of infrastructure that have been developed while improving NQP. While it's taken a long time to get to this point, things are moving quickly and I'm optimistic that the June release of Rakudo will incorporate all of the deliverables of this grant. Even more importantly, it will set the stage for a great many more optimizations, features and other improvements.

I'd also like to take a moment to thank the community for their patience and support with regard to my work on this grant so far - it's wonderful to be a part of it, and to work with so many great people.

About TPF

The Perl Foundation - supporting the Perl community since 2000. Find out more at

About this Entry

This page contains a single entry by Karen Pauley published on May 26, 2011 2:34 PM.

Perl 5.14 was the previous entry in this blog.

YAPC::NA 2012 - Wisconsin or Texas? is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.


OpenID accepted here Learn more about OpenID
Powered by Movable Type 6.2.2