This FAQ is part of the
Programmer's Heaven Perl 6 FAQ. It answers questions about moving from Perl 5 to Perl 6.
What is the best way for a Perl 5 programmer to learn Perl 6?
Perhaps one of the best ways is to take small pieces of Perl 5 that you have written and try translating them into Perl 6. That or try solving the kind of problem you would use Perl 5 to solve using Perl 6.
Of course, to get started you will need to read a bit about the new Perl 6 syntax. This
FAQ is one good source of information on the changes, and the Perl 6
specification provide much more detailed information.
There are a number of places to turn to for help. One is the
Perl 6 forum here at Programmer's Heaven. There is also a perl6-users mailing list; you can subscribe by sending an email to:
perl6-users-subscribe@perl.org
Is Perl 6 backward-compatible with Perl 5?
No. Perl 5 has been a popular and successful language and continues to be as Perl 6 develops. However, there are fundamental issues that need to be addressed in the syntax of the language, and staying backwards-compatible with Perl 5 syntax would have greatly restricted the improvements that were possible. Additionally, the Perl 5 interpreter has grown over the years and become difficult to maintain and add to. Therefore a ground-up design and implementation was required.
There are a lot of things that are good about Perl 5, and a lot of the things that are good about it have been retained. Perl 6 is still very much Perl: it's still great for solving the problems you may have used Perl 5 to solve as well as for other problems that Perl 5 was not so well suited to.
Will I be able to use Perl 5 modules with Perl 6?
Yes; this will likely be achieved by embedding a Perl 5 interpreter, which is what Pugs, one of the prototype Perl 6 compilers, does now. The syntax for using a Perl 5 module is:
use perl5:Module::Name;
The name of a language followed by a single colon is the general syntax for using a module from another language, and in the future, with the Parrot VM, it should be possible to name various languages there.
Will there be a Perl 5 to Perl 6 translator?
Yes, this is currently under development. It uses a modified version of the original Perl 5 parser to build a syntax tree and then takes that and generates Perl 6 code from it.
Does Perl 6 always have "use strict;" turned on, unlike Perl 5?
Not always, just more often. One-liners at the command line, where "-e" is used to specify what to execute, will not have strict turned on. However, it will be on by default everywhere else.
Will Perl 6 programs run faster than Perl 5 programs?
There are way too many factors involved in the performance of a program to give a yes or no answer to this. It is safe to say that it will be possible for Perl 6 programs to run somewhat faster than Perl 5 programs. Some of the improvements are:
- It will be possible to compile Perl 6 down to Parrot bytecode, meaning you save on the parse/compile phase at the start of each run.
- Perl 6 has an optional type annotations system, which means you can give the compiler hints that allow it to generate more optimal code.
- The Parrot interpreter includes a JIT compiler, meaning certain types of code (especially code doing intensive math) may well run notably faster than under Perl 5.
- Multi-threaded programming should be much more resource-efficient than Perl 5 is.
However, be aware that the initial releases of Perl 6 will probably focus on correctness over performance, and that the Perl 6 regex engine will take a while to reach the level of optimization that the Perl 5 one has.
Back To FAQ List |
Next Section
What's next?
Join our
Perl 6 Newsletter
Visit our Perl Resources
Originally from the UK, but currently living in Slovakia, Jonathan specializes in programming languages, compilers and virtual machines, but also has plenty of experience of web development too.
Related articles
None found.