CINXE.COM
FAQ | Raku Documentation
<!DOCTYPE html> <html lang="en" class="fontawesome-i2svg-active fontawesome-i2svg-complete" style="scroll-padding-top:60px"> <head> <title>FAQ | Raku Documentation</title> <meta charset="UTF-8" /> <link href="/assets/images/Camelia.ico" rel="icon" type="image/x-icon"/> <link rel="stylesheet" href="/assets/css/Website.css"/> <link rel="stylesheet" href="/assets/css/css/page-styling-main.css"/> <link rel="stylesheet" href="/assets/css/css/page-styling-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/page-styling-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/chyronToggle-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/chyronToggle-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/centreToggle-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/centreToggle-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/typegraph-styling.css"/> <link rel="stylesheet" href="/assets/css/typegraph-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/typegraph-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/listf-styling-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/listf-styling-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/options-search-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/options-search-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/tm-styling.css"/> <link rel="stylesheet" href="/assets/css/tm-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/tm-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/all.min.css"/> <link rel="stylesheet" href="/assets/css/css/rainbow-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/rainbow-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/filtered-toc-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/filtered-toc-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/announce-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/announce-dark.css" title="dark"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/css/autoComplete.min.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-light.min.css" title="light" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css" title="dark" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="/assets/scripts/all.min.js"></script><script src="/assets/scripts/tableManager.js"></script><script src="/assets/scripts/filter-script.js"></script><script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"></script><script src="https://cdn.jsdelivr.net/npm/fuzzysort@2.0.4/fuzzysort.min.js"></script><script src="/assets/scripts/options-search.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/haskell.min.js"></script><script src="/assets/scripts/filtered-toc.js"></script><script src="/assets/scripts/page-styling.js"></script><script src="/assets/scripts/rainbow.js"></script><script src="/assets/scripts/announcements.js"></script> </head> <body class="has-navbar-fixed-top"> <div id="FAQ" class="top-of-page"></div> <nav class="navbar is-fixed-top is-flex-touch" role="navigation" aria-label="main navigation"> <div class="navbar-item" style="margin-left: auto;"> <div class="left-bar-toggle" title="Toggle Table of Contents & Index"> <label class="chyronToggle left"> <input id="navbar-left-toggle" type="checkbox"> <span class="text">Contents</span> </label> </div> </div> <div class="container is-justify-content-space-around"> <div class="navbar-brand"> <div class="navbar-logo"> <a class="navbar-item" href="/"> <img src="/assets/images/camelia-recoloured.png" alt="Raku" width="52.83" height="38"> </a> <span class="navbar-logo-tm">tm</span> </div> <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navMenu"> <span aria-hidden="true"></span> <span aria-hidden="true"></span> <span aria-hidden="true"></span> </a> </div> <div id="navMenu" class="navbar-menu"> <div class="navbar-start"> <a class="navbar-item" href="/introduction" title="Getting started, Tutorials, Migration guides"> Introduction </a> <a class="navbar-item" href="/reference" title="Fundamentals, General reference"> Reference </a> <a class="navbar-item" href="/miscellaneous" title="Programs, Experimental"> Miscellaneous </a> <a class="navbar-item" href="/types" title="The core types (classes) available"> Types </a> <a class="navbar-item" href="/routines" title="Searchable table of routines"> Routines </a> <a class="navbar-item" href="https://raku.org" title="Home page for community"> Raku<sup>®</sup> </a> <a class="navbar-item" href="https://web.libera.chat/#raku" title="IRC live chat"> Chat </a> <div class="navbar-item has-dropdown is-hoverable"> <a class="navbar-link"> More </a> <div class="navbar-dropdown is-right is-rounded"> <hr class="navbar-divider"> <a class="navbar-item js-modal-trigger" data-target="download-ebook"> Download E-Book (epub) </a> <hr class="navbar-divider"> <a class="navbar-item" href="/about"> About </a> <hr class="navbar-divider"> <a class="navbar-item has-text-red" href="https://github.com/raku/doc-website/issues"> Report an issue with this site </a> <hr class="navbar-divider"> <a class="navbar-item" href="https://github.com/raku/doc/issues"> Report an issue with the documentation content </a> <hr class="navbar-divider"> <label class="navbar-item centreToggle" title="Enable/Disable Announcements" style="--switch-width: 18"> <input id="cancelAnnouncements" type="checkbox"> <span class="text">Announcements</span> <span class="on">suppressed</span> <span class="off">allowed</span> </label> </div> </div> </div> <div class="navbar-end navbar-search-wrapper"> <div class="navbar-item"> <div class="field has-addons"> <div class="autoComplete_options"> <input class="control input" id="autoComplete" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" autocapitalize="off" placeholder="🔍 Type f to search for ..."> </div> <div class="control" title="Search options"> <a class="button is-primary js-modal-trigger" data-target="options-search-info"> <span class="icon"> <i class="fas fa-cogs"></i> </span> </a> </div> </div> </div> </div> <div id="options-search-info" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <p>The last search was: <span id="selected-candidate" class="ss-selected"></span></p> <div class="control is-grouped is-grouped-centered options-search-controls"> <label class="centreToggle" title="Include extra information (Alt-E)" style="--switch-width: 10.5"> <input id="options-search-extra" type="checkbox"> <span class="text">Extra info</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>The search response can be shortened by excluding the extra information line (Alt-E)</p> <label class="centreToggle" title="Search engine type Strict/Loose (Alt-L)" style="--switch-width: 10.5"> <input id="options-search-loose" type="checkbox"> <span class="text">Search type</span> <span class="on">loose</span> <span class="off">strict</span> </label> <p> The search engine can perform a strict search (only the characters in the search box) or a loose search (Alt-L)</p> <label class="centreToggle" title="Search in headings (Alt-H)" style="--switch-width: 10.5"> <input id="options-search-headings" type="checkbox"> <span class="text">Headings</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through headings in all web-pages (Alt-H)</p> <label class="centreToggle" title="Search indexed items (Alt-I)" style="--switch-width: 10.5"> <input id="options-search-indexed" type="checkbox"> <span class="text">Indexed</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through all indexed items (Alt-I)</p> <label class="centreToggle" title="Search composite pages (Alt-C)" style="--switch-width: 10.5"> <input id="options-search-composite" type="checkbox"> <span class="text">Composite</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search in the names of composite pages, which combine similar information from the main web pages (Alt-C)</p> <label class="centreToggle" title="Search primary sources (Alt-P)" style="--switch-width: 10.5"> <input id="options-search-primary" type="checkbox"> <span class="text">Primary</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through the names of the main web pages (Alt-P)</p> <label class="centreToggle" title="Open in new tab (Alt-Q)" style="--switch-width: 10.5"> <input id="options-search-newtab" type="checkbox"> <span class="text">New tab</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Once a search candidate has been chosen, it can be opened in a new tab or in the current tab (Alt-Q)</p> <p>If all else fails, an item is added to use the Google search engine on the whole site</p> <button class="button is-warning" id="options-search-reset-defaults">Clear options, reset to defaults</button> <p>Exit this page by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> </div> <div id="download-ebook" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <p><a href="/RakuDocumentation.epub" download>RakuDocumentation.epub</a> is a work in progress e-book. It targets the <a href="https://www.w3.org/publishing/epub3/">EPUB v3 specification</a>. It needs testing on a variety of ereaders (some of which may still implicitly expect compliance with EPUB v2). The CSS definitely needs enhancing (especially for code snippets). The Ebook opens in a Calibre reader, which is available on all operating systems.</p> <p>Suggestions are welcome and should be addressed by opening an issue on the Raku/doc-website repository</p> <p>Exit this popup by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> <div id="announcement-modal" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <div id="raku-doc-announcement"></div> <p>For more see <a href="/announcements">Announcements page</a>.</p> <p>Exit this popup by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> </div> </nav> <div class="tile is-ancestor section"> <div class="page-edit"> <a class="button page-edit-button" href="https://github.com/Raku/doc/edit/main/doc/Language/faq.rakudoc" title="Edit this page. Commit: 267fb7503 2024-10-26"> <span class="icon is-right"> <i class="fas fa-pen-alt is-medium"></i> </span> </a> </div> <div id="left-column" class="tile is-parent is-2 is-hidden"> <div id="left-col-inner"> <div class="tabs" id="tabs"> <ul> <li class="is-active" id="toc-tab"> <a>Table of Contents</a> </li> <li id="index-tab"> <a>Index</a> </li> </ul> </div> <div class="field"> <div class="control has-icons-right"> <input id="toc-filter" class="input" type="text" placeholder="Filter"> <span class="icon is-right has-text-grey"> <i class="fas fa-search is-medium"></i> </span> </div> </div> <div class="raku-sidebar"> <aside id="toc-menu" class="menu"> <ul class="menu-list"> <li><a href="#General">General</a></li> <ul> <li><a href="#What's_the_difference_between_Raku,_Rakudo_and_Perl_6?">What's the difference between Raku, Rakudo and Perl 6?</a></li> <li><a href="#When_was_Raku_released?">When was Raku released?</a></li> <li><a href="#Is_there_a_Raku_version_6.0.0?">Is there a Raku version 6.0.0?</a></li> <li><a href="#When_was_v6.d_released?">When was v6.d released?</a></li> <li><a href="#As_a_Raku_user,_what_should_I_install?">As a Raku user, what should I install?</a></li> <li><a href="#As_an_advanced_user_I_want_to_track_Rakudo_development.">As an advanced user I want to track Rakudo development.</a></li> <li><a href="#Where_can_I_find_good_documentation_on_Raku?">Where can I find good documentation on Raku?</a></li> <li><a href="#Can_I_get_some_books_about_Raku?">Can I get some books about Raku?</a></li> <li><a href="#What_is_the_Raku_specification?">What is the Raku specification?</a></li> <li><a href="#Is_there_a_glossary_of_Raku_related_terms?">Is there a glossary of Raku related terms?</a></li> <li><a href="#I'm_a_Perl_programmer._Where_is_a_list_of_differences_between_Perl_and_Raku?">I'm a Perl programmer. Where is a list of differences between Perl and Raku?</a></li> <li><a href="#I'm_a_Ruby_programmer_looking_for_quickstart_type_docs?">I'm a Ruby programmer looking for quickstart type docs?</a></li> </ul> <li><a href="#Modules">Modules</a></li> <ul> <li><a href="#Is_there_a_repository_of_third_party_library_modules_for_Raku?">Is there a repository of third party library modules for Raku?</a></li> <li><a href="#Is_there_a_perldoc_(command_line_documentation_viewer)_for_Raku?">Is there a perldoc (command line documentation viewer) for Raku?</a></li> <li><a href="#Can_I_use_Perl_modules_from_Raku?">Can I use Perl modules from Raku?</a></li> <li><a href="#Can_I_use_C_and_C++_from_Raku?">Can I use C and C++ from Raku?</a></li> <li><a href="#Nativecall_can't_find_libfoo.so_and_I_only_have_libfoo.so.1.2!">Nativecall can't find libfoo.so and I only have libfoo.so.1.2!</a></li> <li><a href="#Where_have_all_the_traditional_UNIX_library_functions_gone?">Where have all the traditional UNIX library functions gone?</a></li> <li><a href="#Does_Rakudo_have_a_core_standard_library?">Does Rakudo have a core standard library?</a></li> <li><a href="#Is_there_something_like_B::Deparse/How_can_I_get_hold_of_the_AST?">Is there something like B::Deparse/How can I get hold of the AST?</a></li> <li><a href="#What_is_precompilation?">What is precompilation?</a></li> <li><a href="#Can_I_have_circular_dependencies_between_modules?">Can I have circular dependencies between modules?</a></li> </ul> <li><a href="#Common_operations">Common operations</a></li> <ul> <li><a href="#String:_How_can_I_parse_and_get_a_number_from_a_string?">String: How can I parse and get a number from a string?</a></li> <li><a href="#String:_How_can_I_check_if_a_string_contains_a_substring_and_if_so,_how_can_I_get_indices_of_matches?">String: How can I check if a string contains a substring and if so, how can I get indices of matches?</a></li> <li><a href="#String:_How_can_I_get_the_hexadecimal_representation_of_a_string?">String: How can I get the hexadecimal representation of a string?</a></li> <li><a href="#String:_How_can_I_remove_from_a_string_some_characters_by_index?">String: How can I remove from a string some characters by index?</a></li> <li><a href="#String:_How_can_I_split_a_string_in_equal_parts?">String: How can I split a string in equal parts?</a></li> </ul> <li><a href="#Language_features">Language features</a></li> <ul> <li><a href="#How_can_I_dump_Raku_data_structures_(like_Perl_Data::Dumper_and_similar)?">How can I dump Raku data structures (like Perl Data::Dumper and similar)?</a></li> <li><a href="#Why_is_the_Rakudo_compiler_so_apologetic?">Why is the Rakudo compiler so apologetic?</a></li> <li><a href="#What_is_(Any)?">What is (Any)?</a></li> <li><a href="#What_is_so?">What is so?</a></li> <li><a href="#What_are_those_:D_and_:U_things_in_signatures?">What are those :D and :U things in signatures?</a></li> <li><a href="#What_is_the_-->_thing_in_the_signature?">What is the --> thing in the signature?</a></li> <li><a href="#How_can_I_extract_the_values_from_a_Junction?">How can I extract the values from a Junction?</a></li> <li><a href="#If_Str_is_immutable,_how_does_s///_work?_If_Int_is_immutable,_how_does_$i++_work?">If Str is immutable, how does s/// work? If Int is immutable, how does $i++ work?</a></li> <li><a href="#What's_up_with_array_references_and_automatic_dereferencing?_Do_I_need_the_@_sigil?">What's up with array references and automatic dereferencing? Do I need the @ sigil?</a></li> <li><a href="#Why_sigils?_Couldn't_you_do_without_them?">Why sigils? Couldn't you do without them?</a></li> <li><a href="#"Type_Str_does_not_support_associative_indexing."">"Type Str does not support associative indexing."</a></li> <li><a href="#Does_Raku_have_coroutines?_What_about_yield?">Does Raku have coroutines? What about yield?</a></li> <li><a href="#Why_can't_I_initialize_private_attributes_from_the_new_method,_and_how_can_I_fix_this?">Why can't I initialize private attributes from the new method, and how can I fix this?</a></li> <li><a href="#How_and_why_do_say,_put_and_print_differ?">How and why do say, put and print differ?</a></li> <li><a href="#What's_the_difference_between_token_and_rule_?">What's the difference between token and rule ?</a></li> <li><a href="#What's_the_difference_between_die_and_fail?">What's the difference between die and fail?</a></li> <li><a href="#What's_the_difference_between_Pointer_and_OpaquePointer?">What's the difference between Pointer and OpaquePointer?</a></li> <li><a href="#You_can_have_colonpairs_in_identifiers._What's_the_justification?">You can have colonpairs in identifiers. What's the justification?</a></li> <li><a href="#How_do_most_people_enter_unicode_characters?">How do most people enter unicode characters?</a></li> </ul> <li><a href="#Raku_implementation">Raku implementation</a></li> <ul> <li><a href="#What_Raku_implementations_are_available?">What Raku implementations are available?</a></li> <li><a href="#What_language_is_Rakudo_written_in?">What language is Rakudo written in?</a></li> <li><a href="#What_language_is_NQP_written_in?">What language is NQP written in?</a></li> <li><a href="#Is_Raku_Lisp?">Is Raku Lisp?</a></li> <li><a href="#Can_I_compile_my_script_to_a_standalone_executable?">Can I compile my script to a standalone executable?</a></li> </ul> <li><a href="#Raku_distribution">Raku distribution</a></li> <ul> <li><a href="#When_will_the_next_version_of_Rakudo_Star_be_released?">When will the next version of Rakudo Star be released?</a></li> </ul> <li><a href="#Metaquestions_and_advocacy">Metaquestions and advocacy</a></li> <ul> <li><a href="#Why_was_Raku_originally_called_Perl_6?">Why was Raku originally called Perl 6?</a></li> <li><a href="#When_will_Raku_be_ready?_Is_it_ready_now?">When will Raku be ready? Is it ready now?</a></li> <li><a href="#Why_should_I_learn_Raku?_What's_so_great_about_it?">Why should I learn Raku? What's so great about it?</a></li> <li><a href="#Is_Raku_fast_enough_for_me?">Is Raku fast enough for me?</a></li> </ul> </aside> <aside id="index-menu" class="menu is-hidden"> <ul class="menu-list"> <li>Other languages<ul> <li><a href="#index-entry-perldoc_(FAQ)">perldoc </a></li> </ul></li> <li>Reference<ul> <li><a href="#index-entry-Books">Books</a></li> <li><a href="#index-entry-C_and_C++_(FAQ)">C and C++ </a></li> <li><a href="#index-entry-CPAN_(FAQ)">CPAN </a></li> <li><a href="#index-entry-Circular_dependencies_(FAQ)">Circular dependencies </a></li> <li><a href="#index-entry-Core_standard_library_(FAQ)">Core standard library </a></li> <li><a href="#index-entry-Coroutine_(FAQ)">Coroutine </a></li> <li><a href="#index-entry-Data::Dumper_(FAQ)">Data::Dumper </a></li> <li><a href="#index-entry-Junction_(FAQ)">Junction </a></li> <li><a href="#index-entry-NQP_(FAQ)">NQP </a></li> <li><a href="#index-entry-Perl_modules_(FAQ)">Perl modules </a></li> <li><a href="#index-entry-Precompile_(FAQ)">Precompile </a></li> <li><a href="#index-entry-Raku_Distribution_(FAQ)">Raku Distribution </a></li> <li><a href="#index-entry-Raku_Implementation_(FAQ)">Raku Implementation </a></li> <li><a href="#index-entry-Raku_and_Perl_6_(FAQ)">Raku and Perl 6 </a></li> <li><a href="#index-entry-Rakudo_Star_DMG_binary_installer_(FAQ)">Rakudo Star DMG binary installer </a></li> <li><a href="#index-entry-Rakudo_Star_MSI_binary_installer_(FAQ)">Rakudo Star MSI binary installer </a></li> <li><a href="#index-entry-Rakudo_Star_distribution_and_compiler-only_release_(FAQ)">Rakudo Star distribution and compiler-only release </a></li> <li><a href="#index-entry-Rakudo_Star_docker_image_(FAQ)">Rakudo Star docker image </a></li> <li><a href="#index-entry-Rakudo_Star_for_Linux_(FAQ)">Rakudo Star for Linux </a></li> <li><a href="#index-entry-Rakudo_Star_for_Mac_(FAQ)">Rakudo Star for Mac </a></li> <li><a href="#index-entry-Rakudo_Star_for_Windows_(FAQ)">Rakudo Star for Windows </a></li> <li><a href="#index-entry-Rakudo_Star_release_cycle_(FAQ)">Rakudo Star release cycle </a></li> <li><a href="#index-entry-Ruby_Quickstart_(FAQ)">Ruby Quickstart </a></li> <li><a href="#index-entry-Sigils_(FAQ)">Sigils </a></li> <li><a href="#index-entry-Specification_(FAQ)">Specification </a></li> <li><a href="#index-entry-ecosystem">ecosystem</a></li> <li><a href="#index-entry-rakubrew_(FAQ)">rakubrew </a></li> <li><a href="#index-entry-rakudobrew_(FAQ)">rakudobrew </a></li> <li><a href="#index-entry-rakudoc_(FAQ)">rakudoc </a></li> <li><a href="#index-entry-v6.d_(FAQ)">v6.d </a></li> </ul></li> </ul> </aside> </div> </div> </div> <div id="main-column" class="tile is-parent" style="overflow-x: hidden;"> <div id="main-col-inner"> <section class="raku page-header"> <div class="container px-4"> <div class="raku page-title has-text-centered"> FAQ </div> <div class="raku page-subtitle has-text-centered"> <p>Frequently asked questions about Raku</p> </div> </div> </section> <section class="raku page-content"><div class="container px-4"><div class="columns one-col"> <h1 id="General" class="raku-h1"><a href="#FAQ" title="go to top of document">General<a class="raku-anchor" title="direct link" href="#General">§</a></a></h1> <p><a name="index-entry-Raku_and_Perl_6_(FAQ)" class="index-entry"></a></p> <h2 id="What's_the_difference_between_Raku,_Rakudo_and_Perl_6?" class="raku-h2"><a href="#FAQ" title="go to top of document">What's the difference between Raku, Rakudo and Perl 6?<a class="raku-anchor" title="direct link" href="#What's_the_difference_between_Raku,_Rakudo_and_Perl_6?">§</a></a></h2> <p>Properly speaking, <a href="https://rakudo.org/">Rakudo</a> is an implementation of Raku. It's currently the one that's being developed, but there have been other implementations in the past and there will likely be others in the future. Raku is the definition of the language. When talking about the current interpreter, Rakudo and Raku can be used interchangeably. "Perl 6" is the name that was used for "Raku" before October 2019.</p> <h2 id="When_was_Raku_released?" class="raku-h2"><a href="#FAQ" title="go to top of document">When was Raku released?<a class="raku-anchor" title="direct link" href="#When_was_Raku_released?">§</a></a></h2> <p>The Rakudo 2015.12 implementation version was released on December 25th 2015, which implemented the v6.c Raku specification, released at the same time.</p> <h2 id="Is_there_a_Raku_version_6.0.0?" class="raku-h2"><a href="#FAQ" title="go to top of document">Is there a Raku version 6.0.0?<a class="raku-anchor" title="direct link" href="#Is_there_a_Raku_version_6.0.0?">§</a></a></h2> <p>No. The first stable language specification version is v6.c ("Christmas"). Future versions of the spec may have point releases (e.g., v6.d.2) or major releases (e.g., v6.e).</p><p>Running <code>raku -v</code> will display the language version your compiler implements, e.g.:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Shell highlighting by highlight-js</label> <div> <pre class="nohighlights"><pre class="browser-hl"> <code class="language-shell">$ raku -v Welcome to Rakudo™ v2022.04. Implementing the Raku® Programming Language v6.d. Built on MoarVM version 2022.04. </code></pre> </pre> </div> </div> <p><a name="index-entry-v6.d_(FAQ)" class="index-entry"></a></p> <h2 id="When_was_v6.d_released?" class="raku-h2"><a href="#FAQ" title="go to top of document">When was v6.d released?<a class="raku-anchor" title="direct link" href="#When_was_v6.d_released?">§</a></a></h2> <p>The v6.d Specification was released on <a href="https://en.wikipedia.org/wiki/Diwali">Diwali 2018</a>, which was November 6–7 2018, in a convenient time zone. 6.d was enabled by default in the Rakudo compiler release of 2018.11.</p><p>The vast majority of 6.d features were already implemented and available in the Rakudo compiler without requiring any special pragmas, as they did not conflict with the 6.c specification. A smaller set of features and behaviors is available automatically if you have the <code>use v6.d</code> pragma at the top of the file. The rest of about 3100 new commits to the language specification simply clarify previously undefined behavior.</p><p><a name="index-entry-Rakudo_Star_DMG_binary_installer_(FAQ)" class="index-entry"></a> <a name="index-entry-Rakudo_Star_MSI_binary_installer_(FAQ)" class="index-entry"></a> <a name="index-entry-Rakudo_Star_docker_image_(FAQ)" class="index-entry"></a> <a name="index-entry-Rakudo_Star_for_Linux_(FAQ)" class="index-entry"></a> <a name="index-entry-Rakudo_Star_for_Windows_(FAQ)" class="index-entry"></a> <a name="index-entry-Rakudo_Star_for_Mac_(FAQ)" class="index-entry"></a></p> <h2 id="As_a_Raku_user,_what_should_I_install?" class="raku-h2"><a href="#FAQ" title="go to top of document">As a Raku user, what should I install?<a class="raku-anchor" title="direct link" href="#As_a_Raku_user,_what_should_I_install?">§</a></a></h2> <p>Mac users can use the latest Rakudo Star DMG binary installer at <a href="https://rakudo.org/downloads/star">https://rakudo.org/downloads/star</a></p><p>Windows users can use the Rakudo Star MSI binary installer. You will need Windows Git and Strawberry Perl to use zef to install library modules.</p><p>Linux users probably want to download Rakudo Star and follow the compilation instructions at <a href="https://www.raku.org/downloads/">https://www.raku.org/downloads/</a>.</p><p>There should be Linux and Mac binaries available from vendors and third parties, although vendor versions may be outdated. Versions before Rakudo release of 2015.12 should be avoided.</p><p>There's an official Rakudo Star docker image at <a href="https://hub.docker.com/_/rakudo-star/">https://hub.docker.com/_/rakudo-star/</a></p><p><a name="index-entry-rakubrew_(FAQ)" class="index-entry"></a> <a name="index-entry-rakudobrew_(FAQ)" class="index-entry"></a></p> <h2 id="As_an_advanced_user_I_want_to_track_Rakudo_development." class="raku-h2"><a href="#FAQ" title="go to top of document">As an advanced user I want to track Rakudo development.<a class="raku-anchor" title="direct link" href="#As_an_advanced_user_I_want_to_track_Rakudo_development.">§</a></a></h2> <p>An option is to clone <a href="https://github.com/rakudo/rakudo">the repository</a> and build it. This will install work in progress which is minimally-tested and may contain severe bugs. If you're interested in contributing to the Rakudo Raku compiler, you may find the <a href="https://github.com/zoffixznet/z">Z-Script helper tool</a> useful.</p><p>To install the last official monthly release, check out the tag visible at <a href="https://raw.githubusercontent.com/rakudo/rakudo/master/VERSION">https://raw.githubusercontent.com/rakudo/rakudo/master/VERSION</a> or set up <a href="https://github.com/zoffixznet/r#table-of-contents">a helper command</a>.</p><p>Some users choose to use <a href="https://rakubrew.org/">rakubrew</a>, which allows quick installation of multiple versions of Rakudo in parallel.</p><p>In either case you will probably need to also install <a href="https://github.com/ugexe/zef"><code>zef</code></a> and <a href="https://raku.land/zef:coke/rakudoc"><code>rakudoc</code></a> from the <a href="https://raku.land/">ecosystem</a>.</p> <h2 id="Where_can_I_find_good_documentation_on_Raku?" class="raku-h2"><a href="#FAQ" title="go to top of document">Where can I find good documentation on Raku?<a class="raku-anchor" title="direct link" href="#Where_can_I_find_good_documentation_on_Raku?">§</a></a></h2> <p>See <a href="/index">the official documentation website</a> (especially its <a href="/introduction">"Introduction" section</a>) as well as the <a href="https://raku.org/resources/">Resources page</a>. You can also consult this <a href="https://htmlpreview.github.io/?https://github.com/perl6/mu/blob/master/docs/Perl6/Cheatsheet/cheatsheet.html">great cheatsheet</a>.</p><p><a href="https://perl6book.com/">perl6book.com</a> contains a list of dead tree and electronic books.</p><p>Be mindful of publication dates when reading third-party articles. Anything published before December, 2015 likely describes a pre-release version of Raku.</p><p>You can always <a href="https://web.libera.chat/?channel=#raku">get help from a live human in our help chat</a> or <a href="https://irclogs.raku.org/">search the chat logs</a> to find previous conversations and discussions.</p><p><a name="index-entry-Books" class="index-entry"></a></p> <h2 id="Can_I_get_some_books_about_Raku?" class="raku-h2"><a href="#FAQ" title="go to top of document">Can I get some books about Raku?<a class="raku-anchor" title="direct link" href="#Can_I_get_some_books_about_Raku?">§</a></a></h2> <p>Here are some available books, in alphabetical order:</p> <ul class="rakudoc-item"> <li><p><a href="https://www.learningraku.com/">Learning Raku</a>, by brian d foy</p></li> <li><p><a href="https://www.amazon.com/gp/product/B07221XCVL">Learning to program with Raku: First Steps</a>, by JJ Merelo</p></li> <li><p><a href="https://www.gitbook.com/book/kyclark/metagenomics/details">Metagenomics</a>, by Ken Youens-Clark</p></li> <li><p><a href="https://smile.amazon.com/dp/1484232275/">Parsing with Perl 6 Regexes and Grammars</a>, by Moritz Lenz</p></li> <li><p><a href="https://deeptext.media/perl6-at-a-glance/">Perl 6 at a Glance</a>, by Andrew Shitov</p></li> <li><p><a href="https://www.apress.com/gp/book/9781484261088">Raku Fundamentals</a>, by Moritz Lenz</p></li> <li><p><a href="https://www.packtpub.com/application-development/perl-6-deep-dive">Perl 6 Deep Dive</a>, by Andrew Shitov</p></li> <li><p><a href="https://greenteapress.com/wp/think-perl-6/">Think Perl 6: How to Think Like a Computer Scientist</a>, by Laurent Rosenfeld.</p></li> </ul> <p>A list of books published or in progress is maintained in <a href="https://raku.org/resources/"><code>raku.org</code></a>.</p><p><a name="index-entry-Specification_(FAQ)" class="index-entry"></a></p> <h2 id="What_is_the_Raku_specification?" class="raku-h2"><a href="#FAQ" title="go to top of document">What is the Raku specification?<a class="raku-anchor" title="direct link" href="#What_is_the_Raku_specification?">§</a></a></h2> <p>The specification refers to the official test suite for Raku. It's called <a href="https://github.com/Raku/roast"><code>roast</code></a> and is hosted on github. Any compiler that passes the tests is deemed to implement that version of the Raku specification.</p><p>Roast's <code>master</code> branch corresponds to the latest development that isn't necessarily part of any specification yet. Other branches correspond to specific versions; for example, "6.c-errata".</p><p>So <code>6.c-errata</code> is a released language version we don't change other than to fix errors in tests (the "errata") whereas master is the unreleased work-in-progress that may become the next language version. Its current state is not necessarily prescriptive of the next language version's behavior since new additions will be reviewed for inclusion into the release.</p> <h2 id="Is_there_a_glossary_of_Raku_related_terms?" class="raku-h2"><a href="#FAQ" title="go to top of document">Is there a glossary of Raku related terms?<a class="raku-anchor" title="direct link" href="#Is_there_a_glossary_of_Raku_related_terms?">§</a></a></h2> <p>Yes, see <a href="/language/glossary">glossary</a>.</p> <h2 id="I'm_a_Perl_programmer._Where_is_a_list_of_differences_between_Perl_and_Raku?" class="raku-h2"><a href="#FAQ" title="go to top of document">I'm a Perl programmer. Where is a list of differences between Perl and Raku?<a class="raku-anchor" title="direct link" href="#I'm_a_Perl_programmer._Where_is_a_list_of_differences_between_Perl_and_Raku?">§</a></a></h2> <p>There are several <em>Perl to Raku</em> guides in the <a href="/introduction">Introduction section of the documentation</a>, most notable of which is the <a href="/language/5to6-nutshell">Overview</a>.</p><p><a name="index-entry-Ruby_Quickstart_(FAQ)" class="index-entry"></a></p> <h2 id="I'm_a_Ruby_programmer_looking_for_quickstart_type_docs?" class="raku-h2"><a href="#FAQ" title="go to top of document">I'm a Ruby programmer looking for quickstart type docs?<a class="raku-anchor" title="direct link" href="#I'm_a_Ruby_programmer_looking_for_quickstart_type_docs?">§</a></a></h2> <p>See the <a href="/language/rb-nutshell">rb-nutshell</a> guide.</p> <h1 id="Modules" class="raku-h1"><a href="#FAQ" title="go to top of document">Modules<a class="raku-anchor" title="direct link" href="#Modules">§</a></a></h1> <p><a name="index-entry-CPAN_(FAQ)" class="index-entry"></a><a name="index-entry-ecosystem" class="index-entry"></a></p> <h2 id="Is_there_a_repository_of_third_party_library_modules_for_Raku?" class="raku-h2"><a href="#FAQ" title="go to top of document">Is there a repository of third party library modules for Raku?<a class="raku-anchor" title="direct link" href="#Is_there_a_repository_of_third_party_library_modules_for_Raku?">§</a></a></h2> <p>Yes. As a user, the <a href="https://github.com/ugexe/zef"><code>zef</code> module installer</a> will automatically install the version of a module with the highest version number. If you want a specific version and/or a version from a specific author, you can also specify that with <code>zef</code>.</p><p>As a new module author, you can use the <a href="https://raku.land/zef:tony-o/fez"><code>fez</code> module uploader</a> to upload your module to the Raku ecosystem. There are also a number of helper modules that help you set up a skeleton of a distribution, such as <a href="https://raku.land/cpan:SKAJI/App::Mi6"><code>App::Mi6</code></a>, which will also help you with uploading once your module is ready for distribution.</p><p>Historically, you could also upload a Raku module to CPAN by using <a href="https://pause.perl.org/">PAUSE</a> to upload a module. And before that, there was a way of using Github/Gitlab to make your module available for download. These are now considered to not be the best way for new module authors to start with.</p><p><a name="index-entry-rakudoc_(FAQ)" class="index-entry"></a> <a name="index-entry-perldoc_(FAQ)" class="index-entry"></a></p> <h2 id="Is_there_a_perldoc_(command_line_documentation_viewer)_for_Raku?" class="raku-h2"><a href="#FAQ" title="go to top of document">Is there a perldoc (command line documentation viewer) for Raku?<a class="raku-anchor" title="direct link" href="#Is_there_a_perldoc_(command_line_documentation_viewer)_for_Raku?">§</a></a></h2> <p>Yes, it's called <a href="https://raku.land/zef:coke/rakudoc"><code>rakudoc</code></a> and is present in the ecosystem under that name. It comes bundled in with Rakudo Star but needs to be manually installed with <code>zef</code> if you are using a Rakudo monthly release.</p><p><a name="index-entry-Perl_modules_(FAQ)" class="index-entry"></a></p> <h2 id="Can_I_use_Perl_modules_from_Raku?" class="raku-h2"><a href="#FAQ" title="go to top of document">Can I use Perl modules from Raku?<a class="raku-anchor" title="direct link" href="#Can_I_use_Perl_modules_from_Raku?">§</a></a></h2> <p>Yes, with <a href="https://github.com/niner/Inline-Perl5/">Inline::Perl5</a>, which works well with most Perl modules. It can even run Perl Catalyst and DBI.</p><p><a name="index-entry-C_and_C++_(FAQ)" class="index-entry"></a></p> <h2 id="Can_I_use_C_and_C++_from_Raku?" class="raku-h2"><a href="#FAQ" title="go to top of document">Can I use C and C++ from Raku?<a class="raku-anchor" title="direct link" href="#Can_I_use_C_and_C++_from_Raku?">§</a></a></h2> <p><a href="/language/nativecall">Nativecall</a> makes this particularly easy.</p> <h2 id="Nativecall_can't_find_libfoo.so_and_I_only_have_libfoo.so.1.2!" class="raku-h2"><a href="#FAQ" title="go to top of document">Nativecall can't find <code>libfoo.so</code> and I only have <code>libfoo.so.1.2</code>!<a class="raku-anchor" title="direct link" href="#Nativecall_can't_find_libfoo.so_and_I_only_have_libfoo.so.1.2!">§</a></a></h2> <p>In most Linux systems, shared libraries will be installed in such a way that, for a specific <code>libfoo</code>, there will be a <code>libfoo.so.x.y.z</code> real file, and then a set of symlinks <code>libfoo.so</code> and <code>libfoo.so.x</code>. for instance, <code>ls /usr/local/lib/libxxhash.so*</code> returns:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>「text」 without highlighting</label> <div> <pre class="nohighlights"><pre class="nohighlights"> /usr/local/lib/libxxhash.so -> libxxhash.so.0.6.5 /usr/local/lib/libxxhash.so.0 -> libxxhash.so.0.6.5 /usr/local/lib/libxxhash.so.0.6.5 </pre> </pre> </div> </div> <p>In general, installing a <code>libfoo-dev</code> or <code>libfoo-devel</code> (depending on the distro) in Linux will install the shared library <em>and</em> set up those symlinks for you. But in some cases, you will only have, as in the question, <code>libfoo.so.1.2</code>.</p><p>In that case, just use the version of <code>is native</code> that explicitly sets the ABI/API version, as indicated in <a href="/language/nativecall#ABI/API_version">the manual</a>:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">sub</span> call-foo() <span class="highlite-KEYWORD">is</span> <span class="highlite-KEYWORD">native</span>(<span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">foo</span><span class="highlite-STRING_DELIMITER">'</span>,v1.2); </pre> </div> </div> <h2 id="Where_have_all_the_traditional_UNIX_library_functions_gone?" class="raku-h2"><a href="#FAQ" title="go to top of document">Where have all the traditional UNIX library functions gone?<a class="raku-anchor" title="direct link" href="#Where_have_all_the_traditional_UNIX_library_functions_gone?">§</a></a></h2> <p>It's fairly easy to use <a href="/language/nativecall">NativeCall</a> to access them.</p><p>An ecosystem module <a href="https://github.com/cspencer/perl6-posix">POSIX</a> is also available.</p><p><a name="index-entry-Core_standard_library_(FAQ)" class="index-entry"></a> <a name="index-entry-Rakudo_Star_distribution_and_compiler-only_release_(FAQ)" class="index-entry"></a></p> <h2 id="Does_Rakudo_have_a_core_standard_library?" class="raku-h2"><a href="#FAQ" title="go to top of document">Does Rakudo have a core standard library?<a class="raku-anchor" title="direct link" href="#Does_Rakudo_have_a_core_standard_library?">§</a></a></h2> <p><a href="https://rakudo.org/downloads/">Rakudo Star distribution</a> does come with <a href="https://github.com/rakudo/star/blob/master/etc/modules.txt">many useful modules</a>.</p><p>Rakudo compiler-only release includes <a href="/language/modules-core">only a couple of the most basic modules</a>.</p><p>Many more modules can be found in the <a href="https://raku.land/">ecosystem</a>.</p> <h2 id="Is_there_something_like_B::Deparse/How_can_I_get_hold_of_the_AST?" class="raku-h2"><a href="#FAQ" title="go to top of document">Is there something like <code>B::Deparse</code>/How can I get hold of the AST?<a class="raku-anchor" title="direct link" href="#Is_there_something_like_B::Deparse/How_can_I_get_hold_of_the_AST?">§</a></a></h2> <p>Use <code>--target=optimize</code> command line option to view the AST of your program, e.g., <code>raku --target=optimize -e 'say "hi"'</code></p><p>The target <code>optimize</code> gives the AST after the static optimizer does its job, while target <code>ast</code> gives the AST before that step. To get the full list of available targets, run <code>raku --stagestats -e ""</code></p><p><a name="index-entry-Precompile_(FAQ)" class="index-entry"></a></p> <h2 id="What_is_precompilation?" class="raku-h2"><a href="#FAQ" title="go to top of document">What is precompilation?<a class="raku-anchor" title="direct link" href="#What_is_precompilation?">§</a></a></h2> <p>When you load a module for the first time, Rakudo compiles it into bytecode. Then, Rakudo both stores the compiled bytecode on disk and uses it, because that tends to be significantly faster.</p><p><a name="index-entry-Circular_dependencies_(FAQ)" class="index-entry"></a></p> <h2 id="Can_I_have_circular_dependencies_between_modules?" class="raku-h2"><a href="#FAQ" title="go to top of document">Can I have circular dependencies between modules?<a class="raku-anchor" title="direct link" href="#Can_I_have_circular_dependencies_between_modules?">§</a></a></h2> <p>No, you can't have circular dependencies, and you should get a <code>Circular module loading detected</code> error if you have them between your modules.</p><p>Very likely you can accomplish what you are trying to do using <a href="/language/objects#Roles">roles</a>. Instead of <code>A.rakumod</code> depending on <code>B.rakumod</code> and <code>B.rakumod</code> depending on <code>A.rakumod</code>, you can have <code>A-Role.rakumod</code> and <code>B-Role.rakumod</code> and classes in <code>A.rakumod</code> and <code>B.rakumod</code> implementing these roles respectively. Then you can depend on <code>A-Role.rakumod</code> and <code>B-Role.rakumod</code> without the need for the circular dependency.</p><p>One of the reasons why circular dependencies do not work in Raku is one pass parsing. We have to know what A means when we parse B, and we have to know what B means when we parse A, which is clearly an infinite loop.</p><p>Note that Raku has no “1 file = 1 class” limitation, and circular dependencies within a single compilation unit (e.g., file) are possible through stubbing. Therefore another possible solution is to move classes into the same compilation unit.</p> <h1 id="Common_operations" class="raku-h1"><a href="#FAQ" title="go to top of document">Common operations<a class="raku-anchor" title="direct link" href="#Common_operations">§</a></a></h1> <h2 id="String:_How_can_I_parse_and_get_a_number_from_a_string?" class="raku-h2"><a href="#FAQ" title="go to top of document">String: How can I parse and get a <a href="/language/numerics">number</a> from a <a href="/type/Str">string</a>?<a class="raku-anchor" title="direct link" href="#String:_How_can_I_parse_and_get_a_number_from_a_string?">§</a></a></h2> <p>Use the <a href="/language/operators#prefix_+">+ prefix</a>:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">42.123456789123456789</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «42.123456789123456789» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR">+</span><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">42.4e-2</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «0.424» </span></pre> </div> </div> <p>This example of <a href="/language/contexts">contextualization</a> can numify any string you could enter as a <a href="/language/syntax#Number_literals">literal number</a>. <a href="/routine/val">val</a> routine converts it to <a href="/language/glossary#Allomorph">allomorph</a>. <a href="/routine/unival">unival</a> routine converts one unicode codepoint.</p> <h2 id="String:_How_can_I_check_if_a_string_contains_a_substring_and_if_so,_how_can_I_get_indices_of_matches?" class="raku-h2"><a href="#FAQ" title="go to top of document">String: How can I check if a string contains a substring and if so, how can I get indices of matches?<a class="raku-anchor" title="direct link" href="#String:_How_can_I_check_if_a_string_contains_a_substring_and_if_so,_how_can_I_get_indices_of_matches?">§</a></a></h2> <p>Use <a href="/type/Str#method_contains">.contains</a> or <a href="/type/Str#method_indices">.indices</a>:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">az and az and az again</span><span class="highlite-STRING_DELIMITER">"</span>.<span class="highlite-ROUTINE">contains</span>(<span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">az</span><span class="highlite-STRING_DELIMITER">"</span>); <span class="highlite-COMMENT"># OUTPUT: «True» </span><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">az and az and az again</span><span class="highlite-STRING_DELIMITER">"</span>.<span class="highlite-ROUTINE">indices</span>(<span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">az</span><span class="highlite-STRING_DELIMITER">"</span>); <span class="highlite-COMMENT"># OUTPUT: «(0 7 14)» </span></pre> </div> </div> <h2 id="String:_How_can_I_get_the_hexadecimal_representation_of_a_string?" class="raku-h2"><a href="#FAQ" title="go to top of document">String: How can I get the hexadecimal representation of a string?<a class="raku-anchor" title="direct link" href="#String:_How_can_I_get_the_hexadecimal_representation_of_a_string?">§</a></a></h2> <p>To get a hexadecimal list of each byte of a string (i.e. hex encoder), first convert the string to a <a href="/type/Blob"><code>Blob</code></a> with <a href="/routine/encode">.encode</a>.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">I ❤ 🦋</span><span class="highlite-STRING_DELIMITER">"</span>.<span class="highlite-ROUTINE">encode</span>><span class="highlite-OPERATOR">></span>.<span class="highlite-ROUTINE">base</span>(16); <span class="highlite-COMMENT"># OUTPUT: «(49 20 E2 9D A4 20 F0 9F A6 8B)» </span></pre> </div> </div> <p>Note that <a href="/routine/gist">.gist</a> or <a href="/routine/raku">.raku</a> methods can be useful for variable introspection:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">I ❤ 🦋</span><span class="highlite-STRING_DELIMITER">"</span>.<span class="highlite-ROUTINE">encode</span>.<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «utf8.new(73,32,226,157,164,32,240,159,166,139)» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">I ❤ 🦋</span><span class="highlite-STRING_DELIMITER">"</span>.<span class="highlite-ROUTINE">encode</span>.<span class="highlite-ROUTINE">gist</span>; <span class="highlite-COMMENT"># OUTPUT: «utf8:0x<49 20 E2 9D A4 20 F0 9F A6 8B>» </span></pre> </div> </div> <h2 id="String:_How_can_I_remove_from_a_string_some_characters_by_index?" class="raku-h2"><a href="#FAQ" title="go to top of document">String: How can I remove from a string some characters by index?<a class="raku-anchor" title="direct link" href="#String:_How_can_I_remove_from_a_string_some_characters_by_index?">§</a></a></h2> <p>Use <a href="/routine/comb">.comb</a> to transform it to a <a href="/type/Seq"><code>Seq</code></a>, then the <a href="/language/operators#infix_-">(-) infix</a> to remove the unwanted indices:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">0123456789</span><span class="highlite-STRING_DELIMITER">'</span>.<span class="highlite-ROUTINE">comb</span>[(<span class="highlite-OPERATOR">^</span><span class="highlite-OPERATOR">*</span> <span class="highlite-OPERATOR">(-)</span> (1..3<span class="highlite-OPERATOR">,</span> 8).<span class="highlite-ROUTINE">flat</span>).<span class="highlite-ROUTINE">keys</span>.<span class="highlite-ROUTINE">sort</span>].<span class="highlite-ROUTINE">join</span>; <span class="highlite-COMMENT"># OUTPUT: «045679» </span></pre> </div> </div> <p>If the string is large, <a href="/routine/comb">.comb</a> can take time. In which case, <a href="/routine/substr-rw">.substr-rw</a> is faster:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">multi</span> postcircumfix:<span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">[- ]</span><span class="highlite-STRING_DELIMITER">></span> (Str:D <span class="highlite-NAME_SCALAR">$str</span> <span class="highlite-KEYWORD">is</span> <span class="highlite-ROUTINE">copy</span><span class="highlite-OPERATOR">,</span> <span class="highlite-OPERATOR">+</span><span class="highlite-NAME_ARRAY">@indices</span>) { <span class="highlite-KEYWORD">for</span> <span class="highlite-NAME_ARRAY">@indices</span>.<span class="highlite-ROUTINE">reverse</span> { <span class="highlite-KEYWORD">when</span> <span class="highlite-TYPE">Int</span> { <span class="highlite-NAME_SCALAR">$str</span>.<span class="highlite-ROUTINE">substr-rw</span>(<span class="highlite-NAME_SCALAR">$_</span>,1) <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING_DELIMITER">'</span> } <span class="highlite-KEYWORD">when</span> <span class="highlite-TYPE">Range</span> { <span class="highlite-NAME_SCALAR">$str</span>.<span class="highlite-ROUTINE">substr-rw</span>(<span class="highlite-NAME_SCALAR">$_</span> ) <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING_DELIMITER">'</span> } } <span class="highlite-KEYWORD">return</span> <span class="highlite-NAME_SCALAR">$str</span>; } <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">0123456789</span><span class="highlite-STRING_DELIMITER">'</span>[<span class="highlite-OPERATOR">-</span> 1..3<span class="highlite-OPERATOR">,</span> 8 ]; <span class="highlite-COMMENT"># OUTPUT: «045679» </span></pre> </div> </div> <h2 id="String:_How_can_I_split_a_string_in_equal_parts?" class="raku-h2"><a href="#FAQ" title="go to top of document">String: How can I split a string in equal parts?<a class="raku-anchor" title="direct link" href="#String:_How_can_I_split_a_string_in_equal_parts?">§</a></a></h2> <p><a href="/routine/comb">.comb</a> is accepting an optional <a href="/type/Int"><code>Int</code></a>:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights">.<span class="highlite-ROUTINE">say</span> <span class="highlite-KEYWORD">for</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">abcdefghijklmnopqrstuvwxyz</span><span class="highlite-STRING_DELIMITER">'</span>.comb: 8; <span class="highlite-COMMENT"># OUTPUT: «abcdefghijklmnopqrstuvwxyz» </span></pre> </div> </div> <h1 id="Language_features" class="raku-h1"><a href="#FAQ" title="go to top of document">Language features<a class="raku-anchor" title="direct link" href="#Language_features">§</a></a></h1> <p><a name="index-entry-Data::Dumper_(FAQ)" class="index-entry"></a></p> <h2 id="How_can_I_dump_Raku_data_structures_(like_Perl_Data::Dumper_and_similar)?" class="raku-h2"><a href="#FAQ" title="go to top of document">How can I dump Raku data structures (like Perl Data::Dumper and similar)?<a class="raku-anchor" title="direct link" href="#How_can_I_dump_Raku_data_structures_(like_Perl_Data::Dumper_and_similar)?">§</a></a></h2> <p>Typical options are to use the <a href="/routine/say">say</a> routine that uses the <a href="/routine/gist">gist</a> method which gives the "gist" of the object being dumped. More detailed output can be obtained by calling the <a href="/routine/perl">perl</a> method (soon to be deprecated in favor of <code>$obj.raku</code>, available since the Rakudo 2019.11 release) that typically returns an object's representation in <a href="/routine/EVAL">EVAL</a>-able code.</p><p>If you're using the <a href="https://rakudo.org">rakudo</a> implementation, you can use the <a href="/programs/01-debugging#Dumper_function_(dd)">rakudo-specific <code>dd</code> routine</a> for dumping, whose output is similar to <a href="/routine/raku">raku</a>, but with more information.</p><p>Examples:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$foo</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-OPERATOR">%</span>( foo <span class="highlite-OPERATOR">=></span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">bar</span><span class="highlite-STRING_DELIMITER">'</span> ); <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$foo</span>.<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «${:foo("bar")}» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$foo</span>; <span class="highlite-COMMENT"># OUTPUT: «{foo => bar}» </span> <span class="highlite-COMMENT"># non-standard routine available in rakudo implementation: </span>dd <span class="highlite-NAME_SCALAR">$foo</span>; <span class="highlite-COMMENT"># OUTPUT: «Hash $foo = ${:foo("bar")}» </span></pre> </div> </div> <p>There are also <a href="https://raku.land/?q=dump">several ecosystem modules</a> that provide more control over how data structures are dumped, including support for colored output.</p> <h2 id="Why_is_the_Rakudo_compiler_so_apologetic?" class="raku-h2"><a href="#FAQ" title="go to top of document">Why is the Rakudo compiler so apologetic?<a class="raku-anchor" title="direct link" href="#Why_is_the_Rakudo_compiler_so_apologetic?">§</a></a></h2> <p>If SORRY! is present in the output, the error is a compile time error. Otherwise, it's a runtime error.</p><p>Example:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">sub</span> foo( <span class="highlite-TYPE">Int</span> <span class="highlite-NAME_SCALAR">$a</span><span class="highlite-OPERATOR">,</span> <span class="highlite-TYPE">Int</span> <span class="highlite-NAME_SCALAR">$b</span> ) {<span class="highlite-OPERATOR">...</span>} foo(1) <span class="highlite-COMMENT"># ===SORRY!=== Error while compiling ... </span></pre> </div> </div> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> 1/0; <span class="highlite-COMMENT"># Attempt to divide 1 by zero using div </span></pre> </div> </div> <h2 id="What_is_(Any)?" class="raku-h2"><a href="#FAQ" title="go to top of document">What is <code>(Any)</code>?<a class="raku-anchor" title="direct link" href="#What_is_(Any)?">§</a></a></h2> <p><a href="/type/Any"><code>Any</code></a> is a top level class most objects inherit from. The <a href="/type/Any"><code>Any</code></a> type object is <a href="/type/Attribute#Trait_is_default">the default value</a> on variables and parameters without an explicit type constraint, which means you'll likely see <code>(Any)</code> printed when you output a <a href="/routine/gist">gist</a> of a variable without any value by using, for instance, the <a href="/routine/say"><code>say</code> routine</a>:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$foo</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$foo</span>; <span class="highlite-COMMENT"># OUTPUT: «(Any)» </span> <span class="highlite-KEYWORD">my</span> <span class="highlite-TYPE">Int</span> <span class="highlite-NAME_SCALAR">$baz</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$baz</span>; <span class="highlite-COMMENT"># OUTPUT: «(Int)» </span> <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$bar</span> <span class="highlite-OPERATOR">=</span> 70; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$bar</span>; <span class="highlite-COMMENT"># OUTPUT: «70» </span></pre> </div> </div> <p>To test whether a variable has any defined values, see <a href="/language/classtut#index-entry-type_object-DEFINITE-A_word_on_types">DEFINITE</a> and <a href="/routine/defined">defined</a> routines. Several other constructs exist that test for definiteness, such as <a href="/syntax/with orwith without"><code>with</code>, <code>orwith</code>, and <code>without</code></a> statements, <a href="/routine/$SOLIDUS$SOLIDUS"><code>//</code></a>, <a href="/routine/andthen">andthen</a>, <a href="/routine/notandthen">notandthen</a>, and <a href="/routine/orelse">orelse</a> operators, as well as <a href="/language/signatures#Constraining_argument_definiteness">type constraint smileys</a>.</p> <h2 id="What_is_so?" class="raku-h2"><a href="#FAQ" title="go to top of document">What is <code>so</code>?<a class="raku-anchor" title="direct link" href="#What_is_so?">§</a></a></h2> <p><code>so</code> is a loose precedence operator that coerces to <a href="/type/Bool"><code>Bool</code></a>.</p><p>It has the same semantics as the <code>?</code> prefix operator, just like <code>and</code> is the low-precedence version of <code>&&</code>.</p><p>Example:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR">so</span> 1|2 <span class="highlite-OPERATOR">==</span> 2; <span class="highlite-COMMENT"># OUTPUT: «True» </span></pre> </div> </div> <p>In this example, the result of the comparison (which is a <a href="/type/Junction"><code>Junction</code></a>), is converted to Bool before being printed.</p> <h2 id="What_are_those_:D_and_:U_things_in_signatures?" class="raku-h2"><a href="#FAQ" title="go to top of document">What are those <code>:D</code> and <code>:U</code> things in signatures?<a class="raku-anchor" title="direct link" href="#What_are_those_:D_and_:U_things_in_signatures?">§</a></a></h2> <p>In Raku, classes and other types are objects and pass type checks of their own type.</p><p>For example, if you declare a variable</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-TYPE">Int</span> <span class="highlite-NAME_SCALAR">$x</span> <span class="highlite-OPERATOR">=</span> 42; </pre> </div> </div> <p>then not only can you assign integers (that is, instances of class Int) to it, but the <a href="/type/Int"><code>Int</code></a> type object itself:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-NAME_SCALAR">$x</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-TYPE">Int</span> </pre> </div> </div> <p>If you want to exclude type objects, you can append the <code>:D</code> type smiley, which stands for "definite":</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> Int:D <span class="highlite-NAME_SCALAR">$x</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-NAME_SCALAR">$x</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-TYPE">Int</span>; <span class="highlite-COMMENT"># dies with: </span><span class="highlite-COMMENT"># Type check failed in assignment to $x; </span><span class="highlite-COMMENT"># expected Int:D but got Int </span></pre> </div> </div> <p>Likewise, <code>:U</code> constrains to undefined values, that is, type objects.</p><p>To explicitly allow either type objects or instances, you can use <code>:_</code>.</p> <h2 id="What_is_the_-->_thing_in_the_signature?" class="raku-h2"><a href="#FAQ" title="go to top of document">What is the <code>--></code> thing in the signature?<a class="raku-anchor" title="direct link" href="#What_is_the_-->_thing_in_the_signature?">§</a></a></h2> <p><a href="/language/signatures#Constraining_return_types">--></a> is a return constraint, either a type or a definite value.</p><p>Example of a type constraint:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">sub</span> divide-to-int( <span class="highlite-TYPE">Int</span> <span class="highlite-NAME_SCALAR">$a</span><span class="highlite-OPERATOR">,</span> <span class="highlite-TYPE">Int</span> <span class="highlite-NAME_SCALAR">$b</span> <span class="highlite-KEYWORD">--></span> <span class="highlite-TYPE">Int</span> ) { <span class="highlite-KEYWORD">return</span> (<span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">/</span> <span class="highlite-NAME_SCALAR">$b</span>).<span class="highlite-ROUTINE">narrow</span>; } divide-to-int(3<span class="highlite-OPERATOR">,</span> 2) <span class="highlite-COMMENT"># Type check failed for return value; expected Int but got Rat </span></pre> </div> </div> <p>Example of a definite return value:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">sub</span> discard-random-number( <span class="highlite-KEYWORD">--></span> 42 ) { <span class="highlite-ROUTINE">rand</span> } <span class="highlite-ROUTINE">say</span> discard-random-number; <span class="highlite-COMMENT"># OUTPUT: «42» </span></pre> </div> </div> <p>In this case, the final value is thrown away because the return value is already specified in the signature.</p><p><a name="index-entry-Junction_(FAQ)" class="index-entry"></a></p> <h2 id="How_can_I_extract_the_values_from_a_Junction?" class="raku-h2"><a href="#FAQ" title="go to top of document">How can I extract the values from a Junction?<a class="raku-anchor" title="direct link" href="#How_can_I_extract_the_values_from_a_Junction?">§</a></a></h2> <p>If you want to extract the values from a <a href="/type/Junction"><code>Junction</code></a>, you are probably doing something wrong and should be using a <a href="/type/Set"><code>Set</code></a> instead.</p><p>Junctions are meant as matchers, not for doing algebra with them.</p><p>If you want to do it anyway, you can abuse autothreading for that:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">sub</span> junction-values(<span class="highlite-TYPE">Mu</span> <span class="highlite-NAME_SCALAR">$j</span>) { <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@values</span>; <span class="highlite-KEYWORD">-></span> <span class="highlite-TYPE">Any</span> <span class="highlite-NAME_SCALAR">$s</span> { <span class="highlite-NAME_ARRAY">@values</span>.push: <span class="highlite-NAME_SCALAR">$s</span> }<span class="highlite-OPERATOR">.</span>(<span class="highlite-NAME_SCALAR">$j</span>); <span class="highlite-NAME_ARRAY">@values</span>; } <span class="highlite-ROUTINE">say</span> junction-values(1|2|3).<span class="highlite-ROUTINE">join</span>(<span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">, </span><span class="highlite-STRING_DELIMITER">'</span>); <span class="highlite-COMMENT"># prints 1, 2, 3 or a permutation thereof </span></pre> </div> </div> <h2 id="If_Str_is_immutable,_how_does_s///_work?_If_Int_is_immutable,_how_does_$i++_work?" class="raku-h2"><a href="#FAQ" title="go to top of document">If Str is immutable, how does <code>s///</code> work? If Int is immutable, how does <code>$i++</code> work?<a class="raku-anchor" title="direct link" href="#If_Str_is_immutable,_how_does_s///_work?_If_Int_is_immutable,_how_does_$i++_work?">§</a></a></h2> <p>In Raku, values of many basic types are immutable, but the variables holding them are not. The <code>s///</code> operator works on a variable, into which it puts a newly created string object. Likewise, <code>$i++</code> works on the <code>$i</code> variable, not just on the value in it.</p><p>Knowing this, you would not try to change a literal string (e.g. like <code>'hello' ~~ s/h/H/;</code>), but you might accidentally do something equivalent using <code>map</code> as follows.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@foo</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">hello world</span><span class="highlite-STRING_DELIMITER">></span>.map: { <span class="highlite-REGEX_DELIMITER">s/</span><span class="highlite-REGEX_LITERAL">h</span><span class="highlite-REGEX_DELIMITER">/</span><span class="highlite-STRING">H</span><span class="highlite-REGEX_DELIMITER">/</span> }; <span class="highlite-COMMENT"># dies with </span><span class="highlite-COMMENT"># Cannot modify an immutable Str (hello) </span> <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@bar</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">hello world</span><span class="highlite-STRING_DELIMITER">></span>».subst-mutate: <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">h</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">H</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-COMMENT"># dies with </span><span class="highlite-COMMENT"># Cannot resolve caller subst-mutate(Str: Str, Str); </span><span class="highlite-COMMENT"># the following candidates match the type but require </span><span class="highlite-COMMENT"># mutable arguments: ... </span></pre> </div> </div> <p>Instead of modifying the original value in place, use a routine or operator that returns a new value:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@foo</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">hello world</span><span class="highlite-STRING_DELIMITER">></span>.map: { <span class="highlite-REGEX_DELIMITER">S/</span><span class="highlite-REGEX_LITERAL">h</span><span class="highlite-REGEX_DELIMITER">/</span><span class="highlite-STRING">H</span><span class="highlite-REGEX_DELIMITER">/</span> }; <span class="highlite-COMMENT"># ['Hello','world'] </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@bar</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">hello world</span><span class="highlite-STRING_DELIMITER">></span>».subst: <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">h</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">H</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-COMMENT"># ['Hello','world'] </span></pre> </div> </div> <p>See the documentation on <a href="/language/containers">containers</a> for more information.</p> <h2 id="What's_up_with_array_references_and_automatic_dereferencing?_Do_I_need_the_@_sigil?" class="raku-h2"><a href="#FAQ" title="go to top of document">What's up with array references and automatic dereferencing? Do I need the <code>@</code> sigil?<a class="raku-anchor" title="direct link" href="#What's_up_with_array_references_and_automatic_dereferencing?_Do_I_need_the_@_sigil?">§</a></a></h2> <p>In Raku, nearly everything is a reference, so talking about taking references doesn't make much sense. Scalar variables can also contain arrays directly:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@a</span> <span class="highlite-OPERATOR">=</span> 1<span class="highlite-OPERATOR">,</span> 2<span class="highlite-OPERATOR">,</span> 3; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_ARRAY">@a</span>; <span class="highlite-COMMENT"># OUTPUT: «[1 2 3]» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_ARRAY">@a</span>.^<span class="highlite-ROUTINE">name</span>; <span class="highlite-COMMENT"># OUTPUT: «Array» </span> <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$scalar</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-NAME_ARRAY">@a</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$scalar</span>; <span class="highlite-COMMENT"># OUTPUT: «[1 2 3]» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$scalar</span>.^<span class="highlite-ROUTINE">name</span>; <span class="highlite-COMMENT"># OUTPUT: «Array» </span></pre> </div> </div> <p>The big difference is that arrays inside a scalar act as one value in list context, whereas arrays will be happily iterated over.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@a</span> <span class="highlite-OPERATOR">=</span> 1<span class="highlite-OPERATOR">,</span> 2<span class="highlite-OPERATOR">,</span> 3; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$s</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-NAME_ARRAY">@a</span>; <span class="highlite-KEYWORD">for</span> <span class="highlite-NAME_ARRAY">@a</span> { <span class="highlite-OPERATOR">...</span> } <span class="highlite-COMMENT"># loop body executed 3 times </span><span class="highlite-KEYWORD">for</span> <span class="highlite-NAME_SCALAR">$s</span> { <span class="highlite-OPERATOR">...</span> } <span class="highlite-COMMENT"># loop body executed only once </span> <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@flat</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-ROUTINE">flat</span> <span class="highlite-NAME_ARRAY">@a</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_ARRAY">@a</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_ARRAY">@flat</span>.<span class="highlite-ROUTINE">elems</span>; <span class="highlite-COMMENT"># OUTPUT: «6» </span> <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@nested</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-ROUTINE">flat</span> <span class="highlite-NAME_SCALAR">$s</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_SCALAR">$s</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_ARRAY">@nested</span>.<span class="highlite-ROUTINE">elems</span>; <span class="highlite-COMMENT"># OUTPUT: «2» </span></pre> </div> </div> <p>You can force list context with <code>@( ... )</code> or by calling the <code>.list</code> method on an expression, and item context with <code>$( ... )</code> or by calling the <code>.item</code> method on an expression.</p><p>See the <a href="https://perl6advent.wordpress.com/2017/12/02/"><em>Perl 6: Sigils, Variables, and Containers</em></a> article to learn more.</p><p><a name="index-entry-Sigils_(FAQ)" class="index-entry"></a></p> <h2 id="Why_sigils?_Couldn't_you_do_without_them?" class="raku-h2"><a href="#FAQ" title="go to top of document">Why sigils? Couldn't you do without them?<a class="raku-anchor" title="direct link" href="#Why_sigils?_Couldn't_you_do_without_them?">§</a></a></h2> <p>There are several reasons:</p> <ul class="rakudoc-item"> <li><p>they make it easy to interpolate variables into strings</p></li> <li><p>they form micro-namespaces for different variables and twigils, thus avoiding name clashes</p></li> <li><p>they allow easy single/plural distinction</p></li> <li><p>they work like natural languages that use mandatory noun markers, so our brains are built to handle it</p></li> <li><p>they aren't mandatory, since you can declare sigilless names (if you don't mind the ambiguity)</p></li> </ul> <h2 id=""Type_Str_does_not_support_associative_indexing."" class="raku-h2"><a href="#FAQ" title="go to top of document">"Type Str does not support associative indexing."<a class="raku-anchor" title="direct link" href="#"Type_Str_does_not_support_associative_indexing."">§</a></a></h2> <p>You likely tried to mix string interpolation and key characters, like HTML tags:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$foo</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">abc</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_SCALAR">$foo</span><span class="highlite-STRING"><html-tag></span><span class="highlite-STRING_DELIMITER">"</span>; </pre> </div> </div> <p>Raku thinks <code>$foo</code> is a Hash and <code><html-tag></code> is a string literal hash key. Use a closure to help it to understand you.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$foo</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">abc</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-ESCAPE">{</span><span class="highlite-NAME_SCALAR">$foo</span><span class="highlite-ESCAPE">}</span><span class="highlite-STRING"><html-tag></span><span class="highlite-STRING_DELIMITER">"</span>; </pre> </div> </div> <p><a name="index-entry-Coroutine_(FAQ)" class="index-entry"></a></p> <h2 id="Does_Raku_have_coroutines?_What_about_yield?" class="raku-h2"><a href="#FAQ" title="go to top of document">Does Raku have coroutines? What about <code>yield</code>?<a class="raku-anchor" title="direct link" href="#Does_Raku_have_coroutines?_What_about_yield?">§</a></a></h2> <p>Raku has no <code>yield</code> statement like Python does, but it does offer similar functionality through lazy lists. There are two popular ways to write routines that return lazy lists:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-COMMENT"># first method, gather/take </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@values</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-KEYWORD">gather</span> <span class="highlite-KEYWORD">while</span> have_data() { <span class="highlite-COMMENT"># do some computations </span> <span class="highlite-ROUTINE">take</span> some_data(); <span class="highlite-COMMENT"># do more computations </span>} <span class="highlite-COMMENT"># second method, use .map or similar method </span><span class="highlite-COMMENT"># on a lazy list </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@squares</span> <span class="highlite-OPERATOR">=</span> (1.<span class="highlite-OPERATOR">.*</span>).<span class="highlite-ROUTINE">map</span>(<span class="highlite-KEYWORD">-></span> \<span class="highlite-OPERATOR">x</span> { <span class="highlite-OPERATOR">x</span>² }); </pre> </div> </div> <h2 id="Why_can't_I_initialize_private_attributes_from_the_new_method,_and_how_can_I_fix_this?" class="raku-h2"><a href="#FAQ" title="go to top of document">Why can't I initialize private attributes from the new method, and how can I fix this?<a class="raku-anchor" title="direct link" href="#Why_can't_I_initialize_private_attributes_from_the_new_method,_and_how_can_I_fix_this?">§</a></a></h2> <p>The <code>say</code> statement in the following code sample</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">class</span> A { <span class="highlite-KEYWORD">has</span> <span class="highlite-NAME_SCALAR">$!x</span>; <span class="highlite-KEYWORD">method</span> show-x { <span class="highlite-KEYWORD">return</span> <span class="highlite-NAME_SCALAR">$!x</span>; } } <span class="highlite-ROUTINE">say</span> A.<span class="highlite-ROUTINE">new</span>(<span class="highlite-OPERATOR">x</span> <span class="highlite-OPERATOR">=></span> 5).show-x; </pre> </div> </div> <p>does not print 5. Private attributes are <em>private</em>, which means invisible to the outside world. If the default constructor could initialize them, they would leak into the public API. Thus, in this particular code sample the attribute <code>$!x</code> isn't initialized during object construction by the default constructor.</p><p>If you still want to initialize private attributes with the default constructor, you can add a <code>submethod BUILD</code> to achieve such task:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">class</span> B { <span class="highlite-KEYWORD">has</span> <span class="highlite-NAME_SCALAR">$!x</span>; <span class="highlite-KEYWORD">submethod</span> <span class="highlite-ROUTINE">BUILD</span>(<span class="highlite-OPERATOR">:</span><span class="highlite-NAME_SCALAR">$!x</span>) { } <span class="highlite-KEYWORD">method</span> show-x { <span class="highlite-KEYWORD">return</span> <span class="highlite-NAME_SCALAR">$!x</span>; } } <span class="highlite-ROUTINE">say</span> B.<span class="highlite-ROUTINE">new</span>(<span class="highlite-OPERATOR">x</span> <span class="highlite-OPERATOR">=></span> 5).show-x; </pre> </div> </div> <p><code>BUILD</code> is called by the default constructor (indirectly, see <a href="/language/objects#Object_construction">Object Construction</a> for more details) with all the named arguments that the user passes to the constructor. <code>:$!x</code> is a named parameter with name <code>x</code>, and when called with a named argument of name <code>x</code>, its value is bound to the attribute <code>$!x</code>.</p><p>However, you shouldn't do that. If the attribute is declared as private, then it shouldn't be exposed to the environment outside the class (e.g., during object construction). On the other hand, if the attribute is public, there is no downside to declaring it that way with <code>$.x</code> since the external view is read-only by default, and you can still access it internally with <code>$!x</code>.</p> <h2 id="How_and_why_do_say,_put_and_print_differ?" class="raku-h2"><a href="#FAQ" title="go to top of document">How and why do <code>say</code>, <code>put</code> and <code>print</code> differ?<a class="raku-anchor" title="direct link" href="#How_and_why_do_say,_put_and_print_differ?">§</a></a></h2> <p>The most obvious difference is that <code>say</code> and <code>put</code> append a newline at the end of the output, and <code>print</code> does not.</p><p>But there's another difference: <code>print</code> and <code>put</code> convert their arguments to a string by calling the <a href="/routine/Str"><code>Str</code></a> method on each item passed to them while <code>say</code> uses the <code>gist</code> method. The <code>gist</code> method, which you can also create for your own classes, is intended to create a <a href="/type/Str"><code>Str</code></a> for human interpretation. So it is free to leave out information about the object deemed unimportant to understanding the essence of the object.</p><p>Or phrased differently, <code>$obj.Str</code> gives a string representation, <code>$obj.gist</code> provides a short summary of that object suitable for fast recognition by a human, and <code>$obj.raku</code> gives a Raku-ish representation from which the object could be re-created.</p><p>For example, when the <a href="/routine/Str"><code>Str</code></a> method is invoked on a type object, also known as an "undefined value", the type is stringified to an empty string and a <code>warn</code>ing is thrown. On the other hand, the <code>gist</code> method returns the name of the type between parentheses (to indicate there's nothing in that value except the type).</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-TYPE">Date</span> <span class="highlite-NAME_SCALAR">$x</span>; <span class="highlite-COMMENT"># $x now contains the Date type object </span><span class="highlite-ROUTINE">print</span> <span class="highlite-NAME_SCALAR">$x</span>; <span class="highlite-COMMENT"># empty string plus warning </span><span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$x</span>; <span class="highlite-COMMENT"># OUTPUT: «(Date)» </span></pre> </div> </div> <p>If you'd like to show a debugging version of an object, it is probably better to use the <a href="/programs/01-debugging#Dumper_function_(dd)">rakudo-specific <code>dd</code> routine</a>. It essentially does <code>$obj.raku</code> and shows that on STDERR rather than STDOUT, so it won't interfere with any "normal" output of your program.</p><p>In short, <code>say</code> is optimized for casual human interpretation, <code>dd</code> is optimized for casual debugging output and <code>print</code> and <code>put</code> are more generally suitable for producing output.</p><p><code>put</code> is thus a hybrid of <code>print</code> and <code>say</code>; like <code>print</code>, it calls the <a href="/routine/Str"><code>Str</code></a> method on the object. And like <code>say</code>, it adds a newline at the end of the output.</p> <h2 id="What's_the_difference_between_token_and_rule_?" class="raku-h2"><a href="#FAQ" title="go to top of document">What's the difference between <code>token</code> and <code>rule</code> ?<a class="raku-anchor" title="direct link" href="#What's_the_difference_between_token_and_rule_?">§</a></a></h2> <p><code>regex</code>, <code>token</code> and <code>rule</code> introduce regexes, but with slightly different semantics.</p><p><code>token</code> implies the <code>:ratchet</code> or <code>:r</code> modifier, which prevents the rule from backtracking.</p><p><code>rule</code> implies both the <code>:ratchet</code> and <code>:sigspace</code> (short <code>:s</code>) modifier, which means a rule doesn't backtrace, and it treats whitespace in the text of the regex as <code><.ws></code> calls (i.e., matches whitespace, which is optional except between two word characters). Whitespace at the start of the regex and at the start of each branch of an alternation is ignored.</p><p><code>regex</code> declares a plain regex without any implied modifiers.</p> <h2 id="What's_the_difference_between_die_and_fail?" class="raku-h2"><a href="#FAQ" title="go to top of document">What's the difference between <code>die</code> and <code>fail</code>?<a class="raku-anchor" title="direct link" href="#What's_the_difference_between_die_and_fail?">§</a></a></h2> <p><code>die</code> throws an exception.</p><p><code>fail</code> returns a <a href="/type/Failure"><code>Failure</code></a> object. (If the caller has declared <code>use fatal;</code> in the calling lexical scope, <code>fail</code> throws an exception instead of returning it.)</p><p>A <a href="/type/Failure"><code>Failure</code></a> is an "unthrown" or "lazy" exception. It's an object that contains the exception, and throws the exception if you try to use the <a href="/type/Failure"><code>Failure</code></a> as an ordinary object or ignore it in sink context.</p><p>A <a href="/type/Failure"><code>Failure</code></a> returns <code>False</code> from a <code>defined</code> check, and you can extract the exception with the <code>exception</code> method.</p> <h2 id="What's_the_difference_between_Pointer_and_OpaquePointer?" class="raku-h2"><a href="#FAQ" title="go to top of document">What's the difference between <code>Pointer</code> and <code>OpaquePointer</code>?<a class="raku-anchor" title="direct link" href="#What's_the_difference_between_Pointer_and_OpaquePointer?">§</a></a></h2> <p><code>OpaquePointer</code> is deprecated and has been replaced with <code>Pointer</code>.</p> <h2 id="You_can_have_colonpairs_in_identifiers._What's_the_justification?" class="raku-h2"><a href="#FAQ" title="go to top of document">You can have colonpairs in identifiers. What's the justification?<a class="raku-anchor" title="direct link" href="#You_can_have_colonpairs_in_identifiers._What's_the_justification?">§</a></a></h2> <p><a href="/language/syntax#Identifiers">Identifiers can include colon pairs, which become part of their name</a>. According to <a href="https://github.com/Raku/doc/issues/1753#issuecomment-362875676">Larry Wall's answer to the issue</a>, <em>We already had the colon pair mechanism available, so it was a no-brainer to use that to extend any name that needs to be able to quote uniquefying but non-standard characters (or other information with a unique stringification to such characters)</em>.</p> <h2 id="How_do_most_people_enter_unicode_characters?" class="raku-h2"><a href="#FAQ" title="go to top of document">How do most people enter unicode characters?<a class="raku-anchor" title="direct link" href="#How_do_most_people_enter_unicode_characters?">§</a></a></h2> <p>It depends on the operating system, windowing environment and/or editors. <a href="/language/unicode_entry">This page on entering Unicode characters</a> specifies how it is done in the most popular operating systems and editors.</p><p><a name="index-entry-Raku_Implementation_(FAQ)" class="index-entry"></a></p> <h1 id="Raku_implementation" class="raku-h1"><a href="#FAQ" title="go to top of document">Raku implementation<a class="raku-anchor" title="direct link" href="#Raku_implementation">§</a></a></h1> <h2 id="What_Raku_implementations_are_available?" class="raku-h2"><a href="#FAQ" title="go to top of document">What Raku implementations are available?<a class="raku-anchor" title="direct link" href="#What_Raku_implementations_are_available?">§</a></a></h2> <p>Currently the best developed is Rakudo (using multiple Virtual Machine backends). Historic implementations include Niecza (.NET) and Pugs (Haskell). Others are listed at <a href="https://www.raku.org/compilers/">Raku Compilers</a></p> <h2 id="What_language_is_Rakudo_written_in?" class="raku-h2"><a href="#FAQ" title="go to top of document">What language is Rakudo written in?<a class="raku-anchor" title="direct link" href="#What_language_is_Rakudo_written_in?">§</a></a></h2> <p>A short answer is that Rakudo is written almost entirely in Raku. A more detailed answer is that Rakudo is written in a mixture of Raku and NQP ("Not Quite Perl"). NQP is a lightweight Raku-like environment for virtual machines; it's designed to be a high-level way to create compilers and libraries for virtual machines (such as MoarVM and JVM) using Raku syntax.</p><p><a name="index-entry-NQP_(FAQ)" class="index-entry"></a></p> <h2 id="What_language_is_NQP_written_in?" class="raku-h2"><a href="#FAQ" title="go to top of document">What language is NQP written in?<a class="raku-anchor" title="direct link" href="#What_language_is_NQP_written_in?">§</a></a></h2> <p>NQP is a mixture of (1) NQP code, (2) whatever language the underlying virtual machine is using, (3) some third-party C and Java libraries, and (4) some bootstrapping files created by earlier runs of the build process.</p> <h2 id="Is_Raku_Lisp?" class="raku-h2"><a href="#FAQ" title="go to top of document">Is Raku Lisp?<a class="raku-anchor" title="direct link" href="#Is_Raku_Lisp?">§</a></a></h2> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights">(<span class="highlite-OPERATOR">not</span> (<span class="highlite-OPERATOR">not</span> <span class="highlite-TYPE">Nil</span>)) </pre> </div> </div> <h2 id="Can_I_compile_my_script_to_a_standalone_executable?" class="raku-h2"><a href="#FAQ" title="go to top of document">Can I compile my script to a standalone executable?<a class="raku-anchor" title="direct link" href="#Can_I_compile_my_script_to_a_standalone_executable?">§</a></a></h2> <p>Tools like <a href="https://raku.land/github:jnthn/App::InstallerMaker::WiX"><code>App::InstallerMaker::WiX</code></a> allow you to create an installer that will package the compiler and your script. However, the currently available compilers do not support creating a standalone executable yet.</p><p>If you wish to help out, the <em>Rakudo</em> compiler on <em>MoarVM</em> backend has <a href="https://github.com/MoarVM/MoarVM/issues/875">https://github.com/MoarVM/MoarVM/issues/875</a> issue opened as a place to discuss this problem.</p><p><a name="index-entry-Raku_Distribution_(FAQ)" class="index-entry"></a></p> <h1 id="Raku_distribution" class="raku-h1"><a href="#FAQ" title="go to top of document">Raku distribution<a class="raku-anchor" title="direct link" href="#Raku_distribution">§</a></a></h1> <p><a name="index-entry-Rakudo_Star_release_cycle_(FAQ)" class="index-entry"></a></p> <h2 id="When_will_the_next_version_of_Rakudo_Star_be_released?" class="raku-h2"><a href="#FAQ" title="go to top of document">When will the next version of Rakudo Star be released?<a class="raku-anchor" title="direct link" href="#When_will_the_next_version_of_Rakudo_Star_be_released?">§</a></a></h2> <p>A Rakudo Star release is typically produced quarterly, with release announcements <a href="https://rakudo.org/news">posted on rakudo.org</a>.</p> <h1 id="Metaquestions_and_advocacy" class="raku-h1"><a href="#FAQ" title="go to top of document">Metaquestions and advocacy<a class="raku-anchor" title="direct link" href="#Metaquestions_and_advocacy">§</a></a></h1> <h2 id="Why_was_Raku_originally_called_Perl_6?" class="raku-h2"><a href="#FAQ" title="go to top of document">Why was Raku originally called Perl 6?<a class="raku-anchor" title="direct link" href="#Why_was_Raku_originally_called_Perl_6?">§</a></a></h2> <p>… As opposed to some other name that didn't imply all the things that the higher number might indicate on other languages.</p><p>The short answer is that it was Larry's choice under <a href="https://perldoc.perl.org/5.12.4/perlhack.html#DESCRIPTION">Rule 1</a>.</p><p>The community considers Perl and Raku sister languages - they have a lot in common, address many of the same problem spaces, but Raku is not intended to replace Perl. In fact, both languages interoperate with each other.</p> <h2 id="When_will_Raku_be_ready?_Is_it_ready_now?" class="raku-h2"><a href="#FAQ" title="go to top of document">When will Raku be ready? Is it ready now?<a class="raku-anchor" title="direct link" href="#When_will_Raku_be_ready?_Is_it_ready_now?">§</a></a></h2> <p>Readiness of programming languages and their compilers is not a binary decision. As the language and the implementations evolve, they grow steadily more usable. Depending on your needs, Raku and its compilers may or may not be ready for you.</p><p>That said, version 6.c (Christmas 2015) is the first official release of Raku as a language, along with a validation suite and a compiler that passes it.</p> <h2 id="Why_should_I_learn_Raku?_What's_so_great_about_it?" class="raku-h2"><a href="#FAQ" title="go to top of document">Why should I learn Raku? What's so great about it?<a class="raku-anchor" title="direct link" href="#Why_should_I_learn_Raku?_What's_so_great_about_it?">§</a></a></h2> <p>Raku unifies many great ideas that aren't usually found in other programming languages. While several other languages offer some of these features, none of them offer all of them.</p> <ul class="rakudoc-item"> <li><p>Raku offers procedural, object-oriented AND functional programming methodologies.</p></li> <li><p>Easy to use consistent syntax, using invariable sigils for data-structures.</p></li> <li><p>Full grapheme based Unicode support, including Annex #29.</p></li> <li><p>Clean, more readable regular expressions; taken to the next level of usability, with a lot more functionality. Named regular expressions improve ease of use.</p></li> <li><p>Junctions allowing easy checking of multiple possibilities; e.g., <code>$a == 1|3|42</code> (Is <code>$a</code> equal to 1 or 3 or 42?).</p></li> <li><p>Dynamic variables provide a lexically scoped alternative to global variables.</p></li> <li><p>Emphasis on composability and lexical scoping to prevent “action at a distance”; e.g., imports are always lexically scoped.</p></li> <li><p>Easy to understand consistent scoping rules and closures.</p></li> <li><p>Powerful object orientation, with classes and roles (everything can be seen as an object). Inheritance. Subtyping. Code-reuse.</p></li> <li><p>Introspection into objects and metaobjects (turtles all the way down).</p></li> <li><p>MetaObject Protocol allowing for metaprogramming without needing to generate or parse code.</p></li> <li><p>Subroutine and method signatures for easy unpacking of positional and named parameters.</p></li> <li><p>Multi-dispatch for identically named subroutines/methods with different signatures, based on arity, types and optional additional code.</p></li> <li><p>Compile time error reporting on unknown subroutines or impossible dispatch.</p></li> <li><p>Optional gradual type-checking at no additional runtime cost. With optional type annotations.</p></li> <li><p>Advanced error reporting based on introspection of the compiler/runtime state. This means more useful, more precise error messages.</p></li> <li><p>Phasers (like <code>BEGIN</code> / <code>END</code>) allow code to be executed at scope entry / exit, loop first / last / next and many more special contexts.</p></li> <li><p>High level concurrency model, both for implicit as well as explicit multi-processing, which goes way beyond primitive threads and locks. Raku's concurrency offers a rich set of (composable) tools.</p></li> <li><p>Multiple-core computers are getting used more and more, and with Raku these can be used thanks to parallelism, both implicit (e.g., with the <code>>></code>. method) and explicit ( <code>start { code }</code> ). This is important, because Moore's Law is ending.</p></li> <li><p>Structured language support is provided to enable programming for asynchronous execution of code.</p></li> <li><p>Supplies allow code to be executed when something happens (like a timer, or a signal, or a filesystem event).</p></li> <li><p><code>react</code> / <code>whenever</code> / <code>supply</code> keywords allows easy construction of interactive, event driven applications.</p></li> <li><p>Lazy evaluation when possible, eager evaluation when wanted or necessary. This means, for example, lazy lists, and even infinite lazy lists, like the Fibonacci sequence, or all prime numbers.</p></li> <li><p>Native data types for faster, closer-to-the-metal, processing.</p></li> <li><p>Interfacing to external libraries in C and C++ is fairly easy with <a href="/language/nativecall">NativeCall</a>.</p></li> <li><p>Interfacing with Perl (CPAN) and Python modules is fairly easy with <a href="https://raku.land/cpan:NINE/Inline::Perl5">Inline::Perl5</a> and <a href="https://raku.land/cpan:NINE/Inline::Python">Inline::Python</a></p></li> <li><p>Can have multiple versions of a module installed and loaded simultaneously.</p></li> <li><p>System administration simplified due to simpler update and upgrade policies.</p></li> <li><p>Simple numeric computation without precision loss because of <a href="/type/Rat"><code>Rat</code></a>s (rational numbers).</p></li> <li><p>Extensible grammars for parsing data or code (which Raku uses to parse itself).</p></li> <li><p>Raku is a very mutable language (define your own functions, operators, traits and data-types, which modify the parser for you).</p></li> <li><p>Large selection of data-types, plus the possibility to create your own types.</p></li> <li><p>Multi-dimensional shaped or native arrays with proper bounds checking.</p></li> <li><p>Execute code at any time during parsing of a grammar, or when a certain match occurred.</p></li> <li><p>Adding a custom operator or adding a trait is as simple as writing a subroutine.</p></li> <li><p>Automatic generation of hyper-operators on any operator (system or custom added).</p></li> <li><p>Runs on a variety of back-ends. Currently MoarVM and JVM, JavaScript in development, more may follow.</p></li> <li><p>Runtime optimization of hot code paths during execution (JIT).</p></li> <li><p>Runs on small (e.g., Raspberry Pi) and large multi-processor hardware.</p></li> <li><p>Garbage collection based: no timely destruction, so no reference-counting necessary. Use phasers for timely actions.</p></li> <li><p>Methods can be mixed into any instantiated object at runtime; e.g., to allow adding out-of-band data.</p></li> <li><p>Easy command-line interface accessible by <code>MAIN</code> subroutine with multiple dispatch and automated usage message generation.</p></li> <li><p>Fewer lines of code allow for more compact program creation. Huffman-coding of names allows for better readability.</p></li> <li><p>Lazy lists defined with a simple iterator interface, which any class can supply by minimally supplying a single method.</p></li> <li><p>Ability to use hyphens and other non-alphanumeric ASCII characters as well as certain Unicode characters in identifiers. (Using hyphens instead of underscores in test is commonly called "kebab case" among its users. See also "camel case" and "snake case": <a href="https://en.wikipedia.org/wiki/Letter_case#Special_case_styles">https://en.wikipedia.org/wiki/Letter_case#Special_case_styles</a>.)</p></li> <li><p>Raku's mottos remain the same as they have been for Perl all along: “Perl is different. In a nutshell, Perl is designed to make the easy jobs easy, without making the hard jobs impossible.” and “There Is More Than One Way To Do It”. Now with even more -Ofun added.</p></li> </ul> <h2 id="Is_Raku_fast_enough_for_me?" class="raku-h2"><a href="#FAQ" title="go to top of document">Is Raku fast enough for me?<a class="raku-anchor" title="direct link" href="#Is_Raku_fast_enough_for_me?">§</a></a></h2> <p>That depends on what you are doing. Rakudo has been developed with the philosophy of "make it work right then make it work fast." It's fast for some things already but needs work for others. Since Raku provides lots of clues to the JIT that other dynamic languages don't, we think we'll have a lot of headroom for performance improvements.</p><p>The following crude benchmarks, with all the usual caveats about such things, show that Raku can be faster than Perl for similar tasks if the big weaponry is included, that is, if Raku features are used to its full extent; at the same time, Perl can be faster if only the bare bones are included. Similar situations can be observed when comparing Raku to other languages.</p><p>Try it on your system. You may be pleasantly surprised!</p><p>Examples:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-COMMENT"># Raku version </span><span class="highlite-KEYWORD">class</span> Foo { <span class="highlite-KEYWORD">has</span> <span class="highlite-NAME_SCALAR">$.i</span> <span class="highlite-KEYWORD">is</span> <span class="highlite-KEYWORD">rw</span> }; <span class="highlite-KEYWORD">for</span> 1..1_000_000 <span class="highlite-KEYWORD">-></span> <span class="highlite-NAME_SCALAR">$i</span> { <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$obj</span> <span class="highlite-OPERATOR">=</span> Foo.<span class="highlite-ROUTINE">new</span>; <span class="highlite-NAME_SCALAR">$obj</span>.i <span class="highlite-OPERATOR">=</span> <span class="highlite-NAME_SCALAR">$i</span>; } </pre> </div> </div> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Perl highlighting by highlight-js</label> <div> <pre class="nohighlights"><pre class="browser-hl"> <code class="language-perl"># Perl version package Foo; use Moose; has i => (is => 'rw'); __PACKAGE__->meta->make_immutable; for my $i (1..1_000_000) { my $obj = Foo->new; $obj->i($i); } 1; # Another Perl version that offers bare-bones set of features # compared to Moose/Raku's version but those are not needed in this # specific, simple program anyway. package Foo; use Mojo::Base -base; has 'i'; for my $i (1..1_000_000) { my $obj = Foo->new; $obj->i($i); } 1; </code></pre> </pre> </div> </div> <p>You might want to use this program for comparing performance, too. It works under both languages, as long as <code>perl -Mbigint</code> is used for invocation for Perl.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> (<span class="highlite-NAME_SCALAR">$prev</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_SCALAR">$current</span>) <span class="highlite-OPERATOR">=</span> (1<span class="highlite-OPERATOR">,</span> 0); <span class="highlite-KEYWORD">for</span> (0..100_000) { (<span class="highlite-NAME_SCALAR">$prev</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_SCALAR">$current</span>) <span class="highlite-OPERATOR">=</span> (<span class="highlite-NAME_SCALAR">$current</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_SCALAR">$prev</span> <span class="highlite-OPERATOR">+</span> <span class="highlite-NAME_SCALAR">$current</span>); } <span class="highlite-ROUTINE">print</span> <span class="highlite-NAME_SCALAR">$current</span>; </pre> </div> </div> </div></div></section> </div> </div> </div> <footer class="footer main-footer"> <div class="container px-4"> <nav class="level"> <div class="level-left"> <div class="level-item"> <a href="/about">About</a> </div> <div class="level-item"> <a id="toggle-theme">Toggle theme</a> </div> <div class="level-item" title="267fb7503 2024-10-26"> <a>Commit</a> </div> </div> <div class="level-right"> <div class="level-item"> <a href="/license">License</a> </div> </div> </nav> </div> </footer> </body> </html>