Introduction to Raku

1.1 What is Raku?

Raku is a multi-paradigm, gradually typed, high-level programming language from the Perl family. It was designed by Larry Wall and the community starting in 2000 as "Perl 6", released as language version 6.c at Christmas 2015, and renamed to Raku in 2019 to make clear it's a separate language from Perl 5.

The main implementation is Rakudo, which runs on the MoarVM virtual machine (there are also JVM and experimental JavaScript backends).

Motto: *"-Ofun"* (optimize for fun). The mascot is Camelia the butterfly.

1.2 Key Features

Gradual typing Mix dynamic and static typing; types are optional but enforced when given

First-class, composable parsers built into the language Multiple dispatch

Choose sub/method implementations by signature (types, values, constraints) Unicode-first strings

Grapheme-based (NFG) strings; "👨‍👩‍👧".chars == 1 Rational arithmetic

0.1 + 0.2 == 0.3 is True (Rat by default) Big integers Arbitrary precision Int Infinite sequences and lazy lists

any, all, one, none superpositions Hyper »op«, reduce [op], cross X, zip Z, reverse R

High-level Promises, Supplies (reactive streams), Channels, hyper/race

Classes, roles, MOP, attributes with automatic accessors Blocks that run at specific times (BEGIN, END, ENTER, LEAVE, FIRST, LAST...)

NativeCall (C), Inline::Perl5 (all of CPAN), Inline::Python

1.3 Where Raku Is Used

Text processing, parsing (DSLs, configuration languages, data formats), scripting and automation, data munging, prototyping, education and language research, web services (Cro), bioinformatics, and as a "glue" language with Perl 5 via Inline::Perl5.

1.4 Raku vs Perl vs Python

Invariant (@a[0]) Variant ($a[0]) Dynamic (+ hints) Built-in classes/roles/MOP bless / Moose Rat, big Int by default Floats, big int asyncio/threads (GIL) Slower startup, improving