views:

1303

answers:

23

Perl 6 has really shaped up in terms of which features we can expect to see implemented in the final language, when it comes. Some of them are already available through Perl 6 modules for Perl 5 from CPAN. So which features are most compelling, exciting, nifty, eagerly awaited, etc.?

Please try to limit yourself to one feature per answer.

UPDATE: Added a table of answers, sorted by current votes as of this edit.

Table of Answers (so far):

+10  A: 

Not a feature of Perl 6 (the language) as such, but I am most excited about the Parrot VM.

It will (fingers crossed) allow efficient execution of code in Perl 6 and other dynamic languages, enable them to share libraries, and give the Hotspot VM (the feature of Java I am most excited about) a run for its money.

Thilo
+12  A: 

Lazy lists, in all their varieties. They just make a lot of sense in a lot of circumstances.

Leon Timmermans
+15  A: 

Junctions

Compare

do_something() if $foo == 1 or $foo == 2 or $foo == 4 or $foo == 8

with

do_something() if $foo == any(1,2,4,8)

The latter is better by any standard.

Leon Timmermans
They remind me of Icon's generators. The above in Icon would be: if foo = (1|2|4|8) then do_something()
Hugh Allen
The 1|2|4|8 syntax works in Perl6 also. any(...) is just a little more explicit.
cjm
Both of you are correct, but I'd still say my way of writing is the clearest to people who aren't familiar with the language.
Leon Timmermans
i was reading the spece, isn't qw() replaced with < > ? so it would be if $foo == any(<1 2 4 8>); ?
Ape-inago
+7  A: 

Multimethods (and multisubs)

Multimethods are like methods, except that the method that is run isn't dependent on the run-time type of one variable (aka this), but on multiple. This makes a lot more sense in a lot of situation. Comperators are one, visitor pattern is another.

Leon Timmermans
+17  A: 

Rules. They are regexps on steroids. Being able to break down patterns from a block of line noise to a abstract set of rules is amazingly useful. Not only will it result in code that is more readable and maintainable, but also it will enable easy creation of true domain specific languages (as opposed to evaled hacks).

Leon Timmermans
Rules already work quite well in Rakudo, and you're right, they absolutely rock. I came up with a (basic) working grammar for HTML::Template style templates in 20 minutes or so, and with some practices you can get it a lot faster.
moritz
The `(?(DEFINE)...)` block in 5.10 or better's regexes goes a long way toward the goal of making scrunched-up line-noise patterns into an abstract set of rules. You separate declaration from execution, decouple the ordering issues, and provide alpha(numer)ic identifiers to your named groups, which then act as subroutines. Once you settle into the style, it's very hard to backpeddle back into the line-noise style — which is a *good* thing.
tchrist
+15  A: 

Macros

Perl 6 will have macros in the Lisp sense of the word, not the C sense. True macros that have full access to the language itself. It will enable people to extend the language itself in ways that its creators hadn't foreseen.

In Lisp it was possible because the syntax was so simple (s-expressions), in Perl 6 it will be possible because macros have full access to the rules engine, enabling them to create completely new syntaxes.

Leon Timmermans
C macros fix a problem with the design of C. Lisp/Perl6 macros enhance the language.
Brad Gilbert
+8  A: 

Roles

To some extend roles are similar to Mixins, but with a few differences:

  1. They work during compile time
  2. All roles of a class are applied simultaneously.

This will cause a class to fail graciously if the roles define a conflicting method, unlike mixins where one method just overrides the other.

Leon Timmermans
+15  A: 

Subtypes

For example you could define a subtype

subset EvenNum of Num where { $^n % 2 == 0 }

if you now define a variable of type EvenNum, it can only be assigned even numbers

my EvenNum $foo = 0;
$foo = 1; # TYPE ERROR
Leon Timmermans
+10  A: 

Good Unicode support

Perl 6 will not only support Unicode at bytes and codepoints level but also at the graphemes level, unlike all other current programming languages.

If you think that's not imporant, think of what happens if you reverse a string that contains graphemes that consist of multiple codepoints.

