raku.gg

[ BACK... ]
By: w1ldc4rd-w1z4rd

What is Raku?


Raku, formerly known as Perl 6, is a flexible and powerful programming language designed for the 21st century. It’s like a Swiss Army knife for coders – versatile, feature-rich, and surprisingly fun to use!

Why Learn Raku?

You might be wondering, “With so many programming languages out there, why should I bother with Raku?” Great question! Here are a few reasons:

  1. Expressiveness: Raku lets you write clean, readable code that almost looks like natural language.
  2. Flexibility: Whether you prefer object-oriented, functional, or procedural programming, Raku’s got you covered.
  3. Powerful features: From advanced regex to concurrent programming, Raku packs a punch.

Your First Raku Program

Let’s dip our toes in with a classic “Hello, World!” program:

say "Hello, World!";

That’s it! Just one line, and you’ve written your first Raku program. Simple, right?

A Taste of Raku’s Power

Now, let’s see something that’ll make your head spin (in a good way!):

my $text = "The quick brown fox jumps over 2 lazy dogs on 2023-05-15!";

if $text ~~ m/
    $<animal> = (\w+) \s+
    <?before jumps>
    .+?
    $<number> = (\d+) \s+
    $<lazy> = ("lazy" \s+ \w+)
    .+?
    $<date> = [\d**4 \- \d**2 \- \d**2]
/ {
    say "Found a jumping {$<animal>} and {$<number>} {$<lazy>}!";
    say "Event date: {$<date>}";
}

Wow, that’s a mouthful! But don’t panic – this is just a sneak peek at Raku’s powerful regex capabilities. Let me break down what this code does:

  1. It searches our text for a specific pattern.
  2. It finds and remembers an animal that’s about to jump.
  3. It captures a number and a phrase about lazy creatures.
  4. It extracts a date in the format YYYY-MM-DD.
  5. Finally, it prints out a summary of what it found.

When you run this code, you’ll see:

Found a jumping fox and 2 lazy dogs!
Event date: 2023-05-15

It’s like giving a supercomputer to a detective – you can find patterns in text that you never thought possible! Don’t worry if the syntax looks alien now. As we progress in our Raku journey, we’ll demystify these regex superpowers bit by bit.

What’s Next?

In the coming weeks, we’ll explore more of Raku’s features, including:

Join the Adventure!

Learning a new programming language is like setting out on an adventure. There will be challenges, but also moments of pure joy when you make something work for the first time.

Remember, every expert was once a beginner. So don’t be afraid to experiment, make mistakes, and ask questions. The Raku community is friendly and always eager to help!

Are you excited to start your Raku journey? What aspects of programming interest you the most? Let me know in the comments below!

Stay curious, keep coding, and see you in the next post! 🚀

WWW: 🐪 perl.gg - 🧙‍♂️ clc.onl - 💾 GitHub - 🏙️ Neocities

Copyright ©️ 2024 raku.gg