Perl 6 First Official Release
Written by Nikos Vaggalis   
Monday, 28 December 2015
Article Index
Perl 6 First Official Release
How Will Perl 6.c Be Used

Released on December 24, 2015, Perl 6 Version 1.0 is also  Perl 6.c or Perl 6 Christmas, a reference to this festive season. We look at why Perl 6 has taken so long to get to its first official release and how it will impact the Perl community.

 

 

The Perl 6 project was announced back in 2000. It has taken 15 years since then to reach the first official release.

Why so long?

One reason is that Perl's original creator and main architect Larry Wall faced some serious health problems in the intervening period. A more significant one is that the features that the language would implement like gradual typing and mutable grammars were ahead of their time.

A radical Virtual Machine for Perl 6

Add to that the switch from one VM to another, porting the compiler suite from Parrot VM to the JVM and to MoarVM in parallel, which meant catering and designing for a new bytecode infrastructure.

Also, since Perl 6 was destined to be a gradually typed language, the considerations were different from if it was dynamically typed, so there was interest in VMs which explicitly seek to do both static and dynamic typing.

Back in July 2013 Jonathan Worthington, the person mainly responsible for Raduko, the Perl 6 compiler, revealed to us the reasons for such a switch :

Nikos Vaggalis:So let’s go back to the beginning and talk about Rakudo, JVM, and MoarVM. Was the move of porting Rakudo to the JVM planned, or was it driven by Parrot’s deficiencies?

Jonathan Worthington:Having Rakudo also running on the JVM has been of interest to us for years. Python is on the JVM. Ruby is on the JVM. Where is Perl? What if Perl fits your problem, but you are only allowed to deploy things on the JVM at your organization? The modern reality is that talking about “run everywhere” is no longer just about operating systems and CPUs. Some of those “everywheres” are virtual machines now.

So there’s a lot more to it than, “Parrot has deficiencies”. Even if Parrot had worked out incredibly efficient, getting Perl 6 onto other runtimes would still have been important. The JVM should give us a speed boost for a bunch of workloads. The numbers so far are encouraging. Startup time, on the other hand, is pretty awful. I doubt we can ever get that really low on the JVM.

But perhaps the most important thing for the Perl 6 project overall is that the JVM has very well tested, battle-hardened threads support. We really, really need to nail down those aspects of Perl 6. Once the porting is over, that’s where I expect a lot of my focus will go. So, the JVM support helps fill in a bunch of the puzzle pieces.

Nikos Vaggalis:Work on the JVM port is successful and well underway, so why are we already looking at a new VM, MoarVM?

Jonathan Worthington:10 years of development led by different architects at different periods of time (each of them with good ideas, I should add) led to a fair amount of baggage, as it would in any software project. With some quiet encouragement from others, I started considering what it would take to take the 6model design and put an “r” in it. So that’s where the name comes from: Moar = Metamodel On A Runtime. MoarVM is a place where we’ll be able to do “native” implementations of various Perl 6 constructs, with the idea being that a very close semantic match can lead to efficiency.

Additionally, there will be people who want to use Perl 6, but who really don’t want to use the JVM to run it. Maybe they don’t want the overhead, maybe they don’t like it, maybe they are doing one-liners or other things where you mostly care for start-up time.

So at that time we witnessed MoarVM's baby steps and it looks like that it was this VM that won Rakudo's heart as the Rakudo Perl 6 compiler released this Christmas is not fully functional with the JVM backend and users are recommended to use the MoarVM backend only.

Of course let's not forget about Niesza, the attempt to port Perl 6 on the .NET platform. For more on this check out the interview with Stephan O'Rear Niecza - Perl 6 Implemented in .NET, which has also been used as the basis for demanding Visual Studio to support Perl6 on Windows, something that would enable intellisense and debugger support.

There is also Perlito, aka MiniPerl6, which is a subset of Perl 6, designed as a light bootstrapping language,which can amongst others translate Perl6 to Javascript thus having Perl in the browser

(For more information check the All about Perl 6 – interview of Flávio Glock)

There is detailed information on the differences between
the Perl6 compilers and the available VM's on the Feature Comparison web page.

Perl 6 vs Perl 5

Larry Wall sees Perl 6 as the chance to correct everything done wrong in Perl 5.

This means that Perl 6 has been designed to be easier to parse, in contrast to the Perl 5 saying of 'only Perl can parse Perl'. Also Perl 6 has been designed with Object Orientation from ground up,
also mixing in a functional programming flavor, rather than the way in which Perl's 5 object oriented support which was patched in as an afterthought.

Furthermore Perl 6 is a different language from Perl 5 and not a new version of it, despite borrowing many aspects from, like being easy to learn, get things done quickly and there being more than one way to do things.

As far as implementation is concerned, and according to Moritz Lenz, another main contributor to Perl, Perl 6 in contrast to Perl 5 has multiple implementations like Rakudo and Niecza, with Rakudo running on JVM and MoarVM while Niecza on CLR/.NET. Perl 5 is tied to C and XS, whereas the Perl 6 compiler writers have more freedom in the choice of backends. Perl 5 compiles a program to bytecode, but always keeps that in memory, but Rakudo can compile to bytecode and store it on disc.

Syntax wise,if you know Perl 5, Perl 6 feels familiar, but under the hood a lot has changed.

For example counting the elements of an array -
in Perl5 is done with : array $#array+1 or scalar(@array)
in Perl6 it becomes more like: @array.elems
treating the array as an object with elems as its property

| and & as infix operators now construct junctions. The binary AND and binary OR operators are split into string and numeric operators, that is ~& is binary string AND, +& is binary numeric AND, ~| is binary string OR etc. 

   Perl5: $foo & 1;
Perl6: $foo +& 1;

The assignment operators have been changed in a similar vein:

   Perl5: $foo <<= 42;
   Perl6: $foo +<= 42;

Parenthesis don't construct lists, they merely group.

Lists are constructed with the comma operator. It has tighter precedence than the list assignment operator, which allows you to write lists on the right hand side without parens:

    my @list = 1, 2, 3; 
# @list really has three elements

(Source : Perl6::Perl5::Differences -- Differences between Perl 5 and Perl 6)

Perl6 language features

There is new data types, pairs, junctions, and control structures,
introspection through the Meta Object protocol, Roles which can be used for composition and/or Java like Interfaces,Traits,Lazy lists and much more 

Special mention deserve the new regular expression engine,as Moritz Lenz explains it:   

Perl 6 regexes are somewhat of a mixture of traditional regexes (for lexing), and a BNF-like structure for parsing. In Perl 6 regexes, a regex is a method on the grammar, and you can call other regexes just as you can call other methods in normal code and you can use all the usual code reuse mechanisms, like calling other grammars ( basically delegation), inheritance, and role composition.

And more than that, it provides you with a way to trigger actions that are tied to grammar rules. So for each grammar rule, a method in a corresponding "actions" class is triggered, and that makes it easy to create a syntax tree right away

Mutable grammar allows the language you are parsing to add a new operator, and immediately use them. It also means that it is easy to create a dialect of grammar. For example, if you have a grammar for JSON, it is trivial to override the whitespace rule, and make it accept comments too (which aren't part of standard JSON). 

It certainly looks like a very exciting start to a new programming age.


 



Last Updated ( Monday, 28 December 2015 )