Leon Timmermans
Combining Unicode support with the ability to define your own operators will mean some amazing things for mathematics and engineering. You'll be able to define domain specific operations [b]with the actual character[/b] you'd use on paper.
Robert P
And "good" means *type-safe*. Strings of characters are are one type (`Str`). Sequences of bytes are another type (`Buf`), and the two *don't mix* unless you convert one to the other with the `encode` or `decode` operations. That means it will be *very hard* for `$str1 . $str2` (well, `~` in Perl 6, not `.`) to randomly create gobbledegook, and a lot harder to accidentally read data from the outside world and "just assume" that it's latin1, etc. etc. :)
hobbs
+24  A: 

Grammars. Being able to package together groups of regular expressions (Rules) in a way that is resuable for other projects. Need an SQL parser? We've got a grammar for that. Need to parse CSS? We have one for that too.

mpeters
+13  A: 

Real, honest to goodness OO. And not just OO, OO with a meta model!

mpeters
+12  A: 

Operators. You can declare your own operators (although it makes sense mostly in mathematics and nearby scopes). I like Rules and Grammars, but operators is one of the neat things they allow.

It's not just operator overloading either. C++, Python, Ruby, and others allow you to redefine the existing operators for classes, Perl 6 gives you the ability to create new operators. For example for a matrix x operator, you can define it:

proto infix:<_*_> ( @matrix1, @matrix2 ) { 
    ...
}

And you use them like:

my @matrix3 = @matrix1 _*_ @matrix2;

There are definitely caveats on using these, but the ability to create syntax that makes sense--not just saves typing--is one cool feature.

Axeman
+23  A: 

Parameter lists.

Perl 5's parameter handling is one of its weakest points. You can do some nice things, but it's a lot of work.

Perl 6 will allow named parameters, default values, call-by-value, and call-by-reference with simple but powerful parameter lists.

cjm
+6  A: 

Release date.

Jacek Szymański
Really? I wasn't aware that was planned.
wuputah
That's why it's so exciting.
ijw
A: 

Shipping is a feature, too.

DGentry
Shipping is a feature of an implementation, not of a language. Perl 6 is a language definition, much like C or C++.
moritz
+9  A: 

Extensibility.

Rules+grammars, junctions, good OO and so on are really great features, but the essence of Perl 6 is that it is designed for extensibility. We are no super-heroes, we don't know what the future of programming will look like.

Which is why you can change the grammar, introduce new types, adapt the meaning of operators to these new types, extend core types, introduce new operators, plug in your own OO system, and do basically everything that you need to do to extend and change the language.

Likewise when you introduce a new keyword, you won't break subs or methods of the same (yes, you can call a sub if if you like).

moritz
+11  A: 

Chained Comparisons will be nice, too.

We'll be able to say:

if (0 < $x <= 10) { ...

instead of:

if (0 < $x && $x <= 10) { ...
Adam Bellaire
While I also look forward to this, I can already see the horrible bugs created by switching between Perl 6 and other languages…
zoul
+3  A: 

The Official Perl 6 Wiki. :-) For example, here is its Long Perl 6 Super-Feature List.

OK, my serious answer is November, a wiki implemented in Perl 6. I expect it to eventually lead to a powerful new generation wiki-like {tools and applications}.

(Per an earlier reference to the Parrot VM, there's also an Official Parrot Wiki.)

Conrad Schneiker
+4  A: 

Atomic blocks.

You will be able to run code in the "all or nothing" mode, similar to transactions in the database. And this will be achieved without the need to tamper with some user-managed locks. There will be also the possibility to write a block of code with the "automatic rollback" feature.

Such code must not to change the state of any external entity (no read/write). But if one wants to keep the block running without interruption, can still use the "is critical" trait.

brunorc
+4  A: 

Concurrency.

This is a serious boost in the world of SMP machines. The underlying engine (Software Transactional Memory) is common to atomic blocks and threads - so no user locks, just atomic blocks!

brunorc
+4  A: 

EVERYTHING!!!!!

JDrago
+1  A: 

I won't be able to offer an informed opinion about the more esoteric features until I've had a chance to use them in practice for a while, but right now I can say it would be very nice to have the // and //= operators even in Perl 5. I don't think there's a number large enough to represent the number of times I've typed something like (defined $foo ? $foo : $default).

wisnij
It's in 5.10.0 and on.
ijw
+1  A: 

The hyper meta operator. All the meta operators are cool, but the hyper meta operator is my favorite.

mfollett