
Perl 6 Introduction - bane
http://perl6intro.com/
======
s_kilk
I've got to say, perl6 is really, really fun to play with. (and I say this as
someone who had not used perl before)

So far I've gotten the impression it's made by a bunch of smart, friendly
hackers who care about quality in their software.

To anyone reading this, I'd strongly recommend casting aside any preconceived
notions about perl and giving perl6 an honest shot.

~~~
user9756
I'd like to take perl6 for a spin. However, other than playing with it I'm not
sure how it compares to say python or ruby in terms of strong sides. I mean
what are the cases perl6 would shine in comparison? (NOT TO FLAME! I'm asking
for ideas to when perl6 would be an interesting tool for the job. AFAIK it had
a good string manipulation ~ also I'm still reading the tut and currently it
feels very bash and somewhat ugly (although helpful) with the % & @ prefixes).

~~~
s_kilk
A few upsides I perceive:

\- optional, well-integrated gradual typing system.

\- perl6 is the first mainstream(ish) dynamic language to not suffer from a
GIL of some kind. You can do real concurrency and parallelism in perl6.

\- perl6 is both equally as powerful, and much more simple than previous
versions of perl.

\- a bunch of good ideas stolen from other languages. go-routines are in
there, pattern-matching, gradual typing, classes, etc. Plus, functional
programming is a first-class-citizen of perl6. There's so much good stuff in
there.

\- overall, I think perl6 has the potential to become a very powerful (and yet
robust and well engineered) hacker language, where you will not be constrained
by implementation details of the VM the language runs on (I'm looking at you,
GIL).

I'd also recommend reading Curtis Poe's answer to a similar question:

[https://www.quora.com/Perl-programming-language-1/Should-
I-b...](https://www.quora.com/Perl-programming-language-1/Should-I-be-
interested-in-Perl6)

~~~
_wmd
> \- perl6 is the first mainstream(ish) dynamic language to not suffer from a
> GIL of some kind. You can do real concurrency and parallelism in perl6.

I went digging to try and understand what this meant, and seems it's referring
to syntactic support for promises, which in at least the Rakudo implementation
amount to a wrapper around a forking multiprocessing system (like the Python
multiprocessing module).

From my perspective this concurrency isn't any more "real" than equivalents
available in existing languages, but maybe I'm looking at the wrong thing -
you mention global interpreter locks, and usually they refer to threading.

Does some implementation of perl6 have non-GIL threading?

edit: from
<[https://perl6advent.wordpress.com/2012/12/11/day-11-parrot-t...](https://perl6advent.wordpress.com/2012/12/11/day-11-parrot-
threads/>):

> The solution for these problems implemented in hybrid threads is to sidestep
> them altogether by disallowing write access to shared variables. The
> programmer (or in most cases the compiler) is obliged to declare a list of
> all shared variables before a newly created task is started. The interpreter
> would then create proxy objects for these variables which the task can use
> to access the data. These proxies contain references to the original
> objects. They use these references to forward all reading vtable functions
> to the originals. Write access on the other hand would lead to a runtime
> error.

> In other words, all data is owned by the thread creating it and only the
> owner may write to it. Other threads have only read access.

> For threads to be able to communicate with their creators and other threads,
> they still need to write to shared variables. This is where green threads
> come into play. Since green threads are light weight, it is feasible for a
> thread to create a task just for updating a variable. This task is scheduled
> on the interpreter owning this variable. To reduce latency, the task is
> flagged to run immediately. The data-owning interpreter will preempt the
> currently running task and process the new write task. Put another way, the
> data-owning interpreter is told what to write to its variables, so other
> threads don’t have to.

~~~
gpvos
GIL stands for the Global Interpreter Lock, which python has been criticized
for a lot. I don't know whether perl5 or other languages have one, really.

~~~
jnbiche
> GIL stands for the Global Interpreter Lock, which python has been criticized
> for a lot.

