Instead, I think that P6 is worth looking at because of the "feel" of the language, or perhaps another way to put it is the way that all the pieces fit together. I found it easy to do the following in Perl 6:
1. Quickly write a small proof of concept program
2. Heavily use concurrent and asynchronous code in a way that "just works"
3. Fluidly mix imperative, functional reactive, and object oriented code
4. Add types for safe refactoring / further development
Even though Perl 6 still abides by TIMTOWTDI (There Is More Than One Way To Do It) there was "something" that gave a consistency to all of the above. Or perhaps, nothing felt bolted on, which is perhaps a luxury of essentially starting from scratch. :)
Perl 6 is not only fun to write, but also easy to read (once you of course learn the syntax, which is quite different coming from not-perl). My hope is that the ease of using its OO features and type system will help avoid the "hash-of-who-knows-what" problem.
Lately the two languages I most enjoy using are Perl 6 and Go, which would appear to be almost total opposites! But they both have that "something" that just feels great to write. This is of course subjective, but I hope it's helpful somehow.
Perl5 was feeling the weight of its humble origins as a small language for scripts, designed in the 80's. All that $@%<>$_ syntax, and bad support for keeping larger programs clean and organized.
Python's main selling point was: like Perl, but cleaner syntax and object system is in-build, not bolted on as an afterthought.
Also Ruby's selling point was: Perl, flexible for meta-language hacking like Perl, but cleaner syntax and in-build object system, also not as restrictive as Python.
Now Perl6 has everything that at a time made Python or Ruby feel more modern than Perl5, and more, even optional typing. (Well, it doesn't have Python's opinionated restrictiveness.) Of course at the moment, Perl6 doesn't have the huge selection of libraries that Python and Ruby have at the moment.
I don't know what, if anything, is a good reason for you to learn a new language. But while in the trio perl5,python,ruby perl5 was the most dated, old-feeling language, now in the trio perl6,python,ruby Perl6 is now the most modern in its design.
Well, there is Inline::Python...
I had zero perl experience before diving into perl6. I've found it to be a great language with a fun community.
As for compelling features, there was a good discussion on this a few days ago, so I'm just going to link to that: https://news.ycombinator.com/item?id=10637789
This was not its reputation BITD.
Program something in it, and if you get a good feeling, then probably a lot of other people will too, and the language will take off.
Larry Wall is a linguist, and I think that is probably what sets perl apart more than anything.
But yes, it happens to have the kitchen sink, too.
[1] Unless you have hard requirements, like control over memory or runtime environment.
He's also pretty good at telling jokes, which explains a lot of things about Perl ;-)
The regex system is also part of grammars, which did not exist natively in Perl 5.
I am not following your issues with the versioning. Perl6 was supposed to be released like back in 2005 or so. In that context it made sense that the next release of Perl would be 6 and that the 5 series would just go into maintenance only mode. But that didn't really happen. Perl5 devs continued to do their own thing while a new community was built around Perl6 with different people.
As I understand it, Perl 6 is essentially a complete language overhaul. However, the sequential numbering implies an iteration. To me, that's unintuitive.
At the risk of over-analogizing, it's a bit as if Scala had been released as Java (n). Totally, completely irrational? Maybe not. Confusing? Almost certainly.
> Confusing? Almost certainly.
Agreed. I don't know if it would've been better for Perl6 to not have 'Perl' in its name, but it almost surely would have been better for Perl5 if Perl6 hadn't had 'Perl' in its name.
This is a bit pedantic, but I think a better analogy might be Dutch and German - similar roots, but where fluency in one doesn't confer fluency in the other.
Granted, I haven't touched Perl 6 so the magnitude of difference I'm estimating is based off of a very superficial impression.
Python 2 & 3 might be somewhat akin to American & British English.
> It almost surely would have been better for Perl5 if Perl6 hadn't had 'Perl' in its name
Agreed. From a distance, there's definitely the sense that Perl5 was sacrificed for the benefit of Perl6.
At this point I think most programmers are at least slightly aware of the 5/6 debacle and I feel that both languages actually benefit from it! It makes people think about versioning, sisterhood, and syntax! Which are all important things for programmers to think about. But really, everyone's got an opinion on the matter and that's kind of what makes it so great.
Will I be able to write a dictionary of dictionaries or arrays without looking at the documentation every time? Did Perl 6 syntax for references got sane?
so for instance a dictionary of dictionaries or arrays looks like:
my %dict = {
'foo' => {
'bar' => [ 'an', 'array' ],
'a deeply nested word' => "tada!"
},
'an empty dict' => {},
'an empty array' => []
};
say %dict{'foo'}{'a deeply nested word'}; # tada! my %hash = (
# your key/values
);
and not, my %hash = {
# your key/values
};
I think that may be one of the problems people have with Perl - the syntax gets a little whacky and it's hard, sometimes, to wrap your mind around Perl-style references.My personal way to solve this is to almost exclusively use references in complex data structures, so:
my $hashref = {
another_hashref => {
key_name => [qw(
value
is
an
array_ref
)],
},
};
Is a hashref, that contains another hashref, which contains an array ref. Easy to bring up the 3rd thingy in the arrayref: print $hashref->{another_hashref}->{key_name}->[2]; #an
This should be somewhat palatable to do actually, if you're slinging JSON all day.Notice how in Perl 6 you get a nice error message:
$ perl6 -e 'my %h = { foo => "bar" };'
Potential difficulties:
Useless use of hash composer on right side of hash assignment;
did you mean := instead?
at -e:1
------> my %h = { foo => "bar" }⏏;Are you talking about something like this:
$hash_of_hash = {
hash1 => {key1 => 'value1'},
hash2 => {key1 => 'value1'}
};
say $hash_of_hash->{hash1}{key1};
Seems easy to me...I think reference syntax in Perl6 is gone. Which personally I don't like.
Both are cleared up by really understanding context as it applies in Perl 5, which is probably the single largest difference to other languages that is (sometimes unfortunately) easy to get along without understanding because of the DWIMiness of the language. Or references, but I tend to think most people should be able to understand them without too much trouble.
%hash = {key1 => 'value1'}
$hash_of_hash->{hash1} = %hash
Now, this will work (or something like it, I don't remember the syntax):
%hash = {key1 => 'value1'}
$hash_of_hash->{hash1} = \%hash
The syntax makes a lot of sense when you read the specs. It does create lots of problems when you try to create complex data structures in practice. It's also complex enough (with enough corner cases) that I can't remember it if I don't use it every week - but maybe that's just me.
By the way, I don't remember whether I must read the above structure as:
$hash_of_hash->{hash1}{key1}
or
$($hash_of_hash->{hash1}){key1}
I also don't remember if it is equal to the one you defined. I know it's in the documentation, and it's very clear there. It's just some corner case that I never bothered to memorize for any long time.
%hash = (hello => 'there');
%hash = ('hello', 'there');
This is also perfectly valid (though non-idiomatic) Perl 5: print Hello => ' ' => there => "\n";So look at it as Perl VI, minor version 0. :)
Perl6's main strength and which makes it "fun" is that it is multi-paradigm. It supports many ways of approaching a problem, instead of forcing a particular model. So you get a toolbox instead of just a modular hammer.
The versioning was weird, but it could have been worse. At least they didn't take the PHP option and leap from v5 to v7 because the number 6 was cursed.
As a non-Perl dev who has been looking into Perl 6 after encountering some posts and samples, I'd say it is, though unfortunately the kind of documentation that would make the most interesting bits easily approachable is still somewhat lacking.
Can you be more explicit? I'm not a Perl 6 dev but I would love to help adoption and I'm not so bad at documentation.
[0] at https://docs.python.org
However, you bring up a good point as to the Language Reference / Library Reference. I'm not sure if there's anything remotely comparable for Perl6. I'll get looking into what it would need to add it. Also fwiw Perl6's stdlib is not as bare as 5s.
There was one published by O'Reilly about ten years ago, but of course back then you could not say "apt-get install perl6" or something equivalent. Also, the language definition was far from finished, back then, so that book is probably totally outdated by now.
The Perl community, as far as I can tell, has no lack of talented writers, so I am optimistic something will be written before too long.
Another reference you might want to look at is "Modern Perl" (http://modernperlbooks.com/).
And really, I would like something I can read offline, preferably as a PDF. I know we live an always-online age, but really, I want something I can read on the train where I have no Internet access, and I want to be able to search the documentation without having to send a request to a web server.
I am aware there are of http://www.perl6.org/documentation/, but the docs there seem to be ... not organized in the way my brain is used to.
Another reference that just comes to my mind is the Python documentation, which IMHO is superb. It's well organized, concise and to the point, without being spartan.
Just to be clear, I do not expect you to do all that work, but if you want starting points what I would like Perl 6 documentation to look like, now you know. ;-)
Indeed and an excellent summary it is. How do you feel about the beginnings of this? https://en.wikibooks.org/wiki/Perl_6_Programming
I have never written non-trivial amounts of documentation, so I can only guess, but I have the gut-feeling that structuring documentation well is pretty hard, much like interface design (both for APIs and UIs) is (to me, at least) very hard. So having a well-structured but incomplete Wikibook as a starting point is probably a lot better than vice versa. ;-) The parts that are there are well-written.
that said, I don't think it's failing by this metric.
I personally avoid it like a disease... Python + Ruby + JS are wayyy more used and future proof
Do you prefer what python did? Python 2 vs. Python 3 is a complete and utter mess. Perl, which exists mostly in the same use case, shouldn't have any of those problems.
Besides being off topic and adding no value to this thread, for those of us who made the transition to Python 3 with minimal fuss, this is just pure hyperbole. I really wish people would quit grinding their Python 2/3 axes.
I also made the transition to `#!/usr/bin/env python3` fairly smoothly. That doesn't mean that the majority of the community did. Python3 came out in 2008, next week will be seven years of it being out. Yet `#!/usr/bin/env python` still defaults to python2[1]. That's not quite the expected 5 years of transition that they hoped for. At year 5 it looked like this [2].
[1]: http://legacy.python.org/dev/peps/pep-0394/
[2]: https://web.archive.org/web/20131204094939/http://python3wos...
On the logical flipside, 3 also doesn't alter nearly as much as 6. It was intended (and largely functions) as an iteration - not a backwards incompatible re-write.
It's not an irrelevant comparison, but I feel like it's an overstated one.
The main "problem" of the Python transition is the fact that Python 2.7 is so good.
The biggest problem about Python is not the superiority of 2.7, it's the hubris of the Python community to think that 2.7 is actually that great.
I would send any Python programmer on a course of writing Golang and Perl 6 and I would put money on the line they would come out a better programmer. That's what I feel happened to me to some extent.
And for the last years, we've had the bliss of a stable programming language. So much in open source constantly brings out new versions that you have to keep your stuff compatible with all the time.
It's this reason why I think learning as many languages as possible is a good thing. I can't imagine what'd I'd be missing out on if I was stuck programming Java 6 for a decade.
There were numerous systems that needed both 1 and 2 in the Redhat ecosystem. I agree it likely won't happen again, but mostly because the Linux distros have likely learned their lesson. It's the package managers and Linux distros with included system functionality written in some version of Python which have the ultimate say, and there are much better solutions for the problem now than when Python 2 came out. That said, it's possible some distro will make /usr/bin/python be Python 3 and /usr/bin/python2 be Python 2, if they haven't already. Weirder stuff happens all the time.
Arch linux already has.
I might be an exception, but I've had very few issues with the Python2 to Python3 transition. Python3 made the language more consistent, made a lot of little things simpler and easier, and added several features that makes using it generally more straightforward than Python2. It's essentially the same language, with warts removed. Library support lagged a bit, so on the odd occasion I need an old library, I just use Python2. Both versions can coexist on the same system, so it's not a big deal.
More relevant, though, Python3 was announced and then released when they said it would be. Some parts of the library community dragged their feet with support, and in a lot of cases they were replaced with even better libraries. The important thing is that the language was out and people could use it, and everybody's on the same page that Python3 is the future of Python.
The Perl transition has been a total mess in comparison. Perl6 is not just removing the warts from Perl5, it's an entirely different language. It's been "right around the corner" for almost 15 years now, and as far as I can tell, still isn't released. And good luck porting 25k CPAN modules to a completely new language.
To put it another way, in 15 years Perl6 has gone from announced to still not existing, while in 8 years Python3 was announced, released, and has had vast parts of its library ecosystem have been ported. Seems hard to believe anybody would say the Perl6 transition has gone better.
So should anyone, as it changes only minimal sections of the language. It may remove warts, but in my eyes it re-adds many. I never had typing issues with dictionary keys being strings vs ints in Python 2. I do however have to suffer from that in Python 3.
The fact is, Python 3 barely fixes /any/ of the fundamental problems with Python 2. After writing a little Go and coming back to Python i couldn't believe how little static checking there is, for example.
Another example for you, I have functions which take named parameters, but one of those named parameters I need to be a list.
If it's not a list, python's 'for x in y' will split the string and provide a character based loop. If it is a loop it will split based on loop elements.
This means that I have to have a bunch of isinstance checks wrapped around things and provides no safety whatsoever as I would have to exclude all types other than arrays to even begin to have any rigor.
I don't think Python 2 or 3 is a bad language, but 3 fixed only some of the most superficial issues with 2 and still the transition is ongoing after 8 years. You're glossing over how much of a mess it's been and how much it will continue to be.
I don't even see what your complaints have to do with the Python2/3 transition. Python isn't a statically typed language, so obviously Python3 isn't going to fix badly written code with type errors.
Regardless, if Python2 to Python3 has been a mess, clearly Perl5/6 has been an even bigger mess because they haven't even managed to release the interpreter, much less start moving to it.
I wasn't trying to imply you're intentionally glossing over things, just that the situation isn't as simple as your post made out.
> I don't even see what your complaints have to do with the Python2/3 transition. Python isn't a statically typed language, so obviously Python3 isn't going to fix badly written code with type errors.
Perhaps I'm wrong, but these errors only seemed to occur in 3, and I've read elsewhere it introduced additional 'hidden' type constraints.
> Regardless, if Python2 to Python3 has been a mess, clearly Perl5/6 has been an even bigger mess because they haven't even managed to release the interpreter, much less start moving to it.
Perl 6 isn't really an interpreter, and the same sort of transition is very unlikely to occur. It essentially is an entirely different language that's just very perl-y.
The migration path from Perl 5 to 6 is like going from C to C++ or D. Basically there is no 'migration path'. C didn't go away after C++, neither did the whole rewrite C applications to C++,Perl 5 is not going to go way after Perl 6.
>> because they haven't even managed to release the interpreter, much less start moving to it.
They released a beta and production release is coming out this christmas.
Clearly you have a lot catching up to do.
TBH, I'm not planning on catching up. I skim through the Perl6 articles that get posted here to see how things are evolving, and AFAICT Perl6 doubled down on all the Perl5 features I liked the least. More "magic"; more arcane symbols and operators; more context aware variables, syntax and semantics; etc.
It will be possible to import most Perl 5 modules with the 'use v5;' feature.
use Inline::Perl5;
use Foo:from<Perl5>;
I can imagine for Inline::Perl5 to eventually end up as a core module like NativeCall, but that's just speculation on my part.I don't think it's implemented yet, and I doubt it will be for Xmas. But it will eventually.
You do, currently.
I don't think it's implemented yet
It is - nine's Inline::Perl5 module has been around for a year or so.
I have no plans to look at Perl 6.
This may be inflammatory, but it's my earnest impression : as an outsider, I really don't like how Perl's versioning was handled (5 vs. 6). On top of being unnecessarily confusing, it also gives an impression of complete mismanagement - fair or not.
With so many languages out there to choose from, what sets Perl 6 apart from other modern languages and ecosystems?