Hague Grant Completed by Jonathan Worthington

Jonathan Worthington writes:

This is the final report for my Hague Grant on Meta-model Improvements and Natively Typed Attributes. There was also an intermediate progress report. At the point of the intermediate progress report, a new version of NQP had been delivered. Its objects were implemented in terms of a new meta-object system, developed with the needs of Perl 6 in mind. However, at that point Rakudo had not started to use it. This report covers that part of the work. In this report I will use D1, D2, etc. to refer to Deliverable 1, Deliverable 2, etc. from the original grant application.

Rakudo has evolved and improved enormously during the course of this grant. This is partly thanks to the work of this grant, but also as a consequence of work that has built upon it. In many cases the work done not only meets the goals of the grant but goes far beyond them. Furthermore, the MOP work delivered under this grant is also being studied by those working on the Perl 5 MOP project.

Rakudo today has all of its meta-objects implemented in NQP (D2, D3), using the new meta-object system designed and implemented under this grant, which is often known by the name "6model" (D1). Each meta-object implements the semantics of a kind of type: classes, grammars, roles, subsets, enumerations and so forth. These meta-object implementations are in turn factored in terms of roles, thanks to NQP having been given role support during the course of the grant. The NQP role support has also been used by Patrick Michaud in development of an updated grammar engine, which has in turn resulted in many improvements to Rakudo's grammar support.

The point of a meta-object protocol is not only to enable clean implementation of language features, but also to allow extending the semantics of the language. These extensions can be written in Perl 6 - that is, in the language itself. The ability to extend a language using the language itself is known as meta-circularity. The most useful modules using this ability so far are Grammar::Tracer and Grammar::Debugger, which add debugging support to grammars in pure Perl 6. As well as being a good demonstration of meta-programming in Perl 6, the modules have been genuinely useful to those writing Perl 6 grammars. More examples of meta-programming can be found in my Meta-programming in Perl 6 talk [pdf]. The specification has a section on custom meta-objects also (D5); this will continue to be fleshed out over time.

The grant also called for the implementation of natively typed attributes. This deliverable has been achieved in both NQP and Rakudo (D4). In NQP, they have been used to slim down the Cursor and Match data structures. Furthremore, Rakudo has also gained natively typed lexical variables. As well as being available to user-space programs, they have also been used to optimize various built-ins in the core setting.

Test coverage for the metamodel and other deliverables is available throughout the existing testing frameworks (D6). Testing of 6model and role support is provided in NQP's test suite. Testing of OO programming is performed extensively through the S06, S12, and S14 portions of the roast (spectest) test suite.

During the course of the work, pre-compilation support and BEGIN handling have also been improved greatly. This partly involved the implementation of bounded serialization, which dramatically improved the startup time of Rakudo as well as the load time of pre-compiled modules. It also means that BEGIN time compuations are properly persisted over the compile-time/runtime boundary.

The richer type system support also led to development of an optimizer; this work was presented in a blog post as well as a talk [pdf] given at a couple of workshops. The optimizer supports optimizations such as inlining and compile-time resolution of multiple dispatch. The analysis done by the optimizer can also detect various program errors that will lead to innevitable failure at runtime.

While the optimizer can greatly improve performance in certain situations, the work done in this grant has led to an overall performance increase even without the optimizer. The effect of these improvements on a mandelbrot program was analysed early on in a blog post by Moritz Lenz; further improvements led to running this program 19 times faster than was possible in Rakudo as it was before this grant was started. As another data point, the list/iterator model developed in Rakudo using the primitives provided by this grant is 30x faster than Rakudo previously had, despite being written in Perl 6 rather than PIR.

Also worth mentioning is that by implementing representation polymorphism, the new object system has allowed for greatly improved native call support; it is now possible to pass arrays and structs to C from Perl 6 code using the NativeCall module. The improved native call support has been used in modules such as DBIish, which now supports MySQL, Postgres and Sqlite.

Rakudo is a great deal further forward today than it was before this grant started. While this is of course thanks to the efforts of many contributors, the work done under this grant has been key to the progress than has been made. In many senses, the main success of this grant has not just been in achieving the deliverables themselves, but in the many things that have been built around and on top of them. Critically, Rakudo is in a strong position to continue improving stability, performance and usability, as well as add additional missing features - all important to being useful to a wider range of potential users.

About TPF

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

About this Entry

This page contains a single entry by Karen Pauley published on July 7, 2012 8:29 AM.

Spanish Localization of the Perl Core Documentation - Grant Report #1 was the previous entry in this blog.

Perl 5 Core Maintenance Grants Extended 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