It's pretty clear the GP knows what a GIL is, he's wondering if Perl 6 is
truly GIL-free, or if it "just" abstracts out the GIL using language
primitives for a forking multiprocess system (already, that's a nice step, but
it's not "GIL-free").

I'd like to know the same thing.

~~~
gpvos
(Side remark: it seems the comment has been edited, expanding it a lot. It was
not clear to me initially. And anyway, it is good to have acronyms expanded
for other readers.)

------
user9756
Great (basic) introduction with exception to the regex chapter because it felt
like an introduction to regex instead of the regex features of perl6.

Some things I found interesting (in addition to what s_kilk mentioned and
linked to and others have already mentioned some of them) * Gradual typed! *
Multi subroutine * Hyphen in variable names * @numbers.=sort * .WHAT * Catch
blocks * .defined * Unless

It will be fun :)

I however don't understand the reason for the naming of eg elsif, my,
slurp/spurt?? (instead of else if or local or fread/fwrite) Is it a perl
culture thing? Because they mention in the tutorial that Perl 6 belongs to the
C-family languages (and then call the "for" loop in C "loop").

~~~
username223
> I however don't understand the reason for naming of eg elsif, my,
> slurp/spurt??

Yes, it's for historical reasons. "elsif" is spelled that way in Perl 5. Perl
5 has both "my" and "local" to specify lexical and dynamic scoping,
respectively, so Perl 6 using "local" for lexical scope would be confusing.
"slurp" is a common term for reading the entire contents of a file at once.

~~~
cafard
"my" arrived after "local". The former is true lexical scoping, the latter
isn't quite.

~~~
tbrownaw
Right. As gp says, "local" is _dynamic_ scoping.

It's available as long as the declaration stays on the call stack. It more-or-
less allows globals to be temporarily redefined.

~~~
DonHopkins
Think locally, act globally.

------
imglorp
I am so happy they've included kebab-case identifiers :-) I've always thought
they made more sense than camel or snake, because there's no shift key
involved. It also brings fond memories of fun in lisp land.

~~~
jrumbut
I'm so happy to learn the term kebab-case (and agree that it's very usable and
supremely typable)

------
krylon
I really like the fact that Perl6 has a proper type system.

I like even more that you can mix static and dynamic typing, so to speak.
After taking their sweet time, I am not overly confident about adoption of
Perl6, but I hope I'm wrong.

At least, from what I can tell so far, Perl6 manages to keep the spirit of
Perl, while fixing a number of things that were wrong, or at least
problematic, in Perl5.

------
peteretep
I wish programmers could break away from "tutorials" and "introductions" that
are just lists of syntax and keywords.

I want short examples, brief explanations of those, and then some problems to
solve.

~~~
grondilu
Have you looked at the synopses (1)? That's how I've learnt Perl 6, and I've
never been convinced by any other kind of Perl 6 documentation. To me the
synopses are complete and explanatory enough. As far as problems to solve,
there are the various entries in rosettacode (2).

