Categories

Posts in this category

Mon, 04 Jan 2010

Perl 6 in 2009


Permanent link

Much has happened in the Perl 6 land in 2009. Here is my humble attempt to summarize some of it; If you find something that I missed, feel free to contact me, I'll try to add it.

Specification

The year started with lots of improvements to S19. In January we also learned that *-1 constructs a closure, which means that Perl 6 has semi-automatic currying features built into most operators.

Lists, Captures and Parcels

We've seen a lot of talk about slices, lists, captures and parcels. The heart of the discussions is always how interpolation and non-interpolation of lists can be made both flexible and intuitive. For example: should 1, 2, 3 Z 'a', 'b', 'c' return a single, flat list? or instead a list of lists? How can a function which receives the result decide for itself what it want to receive? How does that mix with multi-dimensional arrays?

I haven't followed these discussions very closely, and so I'm hard pressed to give a good summary; however it seems that in the end an agreement was reached: each parenthesis constructs a Parcel, short for Parenthesis cell. A Parcel can behave context sensitively: A single-item Parcel degrades to its contents; as a signature list it is converted to a Capture object; code object also return parcels.

It remains to be seen how multi-dimensional slices (with the @@ sigil) evolve, and if we can't find anything suitable to replace them.

Built-in Routines

S29, the list of built-in functions and methods, finally got some long awaited attention in 2009, starting with Carl Mäsak's S29 Laundry List, and later carried on by Timothy Nelson, who split S29 into a set of documents summarized as S32.

In December it was decreed that most built-in methods have a candidate in a new class Cool, (Convenient OO Loopbacks), of which all value types and container types in Perl 6 inherit. That way maximal DWIMyness can be retained, while keeping user defined types clean of the more than hundred methods defined in Cool.

It is rather perlish to have a distinct name for each operation, and make it coerce its arguments. A few exceptions exist in Perl 5 (like reverse, which is list reverse in list context, and string reverse in string context); in Perl 6, most of these exceptions have been removed: reverse now only reverses lists, strings are reverted with flip, hashes with invert.

At the Nordic Perl Workshop, Larry decided that the prefix:<=> operator had to go, and replaced it with the .get and .lines methods.

Operators

The Cross Meta Operator is now Xop instead of XopX; in analogy the R meta operator reverses the argument list, so $a R- $b is the same as $b - $a.

Ranges served two purposes: one for denoting ranges in the sense that the mathematicians use them, and for generating lists according to simple schemes. These two functions have been separated: ranges are still constructed with two dots, but the :by adverb is gone; more intricate, lazy list generation can be achieved with the new series operator:

.say for 1, 1.1, 1.2 ... 5;
.say for 1 ... *+0.1, 5;

Numbers

The above actually works, and doesn't suffer from floating-point arithmetics, because 0.1 isn't stored as a floating-point number, but rather as a fractional number of type Rat.

Other languages decided against that approach, because some very simple loops quickly produce rather large numerators and denominators, degrading performance of the integer operations. Perl 6 instead has a limit in denominator size, and falls back to floating-point operations when that limit is crossed.

Implementations

Rakudo

A lot of work has been done in Rakudo; in fact it's hard to remember how it used to be in January 2009; Most features were implemented by Patrick Michaud and Jonathan Worthington, but we had a lot of other contributors too.

In January, Rakudo left the Parrot repository and since then lives on github as a git repository. It now relies on an installed parrot.

Rakudo implements many new features and lifts old limitations:

  • Many built-in routines are now written in Perl 6
  • eval() and classes now have access to outer lexical variables
  • Much improved Unicode support, both in IO and regular expression
  • punning of roles when .new is called
  • Typed arrays and hashes, parametric roles
  • Routine return types are now enforced
  • Error messages now contain backtraces with filenames and line numbers
  • Multi dispatch is now implemented with a custom dispatcher and signature binder, bringing much improvements over the dispatch and binding semantics that parrot supports.
  • User-defined operators now possible, and automatically generate some of their associated meta-operators.
  • Contextual variables
  • User-defined traits are now possible; some of the built-in traits are now written in pure Perl 6.
  • Rational numbers are now implemented, and support for Complex numbers has been much improved.
  • routine signatures can now be introspected properly.

SMOP and Mildew

SMOP and Mildew have seen a major refactoring, connected to the changed semantics of slices, captures and parcels, and to the way method invocations are stored.

Paweł Murias implemented multi dispatch as a Summer of Code project. Mildew now supports an impressive set of features, but since it is not very user oriented, I know of no projects that actually use mildew as a platform.

Other implementations

Elf development seems to have stalled. Pugs mostly sleeps, too, though Audrey updated it to work with the latest Haskell compilers. (It doesn't live in the Pugs repository anymore though, and is distributed by cabal, the Haskell package manager).

New in the field are Sprixel, a Perl 6 to Javascript compiler, and vill, an experimental LLVM backend to STD.pm+viv.

Test Suite

The test suite continued to grow; most tests have now been moved to t/spec/, the official Perl 6 test suite. Most tests in the other remaining files are either rather dubious, or rely on behaviour that's not officially specified (or are specific to an implementation).

Many new tests have been contributed by two new faces: Solomon Foster contributed a large number of tests for trigonometric functions on the various number types, and rational and complex numbers. Kyle Hasselbacher provided us with many regression tests for Rakudo which are also useful to other implementations.

Documentation

Bemoaning the fact that Perl 6 has nearly no user-level documentation, Carl Mäsak started u4x, User-Level Documentation for X-Mas. Hinrik Örn Sigurðsson chimed in, and started to write grok, a tool for retrieving and showing documentation, sponsored by the Google Summer of Code project.

Patrick Michaud, Jonathan Worthington, Carl Mäsak, Jonathan Scott Duff and Moritz Lenz started to work on a Perl 6 book, with a few chapters already being written.

Websites

In an attempt to provide an up-to-date link list, Moritz registered perl6-projects.org and collected links. Later Susanne "Su-Shee" Schmitt contributed a nice design, and Daniel Wright made the domain perl6.org available to us.

So we now have a community driven, central Perl 6 site at perl6.org.

Leo Lapworth redesigned perl.org, and also the old Perl 6 development page, and updated it a bit.

Blogs

As an attempt to improve the visibility of the Perl community, Matt S. Trout issued the Ironman Perl Blogging Challenge. So far it's a huge success, and quite a few hackers blog about Perl 6 there. Also the blog roll of the Planetsix Blog Aggregator continued to grow, some excellent new blogs were added in 2009.

Carl Mäsak blogged at least once per day in Novemeber, same procedure as least year :-)

IRC

The #perl6 IRC channel has been very pleasant and active in 2009, with three times the activity of 2008.

The Future

For April 2010 the Rakudo developers have planned a big release called Rakudo *, not feature complete but still useful and usable. Around the same time the new Perl 6 book will be released.

The specification is still evolving, and has some areas that are in need of implementation before they can evolve more; among them are macros, concurrency and IO.

Update: improved floating point example as per comment from Matthias.

[/perl-6] Permanent link

comments / trackbacks