Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 History  



1.1  Initial goals and implications  





1.2  Mascot  







2 Implementations  



2.1  Historical implementations  







3 Module system  





4 Books  



4.1  Books published before Perl 6 version 1.0 (known as version 6.c)  





4.2  Books published after Perl 6 version 1.0 (known as version 6.c)  





4.3  Books published with the new Raku name  







5 References  





6 External links  














Raku (programming language): Difference between revisions






Български
Čeština
Deutsch
Español
Français

Bahasa Indonesia
Italiano
Nederlands

Norsk bokmål
Русский
Suomi
Türkçe
Українська

 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikibooks
 
















Appearance
   

 





Help
 

From Wikipedia, the free encyclopedia
 


Browse history interactively
 Previous edit
Content deleted Content added
m Now in Pygments, "raku" is an alias of "perl6"
AnomieBOT (talk | contribs)
6,352,178 edits
Rescuing orphaned refs ("syn01" from rev 1227055593)
 
(20 intermediate revisions by 14 users not shown)
Line 32: Line 32:


==History==

==History==

{{Quotation|text=In Perl 6, we decided it would be better to fix the language than fix the user.|author=Larry Wall<ref>{{cite book|title=Masterminds of Programming: Conversations with the Creators of Major Programming Languages|first1=Federico|last1=Biancuzzi|first2=Shane|last2=Warden|year=2009|isbn=978-0596515171}}</ref>}}