1\. [http://design.perl6.org/](http://design.perl6.org/)

2\.
[http://rosettacode.org/wiki/Category:Perl_6](http://rosettacode.org/wiki/Category:Perl_6)

------
stesch
monthly-salary = daily-rate * working-days

Wow. This will make a few people happy who think underlines and camel case are
ugly.

~~~
Sharlin
Adding the missing $ sigils will uglify it quite a bit, though.

~~~
zoffix222
They don't need to be "missing". my \working-days = 200; Creates a working-
days variable that you can't change.

~~~
awwaiid
Isn't that sort of a mis-feature that we don't expect to see in code very
much? I thought mainly people would be using sigils, and ideally the correct
sort of sigil to indicate if it is a single thing, list of things, hash of
things, callable thing, etc.

~~~
zoffix222
I wouldn't call it a misfeature. I think especially in math stuff it would be
useful. I've used Δ in my math for Color module and it both has the natural
mathematical meaning and must not change after I calculate it:
[https://github.com/zoffixznet/perl6-Color/blob/master/lib/Co...](https://github.com/zoffixznet/perl6-Color/blob/master/lib/Color.pm6#L231)

What is a mis-feature is you can't assign-create to these variables when
they're part with sigil-bearing variables, so, for example, here I ended up
using a sigiled-Δ, which isn't as pretty :)
[https://github.com/zoffixznet/perl6-Color/blob/master/lib/Co...](https://github.com/zoffixznet/perl6-Color/blob/master/lib/Color.pm6#L142)

~~~
raiph
Aiui it's for any time a coder prefers that a noun's name does not
emphasize/convey the basic nature of the thing the noun refers to.

Fwiw you can assign to such "raw" nouns if you declare that the raw noun
you're declaring refers in turn to a rw container. For example, a plain `$` is
a container (an anonymous Scalar):

    
    
      my \Δ = my $ = 100;
      Δ = 200;
    

I came up with the following idiom when pondering snippets on twitter and the
fundamental problem that twitter treats strings of the form `@foo` as twitter
handles which messes up the formatting of tweets containing `@` sigil'd nouns:

    
    
      my \array =@= 1,2,3; array[2] = 200; say array;
    

displays

    
    
      [1 2 200]

------
zimbatm
Does Perl 6 have fundamental features that don't exist in other languages ?
Just curious.

~~~
perlgeek
I don't know if any of these features are really unique, but the combination
of having them all is certainly unique:

* Strings that are made of Unicode grapheme clusters instead of codepoints or bytes. This means that a substr() operation for example can't even accidentally rip a apart a base character and a combining character on top of it

* Grammars as a language feature

* Gradual typing

* A built-in meta object protocol

* Concurrency based on high-level primitives (promises, queues, supplies, ...) with syntactic support (instead of threads and locks; which are still available if necessary, but discouraged, because they don't compose well).

* Lazy lists

~~~
Woodi
Yea, grammars looks simple-the-unique thing other languages don't have in
2015, 2016 and, I bet, 2017 too. Maybe even longer :)

~~~
kamaal
That's only at level 1, until you realize Perl 6 code is parsed by a grammar
written in Perl 6.

Its power is amplified by the part Perl 6 regexes are better than anything
there is out there.

Even better, this extends beyond ASCII and applies to Unicode too. And will
work with other powerful control structures.

I'd fix that date to something like 2027.

------
doodpants
This guide is gorgeous; the choices made for fonts, styling, and formatting
are just perfect. I wish more online documentation looked this good.

~~~
justinator
Peeping at the source code, looks like this may have been generated by
[http://asciidoctor.org](http://asciidoctor.org) (in case you would like
something similar for yourself).

For Perl-folk, there is a module to convert between POD and Asciidoc:

[https://metacpan.org/pod/Pod::AsciiDoctor](https://metacpan.org/pod/Pod::AsciiDoctor)

------
DyslexicAtheist
I'm looking for several Perl developers in Berlin for a full-time permanent
position:

[http://valbonne-consulting.com/job/perl-or-lua-software-
deve...](http://valbonne-consulting.com/job/perl-or-lua-software-developers-
real-time-bidding/)

------
lovboat
At first sight I find amusing comparing Ruby to Perl 6. (a=. sort) (a.sort!)
(a.what) (a.class) (say a) (puts a) (for @a=>item) (a.each {|item| ..} ) and
the similarities, push, shift, splice, ...

I see nothing new here. But I must say that Perl 6 seems to be easier to learn
than Perl 5 for beginners.

~~~
justinator
This is just a little intro cheat sheet, it's not supposed to be scary - quite
the opposite, in fact. Easy things should be easy.

The magic is in the more advanced parts of the language. The, "hard things
should be possible" parts.

~~~
lovboat
Show me the more advanced parts of the language, are they transducers, monads,
functors, natural transformations, auto-compilers, self-replicating systems,
high AI in action, ML, NLP. What is the honey spot for this new language?

~~~
kbenson
Here's a short list of some interesting things: phasers[1], lazy evaluation,
feed operators[2], grammars[3], meta/hyper operators[4], subtypes[5], multiple
dispatch[6].

1:
[http://design.perl6.org/S04.html#Phasers](http://design.perl6.org/S04.html#Phasers)

2:
[https://en.wikibooks.org/wiki/Perl_6_Programming/Lazy_Lists_...](https://en.wikibooks.org/wiki/Perl_6_Programming/Lazy_Lists_and_Feeds)

3:
[http://design.perl6.org/S05.html#Grammars](http://design.perl6.org/S05.html#Grammars)

4:
[http://design.perl6.org/S03.html#Binary_hyper_operators](http://design.perl6.org/S03.html#Binary_hyper_operators)

5:
[http://design.perl6.org/S12.html#Types_and_Subtypes](http://design.perl6.org/S12.html#Types_and_Subtypes)

6:
[http://design.perl6.org/S12.html#Multisubs_and_Multimethods](http://design.perl6.org/S12.html#Multisubs_and_Multimethods)

------
sigzero
I love that Perl 6 has a proper REPL now.

~~~
raiph
A note of caution; it's way better than nothing and will get where it needs to
be one day, hopefully in 2016, but it currently uses some awful hacks that
make it suck for a lot of stuff.

~~~
sigzero
I know but I am really glad that they went this route.

~~~
mst
For perl5 I'd commend unto you Reply, which manages to learn from most of the
mistakes I made in Devel::REPL

------
HeadlessChild
When is Perl 6 going to be a standard installed package for the Linux
distributions (Debian, CentOS, Ubuntu)?

~~~
perlgeek
I don't think anybody can predict the future well enough to answer that.

Languages become part of the standard installation by having very commonly
used toos written in them.

I might be wrong, but I'm pretty sure ruby isn't part of a standard Debian
installation, and neither is lua, for example. Ruby is very popular for web
apps, but you don't need web apps to boot the computer, start a GUI and
install packages, so it's not part of the standard installation.

But it's only an 'apt-get install ruby2.1' or so away, and so is rakudo (the
current Perl 6 implementation). The debian package in stable is outdated, but
work on newer versions is in progress. (Don't know about CentOS, sorry).

------
mundanevoice
I am curious, what's the use of learning perl6 in 2015?

~~~
krylon
Well, I can tell you what's the use of learning Perl 5 and that I suspect most
of it will apply to Perl 6 as well:

Perl, more than any other language I know, sacrifices nearly every other
property in the name of being useful. It's not a conceptually clean language,
or an elegant one, or a simple one, but if you need to get stuff done, _now_ ,
there is very little that can compete with it. (At least for some rather
specific values of "stuff" \- Perl, IMHO, really shines at small-ish scripts
that need to convert data from some format to another, or merge data from
different sources, especialy when lots of text-handling are involved). Parsing
a log file, or matching user accounts from a Windows domain with employee
records in an ERP system's database are two examples that come to mind because
I had to do those things not too long ago.)

Perl 5 has problems though, especially when it comes to writing large-ish
programs. While you can write readable und unreadable code in any language,
Perl makes writing unreadable, unmaintainable code easier than, say, Python.
Perl 6 tries to fix a lot of this while remaining as useful as Perl 5 (or at
least trying to).

~~~
username223
> Perl, more than any other language I know, sacrifices nearly every other
> property in the name of being useful.

Another factor that mattered back during Perl's heyday was the insane lengths
it went to for maximum portability. The Perl porters shouldered the burden of
making it run on DOS/Windows, Mac OS, VMS, and all the weird Unices that
existed at the time. This doesn't matter as much nowadays, but it was crucial
back then.

If you had a text-munging or scripting problem, and wanted to solve it once
and for all, Perl was the perfect tool.

~~~
ribasushi
FWIW perl __currently __builds and __passes tests __on z /OS, under straight
EBCDIC:
[http://www.nntp.perl.org/group/perl.perl5.porters/2015/11/ms...](http://www.nntp.perl.org/group/perl.perl5.porters/2015/11/msg232907.html)

~~~
username223
And this is why Perl is awesome: IBM mainframes are the opposite of sexy, but
some people use them, and Perl will work there.

------
ihsw
For those looking to get started with Perl6 in Docker -- here is the related
Docker Hub page:

[https://hub.docker.com/_/rakudo-star/](https://hub.docker.com/_/rakudo-star/)

And its GitHub repo:

[https://github.com/perl6/docker](https://github.com/perl6/docker)

