Image by Editor (Kanwal Mehreen) | Canva
# Introduction
The Raku Programming Language is a modern, expressive, and versatile language designed with the goal of empowering developers to write clean, flexible, and powerful code. Although it began life as the long-awaited “Perl 6,” Raku has since grown into its own identity — an independent language that retains the creative spirit of Perl while offering a fresh perspective on programming in the 21st century. At its core, Raku embraces the philosophy of developer freedom: it supports multiple paradigms, has a rich type system, and provides advanced tools for text processing, concurrency, and metaprogramming. Rather than being a language for just one niche, Raku aims to be a “toolbox for thinking,” encouraging experimentation and giving programmers multiple paths to express their ideas.
In this article, we will dive into Raku’s origins, explore its defining features, and consider the kinds of projects where it shines.
# A Brief History
Raku’s journey is one of persistence, reinvention, and community-driven innovation. Its story begins in 2000, when Perl creator Larry Wall announced plans for what was then called Perl 6. Rather than a simple update to Perl 5, this was envisioned as a bold reimagining of the language: a chance to rethink programming practices for a new era of computing. Over the next two decades, hundreds of contributors worked on redesigning the language from the ground up, weaving in influences from functional programming, object-oriented design, and modern type systems while staying true to Perl’s famous motto: “There’s more than one way to do it.”
As the language evolved, it became clear that its scope and vision had grown beyond being just the next version of Perl. To acknowledge this independence, the community chose a new name, Raku, in 2019. This renaming marked both a recognition of Raku as a distinct language and an invitation for developers to approach it without the baggage of comparing it solely to Perl. Today, Raku continues to develop under the stewardship of an active, passionate community, maintaining a unique balance of innovation and tradition.
# Key Features of Raku
Let’s take a look at some of the technical aspects of the language. The following are some of the key features of Raku.
// Multi-Paradigm Support
Raku supports multiple programming paradigms, including:
- Procedural (classic step-by-step code)
- Object-Oriented (classes, objects, methods)
- Functional (first-class functions, higher-order functions)
This flexibility lets you write simple scripts or large-scale applications using the paradigm that best fits your needs.
# Procedural
say "Hello, Raku!";
# Object-Oriented
class Animal {
has Str $.name;
method speak { say "$.name makes a sound." }
}
Animal.new(name => "Cat").speak;
# Functional
my @nums = (1, 2, 3, 4);
say @nums.map(* * 2);
Output:
// Concurrency and Parallelism
Concurrency is increasingly important in modern computing, and Raku addresses this need with built-in constructs. Features like Promise
, start
, await
, and Supply
make it easy to write asynchronous code.
For example, you can launch a task in the background and await its result:
my $promise = start {
sleep 2;
"Task done"
};
say await $promise;
// Regular Expressions and Grammars
Raku expands traditional regular expressions with rule-based parsing. In Raku, regular expressions are a first-class feature, and you can also create complete grammars for more advanced text processing.
Here’s an example of a grammar that parses simple CSV data:
grammar CSV {
token TOP { * }
token row { ** ',' \n? }
token cell { <-[,\n]>+ }
} |
// Strong Type System
Raku offers a rich and expressive type system that supports both static and dynamic typing. You can explicitly declare types or let Raku infer them. This gradual typing approach allows you to use types only where needed, which helps make code more robust and easier to manage.
# Static typing
sub greet(Str $name) {
say "Hello, $name!";
}
# Works fine
greet("Alice");
# Type check error at runtime
greet(42);
// Metaprogramming
Raku provides developers with advanced metaprogramming capabilities, enabling programs to generate, inspect, and modify code during execution. It also supports introspection, dynamic code evaluation, and the customization of the language’s syntax and behavior.
Key metaprogramming tools in Raku include:
EVAL
: Dynamically evaluate code strings at runtime- Introspection: Examine types, methods, signatures, attributes, and more
Here’s a simple example using EVAL
to define a subroutine at runtime:
# Define and call a function at runtime
EVAL 'sub dynamic() { say "This was defined dynamically!" }';
dynamic();
Output:
This was defined dynamically!
// Multiple Dispatch
Raku has built-in support for multiple dispatch, meaning you can create several versions of the same function, where each version handles different types or numbers of arguments. This makes your code clearer and safer, as you can handle each case separately. At runtime, Raku automatically selects the function version that best matches the provided arguments.
# Define multiple versions of the same function
multi greet(Str $name) {
say "Hello, $name!";
}
multi greet(Int $times) {
say "Hello!" x $times;
}
greet("Raku");
greet(3);
Output:
Hello, Raku!
Hello!Hello!Hello!
// Junctions
A junction is a construct that represents multiple potential values at once. You can think of it as a logical superposition of values that behaves as if it were all its contained values simultaneously.
The four main types of junctions in Raku are:
any
: Returns true if any of the values satisfy the conditionall
: Returns true only if all values satisfy the conditionnone
: Returns true if none of the values satisfy the conditionone
: Returns true if exactly one value satisfies the condition
my $color="red";
if $color eq any('red', 'green', 'blue') {
say "Valid color!";
}
my $score = 95;
if $score > all(80, 85, 90) {
say "Excellent score!";
}
# Check if exactly one condition is true
say one(True, False, False);
say one(True, True, False);
Output:
# Tooling and Ecosystem
Raku is supported by a growing ecosystem and a set of modern development tools that make it practical and enjoyable to work with.
Key tools and components in the Raku ecosystem include:
- Rakudo: The official and most widely used Raku compiler, actively maintained and regularly updated
- Zef: A module manager for Raku, used to install, test, and manage dependencies
- Read-Eval-Print Loop (REPL): An interactive shell that allows for rapid, real-time experimentation with Raku code
- RakuAST: An abstract syntax tree system being introduced into the language to support code generation and transformation tools
- IDE Support: Raku has plugins and syntax highlighting available for popular editors like VS Code, Vim, Emacs, and others
# Use Cases and Applications
Raku’s versatility and expressiveness make it a great choice for a wide range of programming tasks.
Common use cases include:
- Scripting and Automation: Raku’s concise syntax and built-in shell-friendly features make it perfect for writing scripts that automate system tasks, file processing, or DevOps pipelines
- Data Processing and Text Manipulation: With its advanced regex engine, grammars, and Unicode support, Raku excels at parsing and transforming data from various sources and formats
- Language and Compiler Design: Raku’s grammar system, RakuAST, and metaprogramming features make it a perfect playground for designing new languages, interpreters, or code transformation tools
- Prototyping and Experimentation: Thanks to its interactive REPL and flexible type system, Raku is excellent for testing ideas, teaching programming concepts, or building internal DSLs
# Wrapping Up
Raku stands as a testament to what can be achieved when a programming language is allowed to grow organically, shaped not only by technical necessity but also by creativity and philosophy. It blends the pragmatism of scripting languages with the sophistication of modern type systems, concurrency models, and text-processing capabilities, making it equally well-suited for quick one-off scripts and ambitious long-term projects. While it may not yet have the mainstream popularity of languages like Python or JavaScript, Raku offers something rarer: a language that encourages experimentation, welcomes multiple styles of programming, and continually pushes the boundaries of what expressive coding can look like. For developers who enjoy exploring new paradigms and value flexibility, Raku represents not just a tool but an evolving ecosystem and a community that thrives on innovation.
In short, Raku is less about replacing existing languages and more about offering a new lens through which to think about programming itself.
Jayita Gulati is a machine learning enthusiast and technical writer driven by her passion for building machine learning models. She holds a Master’s degree in Computer Science from the University of Liverpool.