{{Quotation|text=In Perl 6, we decided it would be better to fix the language than fix the user.|author=Larry Wall<ref>{{cite book|title=Masterminds of Programming: Conversations with the Creators of Major Programming Languages|first1=Federico|last1=Biancuzzi|first2=Shane|last2=Warden|year=2009|publisher="O'Reilly Media, Inc." |isbn=978-0596515171|url=https://books.google.com/books?id=yB1WwURwBUQC&q=%22In%20Perl%206%2C%20we%20decided%20it%20would%20be%20better%20to%20fix%20the%20language%20than%20fix%20the%20user%22}}</ref>}}



The Raku design process was first announced on 19 July 2000, on the fourth day of that year's [[O'Reilly Open Source Convention|Perl Conference]],<ref>{{cite web | title=Report from the Perl Conference | url=http://www.perl.com/pub/a/2000/08/tpc4.html | author=Kline, Joe | date=2000-08-21 }}</ref> by [[Larry Wall]] in his ''[[Perl#State of the Onion|State of the Onion]] 2000'' talk.<ref>{{cite web | title=State of the Onion 2000 | author=Wall, Larry | publisher=O'Reilly Network | url=http://www.perl.com/pub/a/2000/10/23/soto2000.html | year=2000 | author-link=Larry Wall}}</ref> At that time, the primary goals were to remove "historical warts" from the language; "easy things should stay easy, hard things should get easier, and impossible things should get hard"; a general cleanup of the internal design and [[Application programming interface|APIs]]. The process began with a series of [[Request for Comments|requests for comments]] or "RFCs". This process was open to all contributors, and left no aspect of the language closed to change.<ref>{{cite web | title=About Perl 6 RFCs | author=The Perl Foundation | url=https://raku.org/archive/rfc/meta/ | year=2000}}</ref>

The Raku design process was first announced on 19 July 2000, on the fourth day of that year's [[O'Reilly Open Source Convention|Perl Conference]],<ref>{{cite web | title=Report from the Perl Conference | url=http://www.perl.com/pub/a/2000/08/tpc4.html | author=Kline, Joe | date=2000-08-21 }}</ref> by [[Larry Wall]] in his ''[[Perl#State of the Onion|State of the Onion]] 2000'' talk.<ref>{{cite web | title=State of the Onion 2000 | author=Wall, Larry | publisher=O'Reilly Network | url=http://www.perl.com/pub/a/2000/10/23/soto2000.html | year=2000 | author-link=Larry Wall}}</ref> At that time, the primary goals were to remove "historical warts" from the language; "easy things should stay easy, hard things should get easier, and impossible things should get hard"; and a general cleanup of the internal design and [[Application programming interface|APIs]]. The process began with a series of [[Request for Comments|requests for comments]] or "RFCs". This process was open to all contributors, and left no aspect of the language closed to change.<ref>{{cite web | title=About Perl 6 RFCs | author=The Perl Foundation | url=https://raku.org/archive/rfc/meta/ | year=2000}}</ref>



Once the RFC process was complete, Wall reviewed and classified each of the 361 requests received. He then began the process of writing several "Apocalypses", using the original meaning of the term, "revealing".<ref name="apoc1">{{cite web | url=https://raku.org/archive/doc/design/apo/A01.html | title=Apocalypse 1: The Ugly, the Bad, and the Good | author=Wall, Larry | date=2001-04-02}}</ref> While the original goal was to write one Apocalypse for each chapter of ''[[Programming Perl]]'', it became obvious that, as each Apocalypse was written, previous Apocalypses were being invalidated by later changes. For this reason, a set of Synopses were published, each one relating the contents of an Apocalypse, but with any subsequent changes reflected in updates. Today, the Raku specification is managed through the "roast" testing suite,<ref>{{cite web | title=Raku test suite | website=[[GitHub]] | url=https://github.com/Raku/roast | year=2019}}</ref> while the Synopses are kept as a historical reference.<ref name="syn">{{cite web | author=Larry Wall and the Perl 6 designers | title= Perl 6 Design Documents| url=https://design.raku.org/ | year=2015}}</ref>

Once the RFC process was complete, Wall reviewed and classified each of the 361 requests received. He then began the process of writing several "Apocalypses", using [[wikt:apocalypsis#English|the original meaning of the term]], "revealing".<ref name="apoc1">{{cite web | url=https://raku.org/archive/doc/design/apo/A01.html | title=Apocalypse 1: The Ugly, the Bad, and the Good | author=Wall, Larry | date=2001-04-02}}</ref> While the original goal was to write one Apocalypse for each chapter of ''[[Programming Perl]]'', it became obvious that, as each Apocalypse was written, previous Apocalypses were being invalidated by later changes. For this reason, a set of Synopses was published, each one relating the contents of an Apocalypse, but with any subsequent changes reflected in updates. Today, the Raku specification is managed through the "roast" testing suite,<ref>{{cite web | title=Raku test suite | website=[[GitHub]] | url=https://github.com/Raku/roast | year=2019}}</ref> while the Synopses are kept as a historical reference.<ref name="syn">{{cite web | author=Larry Wall and the Perl 6 designers | title= Perl 6 Design Documents| url=https://design.raku.org/ | year=2015}}</ref>



There are also a series of Exegeses written by [[Damian Conway]] that explain the content of each Apocalypse in terms of practical usage. Each Exegesis consists of code examples along with discussion of the usage and implications of the examples.<ref name="exegeses">{{cite web | url=https://raku.org/archive/doc/exegesis.html | title=Exegeses | author=The Perl Foundation | year=2001}}</ref>

There is also a series of [[wikt:exegesis#English|Exegeses]] written by [[Damian Conway]] that explain the content of each Apocalypse in terms of practical usage. Each Exegesis consists of code examples along witha discussion of the usage and implications of the examples.<ref name="exegeses">{{cite web | url=https://raku.org/archive/doc/exegesis.html | title=Exegeses | author=The Perl Foundation | year=2001}}</ref>



There are three primary methods of communication used in the development of Raku today. The first is the raku [[Internet Relay Chat|IRC channel]] on [[Libera Chat]]. The second is a set of [[mailing list]]s.<ref name="lists">{{cite web | title=Raku Community | author=The Raku Programming Language | url=https://raku.org/archive/lists/ | year=2022}}</ref> The third is the [[Git (software)|Git]] [[source code repository]] hosted at [[GitHub]].<ref>{{cite web | title=Raku | website=GitHub | url=https://github.com/raku | access-date=2022-08-19 }}</ref>

There are three primary methods of communication used in the development of Raku today. The first is the raku [[Internet Relay Chat|IRC channel]] on [[Libera Chat]]. The second is a set of [[mailing list]]s.<ref name="lists">{{cite web | title=Raku Community | author=The Raku Programming Language | url=https://raku.org/archive/lists/ | year=2022}}</ref> The third is the [[Git (software)|Git]] [[source code repository]] hosted at [[GitHub]].<ref>{{cite web | title=Raku | website=GitHub | url=https://github.com/raku | access-date=2022-08-19 }}</ref>



===Initial goals and implications===

===Initial goals and implications===

The major goal Wall suggested in his initial speech was the removal of historical warts. These included the confusion surrounding [[sigil (computer programming)|sigil]] usage for containers, the ambiguity between the <code>select</code> functions, and the syntactic impact of bareword [[filehandle]]s. There were many other problems that Perl programmers had discussed fixing for years that were explicitly addressed by Wall in his speech.{{citation needed|date=July 2019}}

The major goal Wall suggested in his initial speech was the removal of historical warts. These included the confusion surrounding [[sigil (computer programming)|sigil]] usage for containers, the ambiguity between the <code>select</code> functions, and the syntactic impact of bareword [[filehandle]]s. There were many other problems that Perl programmers had discussed fixing for years, and these were explicitly addressed by Wall in his speech.{{citation needed|date=July 2019}}



An implication of these goals was that Perl 6 would not have [[backward compatibility]] with the existing Perl codebase. This meant that some code which was correctly interpreted by a Perl 5 compiler would not be accepted by a Perl 6 compiler. Since backward compatibility is a common goal when enhancing software, the breaking changes in Perl 6 had to be stated explicitly. The distinction between Perl 5 and Perl 6 became so large that eventually Perl 6 was renamed Raku.

An implication of these goals was that Perl 6 would not have [[backward compatibility]] with the existing Perl codebase. This meant that some code which was correctly interpreted by a Perl 5 compiler would not be accepted by a Perl 6 compiler. Since backward compatibility is a common goal when enhancing software, the breaking changes in Perl 6 had to be stated explicitly. The distinction between Perl 5 and Perl 6 became so large that eventually Perl 6 was renamed Raku.

Line 74: Line 74:


==Implementations==

==Implementations==

{{As of|2017}}, only the [[Rakudo]] implementation is under active development. No implementation will be designated as the official Raku implementation; rather, "Raku is anything that passes the official test suite."<ref name="syn01" />

{{As of|2017}}, only the [[Rakudo]] implementation is under active development. No implementation will be designated as the official Raku implementation; rather, "Raku is anything that passes the official test suite."<ref name="syn01">{{cite web | url=https://design.raku.org/S01.html | title=Synopsis 1: Overview | author=Wall, Larry | date=2004-08-10 }}</ref>



Rakudo Perl 6<ref>{{cite web|url=https://github.com/rakudo/rakudo/ |title=rakudo/rakudo - GitHub |publisher=Github.com |access-date=2013-09-21}}</ref><ref>{{cite web | url=http://use.perl.org/~pmichaud/journal/35400 | title=The compiler formerly known as 'perl6' | author=Michaud, Patrick | date=2008-01-16 | url-status=dead | archive-url=https://web.archive.org/web/20120218080103/http://use.perl.org/~pmichaud/journal/35400 | archive-date=2012-02-18 }}</ref> targets a number of virtual machines, such as [[MoarVM]], the [[Java virtual machine|Java Virtual Machine]], and [[JavaScript]]. MoarVM is a [[virtual machine]] built especially for Rakudo<ref>{{cite web |last = Worthington |first = Jonathan |title = MoarVM: A virtual machine for NQP and Rakudo |url = http://6guts.wordpress.com/2013/05/31/moarvm-a-virtual-machine-for-nqp-and-rakudo/ |work = 6guts |date = 31 May 2013 |access-date = 24 July 2013 }}</ref> and the NQP Compiler Toolchain.<ref>{{Cite web | url = https://github.com/Raku/nqp | title = NQP - Not Quite Perl at github | website = [[GitHub]] | date = 2022-05-29 | access-date = 2022-05-29}}</ref> There is a layer between Raku and the virtual machines called Not Quite Perl 6, or NQP, which implements [[Raku rules]] for parsing Raku, as well as an [[abstract syntax tree]] and backend-specific [[Code generation (compiler)|code generation]]. Large portions of Rakudo are written in Raku itself, or in its subset NQP. Rakudo is not a completely [[Self-hosting (compilers)|self-hosting implementation]], nor are there concrete plans at this point to make Rakudo a bootstrapping compiler.

Rakudo Perl 6<ref>{{cite web|url=https://github.com/rakudo/rakudo/ |title=rakudo/rakudo - GitHub |publisher=Github.com |access-date=2013-09-21}}</ref><ref>{{cite web | url=http://use.perl.org/~pmichaud/journal/35400 | title=The compiler formerly known as 'perl6' | author=Michaud, Patrick | date=2008-01-16 | url-status=dead | archive-url=https://web.archive.org/web/20120218080103/http://use.perl.org/~pmichaud/journal/35400 | archive-date=2012-02-18 }}</ref> targets a number of virtual machines, such as [[MoarVM]], the [[Java virtual machine|Java Virtual Machine]], and [[JavaScript]]. MoarVM is a [[virtual machine]] built especially for Rakudo<ref>{{cite web |last = Worthington |first = Jonathan |title = MoarVM: A virtual machine for NQP and Rakudo |url = http://6guts.wordpress.com/2013/05/31/moarvm-a-virtual-machine-for-nqp-and-rakudo/ |work = 6guts |date = 31 May 2013 |access-date = 24 July 2013 }}</ref> and the NQP Compiler Toolchain.<ref>{{Cite web | url = https://github.com/Raku/nqp | title = NQP - Not Quite Perl at github | website = [[GitHub]] | date = 2022-05-29 | access-date = 2022-05-29}}</ref> There is a layer between Raku and the virtual machines called Not Quite Perl 6, or NQP, which implements [[Raku rules]] for parsing Raku, as well as an [[abstract syntax tree]] and backend-specific [[Code generation (compiler)|code generation]]. Large portions of Rakudo are written in Raku itself, or in its subset NQP. Rakudo is not a completely [[Self-hosting (compilers)|self-hosting implementation]], nor are there concrete plans at this point to make Rakudo a [[Bootstrapping_(compilers)|bootstrapping compiler]].



===Historical implementations===

===Historical implementations===

Line 99: Line 99:


[[CPAN]], the Perl module distribution system, does not yet handle Raku modules. Instead a prototype module system is in use.<ref>{{cite web|url=https://modules.raku.org/ |title=Perl 6 Modules Directory |publisher=Modules.raku.org |access-date=2020-05-17}}</ref>

[[CPAN]], the Perl module distribution system, does not yet handle Raku modules. Instead a prototype module system is in use.<ref>{{cite web|url=https://modules.raku.org/ |title=Perl 6 Modules Directory |publisher=Modules.raku.org |access-date=2020-05-17}}</ref>


==Major changes from Perl==

Perl and Raku differ fundamentally, though in general the intent has been to "keep Raku Perl", so that Raku is clearly "a Perl programming language". Most of the changes are intended to normalize the language, to make it easier for novice and expert programmers alike to understand, and to make "easy things easier and hard things more possible".


===A specification===

A major non-technical difference between Perl and Raku is that Raku began as a specification.<ref name="syn01">{{cite web | url=https://design.raku.org/S01.html | title=Synopsis 1: Overview | author=Wall, Larry | date=2004-08-10 }}</ref> This means that Raku can be re-implemented if needed, and it also means that programmers do not have to read the [[source code]] for the ultimate authority on any given feature. In contrast, in Perl, the official documentation is not considered authoritative and only describes the behavior of the actual Perl interpreter informally. Any discrepancies found between the documentation and the implementation may lead to either being changed to reflect the other, a dynamic which drives the continuing development and refinement of the Perl releases.


===A type system===

In Raku, the [[Dynamic type|dynamic type system]] of Perl has been augmented by the addition of [[static type]]s.<ref name="syn2">{{cite web | url=https://design.raku.org/S02.html | title=Synopsis 2: Bits and Pieces | author=Wall, Larry | date=2009-05-20 }}</ref> For example:

<syntaxhighlight lang="raku">

my Int $i = 0;

my Rat $r = 3.142;

my Str $s = "Hello, world";

</syntaxhighlight>

However, static typing remains [[Type system#Combining static and dynamic type checking|optional]], so programmers can do most things without any explicit typing at all:

<syntaxhighlight lang="raku">

my $i = "25" + 10; # $i is 35

</syntaxhighlight>


Raku offers a [[gradual typing]] system, whereby the programmer may choose to use static typing, use dynamic typing, or mix the two.


===Formal subroutine parameter lists===

Perl defines subroutines without [[parameter (computer science)|formal parameter]] lists at all (though simple parameter counting and some type checking can be done using Perl's "prototypes"). Subroutine arguments passed in are aliased into the elements of the array <code>@_</code>. If the elements of <code>@_</code> are modified, the changes are reflected in the original data.


Raku introduces true formal parameters to the language.<ref name="syn6">{{cite web | url=https://design.raku.org/S06.html | title=Synopsis 6: Subroutines | author=Wall, Larry | date=2003-03-21 }}</ref> In Raku, a subroutine declaration looks like this:

<syntaxhighlight lang="raku">

sub do_something(Str $thing, Int $other) {

...

}

</syntaxhighlight>

As in Perl, the formal parameters (i.e., the variables in the parameter list) are aliases to the actual parameters (the values passed in), but by default, the aliases are [[constant (programming)|constant]] so they cannot be modified. They may be declared explicitly as read-write aliases for the original value or as copies using the <code>is rw</code> or <code>is copy</code> directives respectively should the programmer require them to be modified locally.


====Parameter passing modes====

Raku provides three basic modes of parameter passing: positional parameters, [[named parameter]]s, and slurpy parameters.


Positional parameters are the typical ordered list of parameters that most programming languages use. All parameters may also be passed by using their name in an unordered way. Named-only parameters (indicated by a <code>:</code> before the parameter name) can only be passed by specifying its name, i.e. it never captures a positional argument. Slurpy parameters (indicated by an <code>*</code> before the parameter name) are Raku's tool for creating [[variadic function]]s. A slurpy hash will capture remaining passed-by-name parameters, whereas a slurpy array will capture remaining passed-by-position parameters.


Here is an example of the use of all three parameter-passing modes:


<syntaxhighlight lang="raku">

sub somefunction($a, $b, :$c, :$d, *@e) {

...

}


somefunction(1, 2, :d(3), 4, 5, 6); # $a=1, $b=2, $d=3, @e=(4,5,6)

</syntaxhighlight>


Positional parameters, such as those used above, are always required unless followed by <code>?</code> to indicate that they are optional. Named parameters are optional by default, but may be marked as required by adding <code>!</code> after the variable name. Slurpy parameters are ''always'' optional.


====Blocks and closures====

Parameters can also be passed to arbitrary blocks, which act as [[Closure (computer science)|closures]]. This is how, for example, <code>for</code> and <code>while</code> loop iterators are named. In the following example, a list is traversed, 3 elements at a time, and passed to the loop's block as the variables, <code>$a, $b, $c</code>.<ref name="syn04">{{cite web | url=https://design.raku.org/S04.html | title=Synopsis 4: Blocks and Statements | author=Wall, Larry | date=2009-05-20 }}</ref>

<syntaxhighlight lang="raku">

for @list -> $a, $b, $c {

...

}

</syntaxhighlight>

This is generally referred to as a "pointy sub" or "pointy block", and the arrow behaves almost exactly like the <code>sub</code> keyword, introducing an anonymous closure (or anonymous subroutine in Perl terminology).<ref name="syn6"/>


===Sigil invariance===

In Perl, [[Sigil (computer programming)|''sigils'']] &ndash; the punctuation characters that precede a variable name &ndash; change depending on how the variable is used:

# Perl code

<!--Can't use tag "source lang" because of colorized emphasis on sigil-->

my {{font color|red|@}}array = ('a', 'b', 'c');

my $element = {{font color|red|$}}array[1]; # $element equals 'b',

my @extract = {{font color|red|@}}array[1, 2]; # @extract equals ('b', 'c')

my $element = {{font color|red|@}}array[1]; # 'b' comes with a warning (5.10 option)


In Raku, sigils are invariant, which means that they do not change based on whether it is the array or the array element that is needed:<ref name="syn2"/>

<!--Can't use tag "source lang" because of colorized emphasis on sigil-->

# Raku code

my {{font color|red|@}}array = 'a', 'b', 'c';

my $element = {{font color|red|@}}array[1]; # $element equals 'b'

my @extract = {{font color|red|@}}array[1]; # @extract equals ('b')

my @extract = {{font color|red|@}}array[1, 2]; # @extract equals ('b', 'c')


The variance in Perl is inspired by number agreement in English and many other natural languages:


"'''This''' apple." # $a CORRECT

"'''These''' apples." # @a CORRECT

"'''This''' third apple." # $a[3] CORRECT

"'''These''' third apple." # @a[3] WRONG


However, this conceptual mapping breaks down when using [[Reference (computer science)|references]], since they may refer to data structures even though they are scalars. Thus, dealing with nested data structures may require an expression of both singular and plural form in a single term:


<!-- compare the following two code blocks by using the same style syntax-->

<syntaxhighlight lang="perl">

# Perl code: retrieve a list from the leaf of a hash containing hashes that contain arrays

my @trans_verbs = @{ $dictionary{ 'verb' }{ 'transitive' } };

</syntaxhighlight>


This complexity has no equivalent either in common use of natural language or in other programming languages,{{dubious|date=October 2015}} and it causes high [[cognitive load]] when writing code to manipulate complex data structures. This is the same code in Raku:

<syntaxhighlight lang="raku">

# Raku code: retrieve a list from the leaf of a hash containing hashes that contain arrays

my @trans_verbs = %dictionary<verb><transitive><>;

</syntaxhighlight>


===Object-oriented programming===

Perl supports [[object-oriented programming]] via a mechanism known as ''blessing''. Any reference can be blessed into being an object of a particular class. A blessed object can have [[method (computer science)|method]]s invoked on it using the "arrow syntax" which will cause Perl to locate or "dispatch" an appropriate [[subroutine]] by name, and call it with the blessed variable as its first argument.


While extremely powerful, it makes the most common case of object orientation, a [[struct]]-like object with some associated code, unnecessarily difficult. In addition, because Perl can make no assumptions about the [[object model]] in use, method invocation cannot be optimized very well.


In the spirit of making the "easy things easy and hard things possible", Raku retains the blessing model and supplies a more robust object model for the common cases.<ref>{{cite web | url=https://design.raku.org/S12.html | title=Synopsis 12: Objects | author=Wall, Larry | date=2006-08-18 }}</ref> For example, a class to encapsulate a [[Cartesian coordinate system|Cartesian]] [[point (geometry)|point]] could be defined and used this way:

<syntaxhighlight lang="raku">

class Point is rw {

has $.x;

has $.y;

method distance( Point $p ) {

sqrt(($!x - $p.x) ** 2 + ($!y - $p.y) ** 2)

}

method distance-to-center {

self.distance: Point.new(x => 0, y => 0)

}

}


my $point = Point.new( x => 1.2, y => -3.7 );

say "Point's location: (", $point.x, ', ', $point.y, ')';

# OUTPUT: Point's location: (1.2, -3.7)


# Changing x and y (note methods "x" and "y" used as lvalues):

$point.x = 3;

$point.y = 4;

say "Point's location: (", $point.x, ', ', $point.y, ')';

# OUTPUT: Point's location: (3, 4)


my $other-point = Point.new(x => -5, y =>10);

$point.distance($other-point); #=>10

$point.distance-to-center; #=>5

</syntaxhighlight>

The dot replaces the arrow in a nod to the many other languages (e.g. [[C++]], [[Java (programming language)|Java]], [[Python (programming language)|Python]], etc.) that have coalesced around dot as the syntax for method invocation.


In the terminology of Raku, <code>$.x</code> is called an "attribute". Some languages call these ''fields ''or ''members''. The method used to access an attribute is called an "accessor". An auto-accessor method is a method created automatically and named after the attribute's name, as the method <code>x</code> is in the example above. These accessor functions return the value of the attribute. When a class or individual attribute is declared with the <code>is rw</code> modifier (short for "read/write"), the auto-accessors can be passed a new value to set the attribute to, or it can be directly assigned to as an [[Value (computer science)#lrvalue|lvalue]] (as in the example). Auto-accessors can be replaced by user-defined methods, should the programmer desire a richer interface to an attribute. Attributes can only be accessed directly from within a class definition via the <code>$!</code> syntax regardless of how the attributes are declared. All other access must go through the accessor methods.


The Raku object system has inspired the [[Moose (Perl)|Moose]] framework that introduces many of Raku's OOP features to Perl.{{clarify|What does perl mean here? Perl5?|date=September 2020}}


====Inheritance, Roles and Classes====

Inheritance is the technique by which an object or type can re-use code or definitions from existing objects or types. For example, a programmer may want to have a standard type but with an extra attribute. Inheritance in other languages, such as Java, is provided by allowing Classes to be sub-classes of existing classes.


Raku provides for inheritance via Classes, which are similar to Classes in other languages, and Roles.


Roles in Raku take on the function of [[Interface (Java)|''interfaces'' in Java]], ''[[mixin]]s'' in Ruby, and ''[[Trait (computer science)|traits]]''<ref>{{cite web | title=Traits | url=http://www.iam.unibe.ch/~scg/Research/Traits/ | author=The Software Composition Group | year=2003 | access-date=22 September 2006 | archive-url=https://web.archive.org/web/20060811170712/http://www.iam.unibe.ch/~scg/Research/Traits/ | archive-date=11 August 2006 | url-status=dead }}</ref> in [[PHP]] and in the [[Smalltalk]] variant [[Squeak]]. These are much like classes, but they provide a safer composition mechanism.<ref>{{cite web| title=Day 18: Roles| url=https://perl6advent.wordpress.com/2009/12/18/day-18-roles/ | year=2009 | first=Jonathan| last=Worthington}}</ref> These are used to perform composition when used with classes rather than adding to their [[Inheritance (computer science)|inheritance]] chain. Roles define nominal types; they provide semantic names for collections of behavior and state. The fundamental difference between a role and a class is that classes can be instantiated; roles are not.<ref>{{cite web | title=The Why of Perl Roles | url=http://www.modernperlbooks.com/mt/2009/04/the-why-of-perl-roles.html | author=chromatic | year=2009 | author-link=chromatic (programmer)}}</ref>


Although Roles are distinct from Classes, it is possible to write Raku code that directly instantiates a Role or uses a Role as a type object, Raku will automatically create a class with the same name as the role, making it possible to transparently use a role as if it were a class.<ref>{{Cite web|url=https://docs.raku.org/language/objects#Automatic_role_punning|title=Object orientation|website=docs.raku.org|access-date=2019-10-24}}</ref>


Essentially, a role is a bundle of (possibly abstract) methods and attributes that can be added to a class without using inheritance. A role can even be added to an individual object; in this case, Raku will create an anonymous subclass, add the role to the subclass, and change the object's class to the anonymous subclass.


For example, a [[Dog]] is a [[Mammal]] because dogs inherit certain characteristics from Mammals, such as [[mammary gland]]s and (through Mammal's parent, [[Vertebrate]]) a [[Vertebral column|backbone]]. On the other hand, dogs also may have one of several distinct types of behavior, and these behaviours may change over time. For example, a Dog may be a [[Pet]], a [[feral|Stray]] (an abandoned pet will acquire behaviours to survive not associated with a pet), or a [[guide dog|Guide]] for the blind (guide dogs are trained, so they do not start life as guide dogs). However, these are sets of additional behaviors that can be added to a Dog. It is also possible to describe these behaviors in such a way that they can be usefully applied to other animals, for example, a [[Cat]] can equally be a Pet or Stray. Hence, Dog and Cat are distinct from each other, while both remain within the more general category Mammal. So Mammal is a Class and Dog and Cat are classes that inherit from Mammal. But the behaviours associated with Pet, Stray, and Guide are Roles that can be added to Classes, or objects instantiated from Classes.

<syntaxhighlight lang="raku">

class Mammal is Vertebrate {

...

}

class Dog is Mammal {

...

}

role Pet {

...

}

role Stray {

...

}

role Guide {

...

}

</syntaxhighlight>

Roles are added to a class or object with the <code>does</code> keyword. In order to show inheritance from a class, there is a different keyword <code>is</code>. The keywords reflect the differing meanings of the two features: role composition gives a class the ''behavior'' of the role, but doesn't indicate that it is truly the ''same thing'' as the role.

<syntaxhighlight lang="raku">

class GuideDog is Dog does Guide {

...

} # Subclass composes role


my $dog = new Dog;

$dog does Guide; # Individual object composes role

</syntaxhighlight>

Although roles are distinct from classes, both are types, so a role can appear in a variable declaration where one would normally put a class. For example, a Blind role for a Human could include an attribute of type Guide; this attribute could contain a Guide Dog, a [[guide horse|Guide Horse]], a Guide Human, or even a Guide Machine.

<syntaxhighlight lang="raku">

class Human {

has Dog $dog; # Can contain any kind of Dog, whether it does the

... # Guide role or not

}

role Blind {

has Guide $guide; # Can contain any object that does the Guide role,

... # whether it is a Dog or something else

}

</syntaxhighlight>


===Regular expressions===

{{Main|Raku rules}}

Perl's [[regular expression]] and string-processing support has always been one of its defining features.<ref>{{cite web | url=http://cslibrary.stanford.edu/108/EssentialPerl.html#re | title=Essential Perl: String Processing with Regular Expressions | author=Parlante, Nick | year=2000}}</ref> Since Perl's pattern-matching constructs have exceeded the capabilities of [[regular language]] expressions for some time,<ref>{{cite web | url=http://www.perl.com/doc/FMTEYEWTK/regexps.html | title=PERL5 Regular Expression Description | author=Christiansen, Tom | year=1996 | quote=Perl's regexps "aren't" -- that is, they aren't "regular" because backreferences per sed and grep are also supported, which renders the language no longer strictly regular | access-date=25 March 2010 | archive-url=https://web.archive.org/web/20100331122815/http://www.perl.com/doc/FMTEYEWTK/regexps.html | archive-date=31 March 2010 | url-status=dead }}</ref> Raku documentation will exclusively refer to them as ''regexes'', distancing the term from the formal definition.


Raku provides a superset of Perl features with respect to regexes, folding them into a larger framework called "[[Raku rules|rules]]" which provide the capabilities of [[Context-sensitive language|context-sensitive]] [[parsing]] formalisms (such as the [[syntactic predicate]]s of [[parsing expression grammar]]s and [[ANTLR]]), as well as acting as a [[Closure (computer science)|closure]] with respect to their [[Scope (programming)|lexical scope]].<ref>{{cite web | url=https://design.raku.org/S05.html | title=Synopsis 5: Regexes and Rules | author=Wall, Larry | date=2009-05-20 }}</ref> Rules are introduced with the <code>rule</code> keyword which has a usage quite similar to subroutine definition. Anonymous rules can also be introduced with the <code>regex</code> (or <code>rx</code>) keyword, or they can simply be used inline as regexps were in Perl via the <code>m</code> (matching) or <code>s</code> (substitute) operators.


In ''Apocalypse 5'', Larry Wall enumerated 20 problems with "current regex culture". Among these were that Perl's regexes were "too compact and 'cute'", had "too much reliance on too few metacharacters", "little support for named captures", "little support for grammars", and "poor integration with 'real' language".<ref>{{cite web | url=https://raku.org/archive/doc/design/apo/A05.html | title=Apocalypse 5: Pattern Matching | author=Wall, Larry | date=2002-06-04 }}</ref>


===Syntactic simplification===<!-- This section is linked from [[Ellipsis]] -->

Some Perl constructs have been changed in Raku, optimized for different syntactic cues for the most common cases. For example, the parentheses (round [[bracket]]s) required in [[control flow]] constructs in Perl are now optional:<ref name="syn04"/>

<syntaxhighlight lang="raku">

if is-true() {

for @array {

...

}

}

</syntaxhighlight>

Also, the <code>,</code> (comma) operator is now a list constructor, so enclosing parentheses are no longer required around lists. The code

<syntaxhighlight lang="raku">

@array = 1, 2, 3, 4;

</syntaxhighlight>

now makes <code>@array</code> an array with exactly the elements '1', '2', '3', and '4'.


===Chained comparisons===

Raku allows comparisons to "chain". That is, a sequence of comparisons such as the following is allowed:

<syntaxhighlight lang="raku">

if 20 <= $temperature <= 25 {

say "Room temperature is between 20 and 25!"

}

</syntaxhighlight>

This is treated as if each left-to-right comparison were performed on its own, and the result is logically combined via the <code>and</code> operation.


===Lazy evaluation===

Raku uses the technique of [[lazy evaluation]] of lists that has been a feature of some [[functional programming]] languages such as [[Haskell (programming language)|Haskell]]:<ref name="syn9">{{cite web | url=https://design.raku.org/S09.html | title=Synopsis 9: Data Structures | author=Wall, Larry | date=2004-09-13 }}</ref>

<syntaxhighlight lang="raku">

@integers = 0..Inf; # integers from 0 to infinity

</syntaxhighlight>

The code above will not crash by attempting to assign a list of infinite size to the array <code>@integers</code>, nor will it hang indefinitely in attempting to expand the list if a limited number of slots are searched.


This simplifies many common tasks in Raku including input/output operations, list transformations, and parameter passing.


===Gather===

Related to lazy evaluation is the construction of lazy lists using <code>gather</code> and <code>take</code>, behaving somewhat like generators in languages like [[Icon (programming language)|Icon]] or [[Python (programming language)|Python]].

<syntaxhighlight lang="raku">

my $squares = lazy gather for 0..Inf {

take $_ * $_;

};

</syntaxhighlight>

<code>$squares</code> will be an infinite list of square numbers, but lazy evaluation of the <code>gather</code> ensures that elements are only computed when they are accessed.


===Junctions===

Raku introduces the concept of ''junctions'': values that are composites of other values.<ref name="syn9"/> In their simplest form, junctions are created by combining a set of values with junctive [[Operator (programming)|operator]]s:

<syntaxhighlight lang="raku">

# Example for | ("any") Junction:

my $color = 'white';

unless $color eq 'white' | 'black' | 'gray' | 'grey' {

die "Color printing not supported\n";

}


# Example for & ("all") Junction:

my $password = 'secret!123';

if $password ~~ /<:alpha>/ & /<:digit>/ & /<:punct>/ {

say "Your password is reasonably secure";

}

</syntaxhighlight>

<code>|</code> indicates a value which is equal to either its left- ''or'' right-hand arguments. <code>&</code> indicates a value which is equal to both its left- ''and'' right-hand arguments. These values can be used in any code that would use a normal value. Operations performed on a junction act on all members of the junction equally, and combine according to the junctive operator. So, <code>("apple"|"banana") ~ "s"</code> would yield <code>"apples"|"bananas"</code>. In comparisons, junctions return a single true or false result for the comparison. "<code>any</code>" junctions return true if the comparison is true for any one of the elements of the junction. "<code>all</code>" junctions return true if the comparison is true for all of the elements of the junction.


Junctions can also be used to more richly augment the type system by introducing a style of [[generic programming]] that is constrained to junctions of types:

<syntaxhighlight lang="raku">

subset Color of Any where RGB_Color | CMYK_Color;

sub get_tint(Color $color, Num $opacity) {

...

}

</syntaxhighlight>


===Macros===

In low-level languages, the concept of [[Macro (computer science)|macros]] has become synonymous with textual substitution of source-code due to the widespread use of the [[C preprocessor]]. However, high-level languages such as [[Lisp programming language|Lisp]] pre-dated C in their use of macros that were far more powerful.<ref>{{cite book | title=Successful Lisp: How to Understand and Use Common Lisp | author=Lamkins, David B. | date=2004-12-08 | publisher=bookfix.com | url=http://psg.com/~dlamkins/sl/chapter20.html | access-date=13 September 2006 | archive-date=12 September 2006 | archive-url=https://web.archive.org/web/20060912113327/http://www.psg.com/~dlamkins/sl/chapter20.html | url-status=dead }}</ref> It is this Lisp-like macro concept that Raku will take advantage of.<ref name="syn6"/> The power of this sort of macro stems from the fact that it operates on the program as a high-level [[data structure]], rather than as simple text, and has the full capabilities of the programming language at its disposal.


A Raku macro definition will look like a subroutine or method definition, and it can operate on unparsed strings, an [[Abstract syntax tree|AST]] representing pre-parsed code, or a combination of the two. A macro definition would look like this:<ref name="macros">{{cite web |url=https://design.raku.org/S06.html#Macros |title=Macros}}</ref>


<syntaxhighlight lang="raku">

macro hello($what) {

quasi { say "Hello { {{{$what}}} }" };

}

</syntaxhighlight>


In this particular example, the macro is no more complex than a C-style textual substitution, but because parsing of the macro parameter occurs before the macro operates on the calling code, diagnostic messages would be far more informative. However, because the body of a macro is executed at [[compile time]] each time it is used, many techniques of [[Optimization (computer science)|optimization]] can be employed. It is even possible to eliminate complex computations from resulting programs by performing the work at compile-time.


===Identifiers===

In Perl, identifier names can use the ASCII alphanumerics and underscores also available in other languages. In Raku, the alphanumerics can include most Unicode characters. In addition, hyphens and apostrophes can be used (with certain restrictions, such as not being followed by a digit). Using hyphens instead of underscores to separate words in a name leads to a style of naming called "[[kebab case]]".


==Examples==

===Hello world===

The [[hello world program]] is a common program used to introduce a language. In Raku, hello world is:

<syntaxhighlight lang="raku">

say 'Hello, world';

</syntaxhighlight>

&mdash; though [[there is more than one way to do it]].


===Factorial===

The [[factorial]] function in Raku, defined in a few different ways:

<syntaxhighlight lang="raku">

# Using recursion (with `if\else` construct)

sub fact( UInt $n --> UInt ) {

if $n == 0 { 1 }

else { $n * fact($n-1) }

}


# Using recursion (with `if` as statement modifier)

sub fact( UInt $n --> UInt ) {

return 1 if $n == 0;

return $n * fact($n-1);

}


# Using recursion (with `when` construct)

sub fact( UInt $n --> UInt ) {

when $n == 0 { 1 }

default { $n * fact($n-1) }

}


# Using the ternary operator

sub fact( UInt $n --> UInt ) {

$n == 0 ?? 1 !! $n * fact($n-1)

}


# Using multiple dispatch

multi fact(0) { 1 }

multi fact( UInt $n --> UInt ) {

$n * fact($n - 1)

}


# Using the reduction metaoperator

sub fact( UInt $n --> UInt ) {

[*] 1..$n

}


# Creating a factorial operator and using the reduction metaoperator

sub postfix:<!>( UInt $n --> UInt ) { [*] 1..$n }


# Using `state` declarator to create a memoized factorial

sub fact( UInt $n --> UInt ) {

state %known = 0 => 1;

return %known{$n} if %known{$n}:exists;

%known{$n} = $n * fact($n-1);

return %known{$n};

}

</syntaxhighlight>


===Quicksort===

[[Quicksort]] is a well-known sorting algorithm. A working implementation{{efn|Unless the implementation does something fancy and mysterious behind the scenes, the maximal possible recursion depth is the length of the list, making this implementation unsuitable for big data. Recursion depth can be limited to <code>log2(list_length)</code> by iterating into the larger of partitions <code>before</code> and <code>after</code>, and only recursing into the smaller partition.}} using the functional programming paradigm can be succinctly written in Raku:

<syntaxhighlight lang="raku">

# Empty list sorts to the empty list

multi quicksort([]) { () }


# Otherwise, extract first item as pivot...

multi quicksort([$pivot, *@rest]) {

# Partition.

my @before = @rest.grep(* before $pivot);

my @after = @rest.grep(* after $pivot);


# Sort the partitions.

flat (quicksort(@before), $pivot, quicksort(@after))

}

</syntaxhighlight>


{{notelist}}


===Tower of Hanoi===

[[Tower of Hanoi]] is often used to introduce recursive programming in computer science. This implementation uses Raku's multi-dispatch mechanism and parametric constraints:

<syntaxhighlight lang="raku">

multi sub hanoi(0, $, $, $) { } # No disk, so do not do anything

multi sub hanoi($n, $a = 'A', $b = 'B', $c = 'C') { # Start with $n disks and three pegs A, B, C

hanoi $n - 1, $a, $c, $b; # firstly move top $n - 1 disks from A to B

say "Move disk $n from peg $a to peg $c"; # then move last disk from A to C

hanoi $n - 1, $b, $a, $c; # lastly move $n - 1 disks from B to C

}

</syntaxhighlight>



== Books ==

== Books ==

In the history of Raku there were two waves of book writing. The first wave followed the initial announcement of Perl 6 in 2000. Those books reflect the state of the design of the language of that time, and contain mostly outdated material. The second wave, that followed the announcement of Version 1.0 in 2015, includes several books that have already been published and some others that are in the process of being written.



=== Books published before Perl 6 version 1.0 (known as version 6.c) ===

=== Books published before Perl 6 version 1.0 (known as version 6.c) ===

* A. Randal, D. Sugalski, L. Totsch. ''Perl 6 and Parrot Essentials'', 1st edition, 2003, {{ISBN|978-0596004996}}

* {{cite book | last=Randal | first=Allison | last2=Sugalski | first2=Dan | last3=Tötsch | first3=Leopold | title=Perl 6 Essentials |edition=1st | publisher=O'Reilly Media | date=2003 | isbn=978-0-596-00499-6}}

* A. Randal, D. Sugalski, L. Totsch. [http://shop.oreilly.com/product/9780596007379.do ''Perl 6 and Parrot Essentials'', Second Edition] 2004. {{ISBN|978-0596007379}}

* {{cite book | last=Randal | first=Allison | last2=Sugalski | first2=Dan | last3=Tötsch | first3=Leopold |url=http://shop.oreilly.com/product/9780596007379.do | title=Perl 6 and Parrot Essentials |edition=2nd | publisher=O'Reilly Media | date=2004 | isbn=978-0-596-00737-9}}

* S. Walters. [http://www.apress.com/us/book/9781590593950 ''Perl 6 Now: The Core Ideas Illustrated with Perl 5.''] 2004. {{ISBN|978-1590593950}}

* {{cite book | last=Walters | first=Scott |url=http://www.apress.com/us/book/9781590593950 | title=Perl 6 Now: The Core Ideas Illustrated with Perl 5 | publisher=Expert's Voice in Open Source | date=2004-12-15 | isbn=978-1-59059-395-0}}

Also, a book dedicated to one of the first Perl 6 virtual machines, Parrot, was published in 2009.

Also, a book dedicated to one of the first Perl 6 virtual machines, Parrot, was published in 2009.

* A. Randal, A. Whitworth. [http://onyxneon.com/books/pir/index.html ''Parrot Developer's Guide: Pir.''] 2009. {{ISBN|978-0977920129}}

* {{cite book | last=Randal | first=Allison | last2=Whitworth | first2=Andrew |url=http://onyxneon.com/books/pir/index.html | title=Parrot Developer's Guide: Pir | publisher=Onyx Neon Press | date=2009-06-15 | isbn=978-0-9779201-2-9}}



=== Books published after Perl 6 version 1.0 (known as version 6.c) ===

=== Books published after Perl 6 version 1.0 (known as version 6.c) ===

* Andrew Shitov. [https://andrewshitov.com/perl6-at-a-glance/ ''Perl 6 at a Glance.''] 2017. {{ISBN|978-90-821568-3-6}} — [https://andrewshitov.com/wp-content/uploads/2020/01/Perl-6-at-a-Glance.pdf download free official PDF] or download it [https://github.com/ash/books/blob/master/Perl%206%20at%20a%20Glance/Perl%206%20at%20a%20Glance.pdf from GitHub]

* {{cite book |first=Andrew |last=Shitov |url=https://andrewshitov.com/perl6-at-a-glance/ |title=Perl 6 at a Glance |date=2017 |isbn=978-90-821568-3-6}}

* Laurent Rosenfeld, Allen B. Downey. [http://shop.oreilly.com/product/0636920065883.do ''Think Perl 6''] 2017. {{ISBN|978-1-4919-8055-2}}

* {{cite book | last=Rosenfeld | first=Laurent | last2=Downey | first2=Allen B. | title=Think Perl 6 | date=2017 | isbn=978-1-4919-8055-2 |url=http://shop.oreilly.com/product/0636920065883.do}}

* {{cite book | last=Merelo | first=J. J. | title=Learning to program with Perl 6: First Steps: Getting into programming without leaving the command line | publisher=Learning to Program with Perl | date=2017-07-09 | isbn=978-1-5217-9578-1 |url=https://github.com/JJ/perl6em/tree/master/docs}}

* Moritz Lenz. [https://www.apress.com/us/book/9781484228982 ''Perl 6 Fundamentals''] 2017. {{ISBN|978-1-4842-2898-2}}

* {{cite book | last=Lenz | first=Moritz | title=Perl 6 Fundamentals | publisher=Apress | date=2017-07-27 | isbn=978-1-4842-2898-2 |url=https://www.apress.com/us/book/9781484228982}}

* J. J. Merelo. [https://github.com/JJ/perl6em/tree/master/docs ''Learning to program with Perl 6: First Steps: Getting into programming without leaving the command line''] 2017. {{ISBN|978-1521795781}}

* Andrew Shitov. [https://www.packtpub.com/application-development/perl-6-deep-dive ''Perl 6 Deep Dive'']. 2017. {{ISBN|978-1-78728-204-9}}

* {{cite book | last=Shitov | first=Andrew | title=Perl 6 Deep Dive | date=2017-09-07 | isbn=978-1-78728-204-9 |url=https://www.packtpub.com/application-development/perl-6-deep-dive}}

* Andrew Shitov. [https://andrewshitov.com/using-perl6/ ''Using Perl 6'']. 2017. {{ISBN|978-90-821568-1-2}} — [https://andrewshitov.com/wp-content/uploads/2020/01/Using-Perl-6.pdf download free official PDF] or download [https://github.com/ash/books/blob/master/Using%20Perl%206/Using%20Perl%206.pdf from GitHub]

* {{cite book | last=Shitov | first=Andrew |url=https://andrewshitov.com/using-perl6/ | title=Using Perl 6 | date=2017 | isbn=978-90-821568-1-2}}

* {{cite book |first=Gabor |last=Szabo |date=3 December 2017 |url=https://leanpub.com/bailador |title=Web Application Development in Perl 6 |publisher=Author}}

* Moritz Lenz. [https://www.apress.com/us/book/9781484232279 ''Searching and Parsing with Perl 6 Regexes''] 2017. {{ISBN|978-1-4842-3228-6}}

* {{cite book | last=Lenz | first=Moritz |url=https://www.apress.com/us/book/9781484232279 | title=Parsing with Perl 6 Regexes and Grammars: A Recursive Descent into Parsing | publisher=Apress | date=2017-12-04 | isbn=978-1-4842-3228-6}}

* [[brian d foy]]. [http://shop.oreilly.com/product/0636920062776.do ''Learning Perl 6''] 2018 {{ISBN|978-1491977682}}

* {{cite book | last=Foy | first=Brian D. | title=Learning Perl 6 | publisher=O'Reilly Media | date=2018 | isbn=978-1-4919-7768-2 |url=http://shop.oreilly.com/product/0636920062776.do}}



=== Books published with the new Raku name ===

=== Books published with the new Raku name ===

* Andrew Shitov. ''[https://andrewshitov.com/2019/10/13/using-raku-the-free-book/ Using Raku]'', 2nd edition, 2019, {{ISBN|978-90-821568-8-1}} — [https://andrewshitov.com/wp-content/uploads/2020/01/Using-Raku.pdf download free official PDF] or download a copy [https://github.com/ash/books/blob/master/Using%20Raku/Using%20Raku.pdf from GitHub]

* {{cite book | last=Shitov | first=Andrew |url=https://andrewshitov.com/2019/10/13/using-raku-the-free-book/ | title=Using Raku: 100 Programming Challenges Solved in the Raku Programming Language |edition=2nd | date=2019-10-13 | isbn=978-90-821568-8-1}}

* Andrew Shitov. ''[https://andrewshitov.com/2019/10/18/raku-one-liners-a-free-book/ Raku One-Liners]'', 2019, {{ISBN|978-90-821568-9-8}} — [https://andrewshitov.com/wp-content/uploads/2020/01/Raku-One-Liners.pdf download free official PDF] or download [https://github.com/ash/books/blob/master/Raku%20One-Liners/Raku%20One%20Liners.pdf from GitHub]

* {{cite book | last=Shitov | first=Andrew |url=https://andrewshitov.com/2019/10/18/raku-one-liners-a-free-book/ | title=Raku One-Liners: Getting the Most of Raku's Expressive Syntax for Your Daily Routines | date=2019-10-18 | isbn=978-90-821568-9-8}}

* {{cite book | last=Lenz | first=Moritz |url=https://link.springer.com/book/10.1007/978-1-4842-6109-5 | title=Raku Fundamentals: A Primer with Examples, Projects, and Case Studies | publisher=Apress | date=2020-09-06 | isbn=978-1-4842-6108-8}}


=== Books to be published ===

There are a few reports<ref>[https://perl6book.com/ Books about Perl 6]</ref> from different authors about the new books that are going to be published soon, all based on the current version 1.0 (known as version 6.c) of Perl 6.

* Andrew Shitov. ''Migrating to Perl 6. An Easy Transition from Perl 5''. {{ISBN|978-90-821568-5-0}}. Probably never to be published.

* Gabor Szabo. [https://leanpub.com/bailador ''Web Application Development in Perl 6''].



==References==

==References==


Latest revision as of 19:47, 4 June 2024

Raku
Camelia, the Raku mascot[1]
ParadigmMulti-paradigm
FamilyPerl
Designed byLarry Wall
DeveloperRaku community
First appeared25 December 2015; 8 years ago (2015-12-25)
Stable release

6.d 'Diwali'[2] / 24 October 2020; 3 years ago (2020-10-24)

Typing disciplineDynamic, gradual
OSCross-platform
LicenseGNU General Public Licenseor Artistic License 2
Filename extensions.raku, .rakumod, .rakudoc, .t, .rakutest[3]
Websiteraku.org
Major implementations
Rakudo
Influenced by
Perl, Ruby, Smalltalk, Haskell,[4] JavaScript
Influenced
Perl,[5] Haskell,[5] AntLang

Raku is a member of the Perl family of programming languages.[6] Formerly known as Perl 6, it was renamed in October 2019.[7][8] Raku introduces elements of many modern and historical languages. Compatibility with Perl was not a goal, though a compatibility mode is part of the specification. The design process for Raku began in 2000.

History[edit]

In Perl 6, we decided it would be better to fix the language than fix the user.

— Larry Wall[9]

The Raku design process was first announced on 19 July 2000, on the fourth day of that year's Perl Conference,[10]byLarry Wall in his State of the Onion 2000 talk.[11] At that time, the primary goals were to remove "historical warts" from the language; "easy things should stay easy, hard things should get easier, and impossible things should get hard"; and a general cleanup of the internal design and APIs. The process began with a series of requests for comments or "RFCs". This process was open to all contributors, and left no aspect of the language closed to change.[12]

Once the RFC process was complete, Wall reviewed and classified each of the 361 requests received. He then began the process of writing several "Apocalypses", using the original meaning of the term, "revealing".[13] While the original goal was to write one Apocalypse for each chapter of Programming Perl, it became obvious that, as each Apocalypse was written, previous Apocalypses were being invalidated by later changes. For this reason, a set of Synopses was published, each one relating the contents of an Apocalypse, but with any subsequent changes reflected in updates. Today, the Raku specification is managed through the "roast" testing suite,[14] while the Synopses are kept as a historical reference.[15]

There is also a series of Exegeses written by Damian Conway that explain the content of each Apocalypse in terms of practical usage. Each Exegesis consists of code examples along with a discussion of the usage and implications of the examples.[16]

There are three primary methods of communication used in the development of Raku today. The first is the raku IRC channelonLibera Chat. The second is a set of mailing lists.[17] The third is the Git source code repository hosted at GitHub.[18]

Initial goals and implications[edit]

The major goal Wall suggested in his initial speech was the removal of historical warts. These included the confusion surrounding sigil usage for containers, the ambiguity between the select functions, and the syntactic impact of bareword filehandles. There were many other problems that Perl programmers had discussed fixing for years, and these were explicitly addressed by Wall in his speech.[citation needed]

An implication of these goals was that Perl 6 would not have backward compatibility with the existing Perl codebase. This meant that some code which was correctly interpreted by a Perl 5 compiler would not be accepted by a Perl 6 compiler. Since backward compatibility is a common goal when enhancing software, the breaking changes in Perl 6 had to be stated explicitly. The distinction between Perl 5 and Perl 6 became so large that eventually Perl 6 was renamed Raku.

Mascot[edit]

Larry Wall and Camelia

The language's mascot is "Camelia, the Raku bug".[1] Her name is a nod to the camel mascot associated with Perl, and her form, in the pun-loving tradition of the Perl community, is a play on "software bug". Spiral designs embedded in her butterfly-like wings resemble the characters "P6", the favored nickname for Perl 6, and off-center eye placement is an intentional pun on "Wall-eyed".[19]

One of the goals behind the lively and colorful design of the logo was to discourage misogyny in the community and for it to be an opportunity for those of "masculine persuasion" to show their sensitive side.[20]

Implementations[edit]

As of 2017, only the Rakudo implementation is under active development. No implementation will be designated as the official Raku implementation; rather, "Raku is anything that passes the official test suite."[21]

Rakudo Perl 6[22][23] targets a number of virtual machines, such as MoarVM, the Java Virtual Machine, and JavaScript. MoarVM is a virtual machine built especially for Rakudo[24] and the NQP Compiler Toolchain.[25] There is a layer between Raku and the virtual machines called Not Quite Perl 6, or NQP, which implements Raku rules for parsing Raku, as well as an abstract syntax tree and backend-specific code generation. Large portions of Rakudo are written in Raku itself, or in its subset NQP. Rakudo is not a completely self-hosting implementation, nor are there concrete plans at this point to make Rakudo a bootstrapping compiler.

Historical implementations[edit]

Pugs was an initial implementation of Perl 6 written in Haskell. Pugs used to be the most advanced implementation of Perl 6, but since mid 2007 it is mostly dormant (with updates made only to track the current version of GHC). As of November 2014 Pugs was not being actively maintained.[26]

In 2007, v6-MiniPerl6 ("mp6") and its reimplementation, v6-KindaPerl6 ("kp6") were written as a means to bootstrap the Perl-6.0.0 STD, using Perl 5. The STD is a full grammar for Perl 6 and is written in Perl 6. In theory, anything capable of parsing the STD and generating executable code is a suitable bootstrapping system for Perl 6. kp6 is currently compiled by mp6 and can work with multiple backends.[27][28] mp6 and kp6 are not full Perl 6 implementations and are designed only to implement the minimum featureset required to bootstrap a full Perl 6 compiler.

Yapsi was a Perl 6 compiler and runtime written in Perl 6 itself. As a result, it required an existing Perl 6 interpreter, such as one of the Rakudo Star releases, in order to run.[29]

Niecza, another major Perl 6 implementation effort, focused on optimization and efficient implementation research. It targets the Common Language Infrastructure.[30]

Module system[edit]

The Raku specification requests that modules be identified by name, version, and authority.[31] It is possible to load only a specific version of a module, or even two modules of the same name that differ in version or authority. As a convenience, aliasing to a short name is provided.

CPAN, the Perl module distribution system, does not yet handle Raku modules. Instead a prototype module system is in use.[32]

Books[edit]

Books published before Perl 6 version 1.0 (known as version 6.c)[edit]

Also, a book dedicated to one of the first Perl 6 virtual machines, Parrot, was published in 2009.

Books published after Perl 6 version 1.0 (known as version 6.c)[edit]

Books published with the new Raku name[edit]

References[edit]

  1. ^ a b Jackson, Joab (23 July 2010). "Perl creator hints at imminent release of long-awaited Perl 6". IDG News Service. Retrieved 8 February 2015.
  • ^ "Announce: Raku Perl 6 'Diwali' 6.d Language Specification Release". blogs.perl.org. Zoffix Znet. 5 November 2018. Retrieved 19 August 2022.
  • ^ "Modules". docs.raku.org. Retrieved 19 August 2022.
  • ^ "Glossary of Terms and Jargon". Perl Foundation Perl 6 Wiki. The Perl Foundation. 28 February 2011. Archived from the original on 21 January 2012. Retrieved 8 February 2015.
  • ^ a b 唐鳳, a.k.a. Audrey Tang (21 April 2010). "How to Implement Perl 6 in '10".
  • ^ "About Perl". perl.org. Retrieved 11 June 2020. "Perl" is a family of languages, "Raku" (formerly known as "Perl 6") is part of the family, but it is a separate language which has its own development team. Its existence has no significant impact on the continuing development of "Perl".
  • ^ "Perl 6 renamed to Raku". LWN.net. 15 October 2019. Retrieved 16 October 2019.
  • ^ "TPF response to Raku rename". 29 October 2019.
  • ^ Biancuzzi, Federico; Warden, Shane (2009). Masterminds of Programming: Conversations with the Creators of Major Programming Languages. "O'Reilly Media, Inc.". ISBN 978-0596515171.
  • ^ Kline, Joe (21 August 2000). "Report from the Perl Conference".
  • ^ Wall, Larry (2000). "State of the Onion 2000". O'Reilly Network.
  • ^ The Perl Foundation (2000). "About Perl 6 RFCs".
  • ^ Wall, Larry (2 April 2001). "Apocalypse 1: The Ugly, the Bad, and the Good".
  • ^ "Raku test suite". GitHub. 2019.
  • ^ Larry Wall and the Perl 6 designers (2015). "Perl 6 Design Documents".{{cite web}}: CS1 maint: numeric names: authors list (link)
  • ^ The Perl Foundation (2001). "Exegeses".
  • ^ The Raku Programming Language (2022). "Raku Community".
  • ^ "Raku". GitHub. Retrieved 19 August 2022.
  • ^ "Larry Wall in IRC chat log". 15 January 2016. Retrieved 10 November 2017.
  • ^ "Archived "Logo considerations" email from Larry Wall". GitHub. 24 March 2009. Retrieved 10 November 2017.
  • ^ Wall, Larry (10 August 2004). "Synopsis 1: Overview".
  • ^ "rakudo/rakudo - GitHub". Github.com. Retrieved 21 September 2013.
  • ^ Michaud, Patrick (16 January 2008). "The compiler formerly known as 'perl6'". Archived from the original on 18 February 2012.
  • ^ Worthington, Jonathan (31 May 2013). "MoarVM: A virtual machine for NQP and Rakudo". 6guts. Retrieved 24 July 2013.
  • ^ "NQP - Not Quite Perl at github". GitHub. 29 May 2022. Retrieved 29 May 2022.
  • ^ "Feature comparison of Perl 6 compilers". Archived from the original on 7 February 2019.
  • ^ Wall, Larry; et al. (2007). "Perl 6 STD". GitHub.
  • ^ "mp6/kp6 FAQ". Perl 6 development team. 2006.
  • ^ "Yapsi README". GitHub. 2011.
  • ^ O'Rear, Stefan (29 November 2011). "Niecza README.pod". GitHub. Retrieved 12 January 2012.
  • ^ Wall, Larry (2004). "Synopsis 11: Modules".
  • ^ "Perl 6 Modules Directory". Modules.raku.org. Retrieved 17 May 2020.
  • External links[edit]


    Retrieved from "https://en.wikipedia.org/w/index.php?title=Raku_(programming_language)&oldid=1227275395"

    Categories: 
    Programming languages
    Raku (programming language)
    Multi-paradigm programming languages
    Cross-platform software
    Free compilers and interpreters
    High-level programming languages
    Scripting languages
    Programming languages created in 2015
    Free software programmed in C
    Hidden categories: 
    CS1 maint: numeric names: authors list
    Articles with short description
    Short description is different from Wikidata
    All articles with unsourced statements
    Articles with unsourced statements from July 2019
    Articles containing potentially dated statements from 2017
    All articles containing potentially dated statements
    Use dmy dates from October 2018
    Articles with example Perl code
     



    This page was last edited on 4 June 2024, at 19:47 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki