107 points · by hankache · 10y ago · 146 comments
I say don't worry about the criticism and popular opinion: The specific language you use is pretty far down the list of problems that a given software might have. You'll build up some useful libraries in your niche and eventually other people will see that the most time-effective way to solve a problem in that niche is to use Perl 6 to get access your libraries.
Every other language I use derives from its specific purpose: Ruby because vendors like PayPal or AWS publish Ruby gems(and because of Rails); Haskell for writing parsers, interpreters, and compilers(ADTs and parsing monads); C if I'm trying to understand some code and need it to be portable or operationally simple; Perl 5 if it's a quick prototype script. Just the other week I needed a Bayesian variant of Prolog and would've used Perl 6 if it had a library for it.
The hatred P6 receives here reminds me a lot of the hatred Go used to receive, where every article posted devolved into a discussion regarding the lack of generics. I bought into the "Go is a regression" meme for a long time until I started using it to solve real problems at work, and now I love it.
I hope that we programmers can learn to rejoice in each other's creations rather than to heap scorn and criticism on anything not from our particular tribe. It reminds me of people who insist that you can only like a single video game console... heaven forbid you use more than one, or one with inferior graphics (but with more fun games!), etc.
Hackers or not, we're all still human, and experience emotions like frustration and disappointment. Back when perl6 was first being discussed (what was it, 15 years ago now?), probably a lot of us were getting a ton of mileage out of the remarkable perl5 ecosystem.
When perl6 started getting promoted, it seemed like it took a lot of the wind out of the perl5 sails, like an Osborne effect for a programming language.
When the years ticked by and nothing came of it, and lots of moved onto other languages, I imagine a lot of people still remembered being disappointed at how the perl5->6 situation played out.
Probably some of the negativity is just remnants of that, because, like I said, we're all still human.
And schadenfreude, I'm sure, plays into it, like when the overhyped disappointments Daikatana and Duke Nukem Forever were released...
Anyway, just one man's opinion, of course...
I don't know if Perl programmers have been separated from the other scripting languages too much as not to understand that there are different mindsets out there.
Perl has always been quite a confusing language if you only skimmed it (lots of incoherent features and more than one way to do it), so I find it natural that Perl6 isn't any better.
But if you don't explain the confusing features of a language well enough, puzzlement and confusion is what you get.
My impression is rather that the P6 marketing has traditionally focused on presenting a long list of features instead of a user-focused business case.
If not us, then who? There is plenty of space for a language that delivers real innovation, or even one that puts real polish on old ideas. But when a language does neither, we absolutely should be asking what it's for. A community that prides itself on being pragmatic and delivering business value should know the costs of language proliferation.
Oh please. Perl 6 does both of these very nicely. Dismissing it out of hand as you have just done is exactly what the parent is complaining about.
jnthn has a great series of blog posts illustrating how many of Perl 6's features come together to make developing a library very easy. To me, this is a great example of "how does Perl 6 help a business": by allowing rapid development of a complex asynchronous application, which is a use case many of us face. He illustrates this by writing a STOMP client for RabbitMQ, going from toy to a serious library: https://6guts.wordpress.com/2016/01/04/not-guts-but-6-part-1...
I look at this workflow and think, "Wow, I wish I could do things that easily." But now I can, because Perl 6 is out. :)
#!/usr/bin/env perl6
if 3|4|5 == 5|6 {
print "Junction found\n"
} else {
print "No junction\n"
}
...or using arrays this seems to be the way to do it... #!/usr/bin/env perl6
my @first = <3 4 5>;
my @second = <5 6>;
if any(@first) == any(@second) {
print "Junction found\n"
} else {
print "No junction\n"
}However ridiculous it sounds, a weight is lifted from my chest.
I mean, it's nice that this sort of functionality has nice and concise operators, but I'm coming from a school of thought where overloading the equality operator should not be done lightly :)
Each operator and its overloads -- certainly built ins, users are recommended to follow suit -- conceptually maintains its own single high level semantics. Thus, while some langs have a `+` op that does numeric addition or string concat based on operand types, in Perl 6 a `+` will always mean numeric addition (unless a user breaks this convention).
`==` is always numeric value equality.
`==` does what most folk would expect between any pair of values that are a subclass of Any (the root of the type hierarchy for most purposes).
Junction is a direct subclass of Mu (the ultimate root of the type hierarchy), outside the Any hierarchy.
When a scalar operation is applied to one or more Junction values, the relevant operation is "autothreaded" over the superposed values inside the Junctions and returns a new Junction value.
If a Junction is treated as a boolean the Junction collapses to a regular single boolean value.
Junctions seem way more complex than that, first there are 4 different junction contains (any, all, one and none), second they overload 12 comparison operators each and third the other operand doesn't have to be a junction.
So e.g. any(@ar1) == any(@ar2) is an intersection but any(@ar1) == $val is a containment, and I've no idea what all(@ar1) < any(@ar2) would be, I guess it would check that max(ar1) < max(ar2)?
It seems that it just expands the lists using the operator. The output from junctions is quite nice:
> my @a = <1 2 3 4>;
> my @b = <2 3>;
> say all(@a) < any(@b);
all(any(True, True), any(False, True), any(False, False), any(False, False))
> say so all(@a) < any(@b);
False no idea what all(@ar1) < any(@ar2) would be
Subset?Thing is, operators in perl6 are basically multimethods under the hood, as is pretty much everything else - so it's a much saner, more predictable thing than, say, the bag of razorblades that is perl5 overloading (which I've used to good effect, but, still, razorblades ;).
In [1]: {3,4,5} & {5,6}
Out[1]: {5}
or is there something I'm missing? > (5|4) + 1
any(6, 5)
> (5&4) + 1
all(6, 5)
> my $x = 5|4|3|2
any(5, 4, 3, 2)
> say "yep!" if $x + 2 ~~ 7
yep!
> ((2|3|4|5|6|7) & (3|4)) + 1 ~~ 5
True
> ((2|3|4|5|6|7) & (3|4)) + 1 ~~ 6
False
Kinda weird, especially & junctions. The docs[1] say "Junctions are meant to be used as matchers in boolean context; introspection of junctions is not supported. If you feel the urge to introspect a junction, use a Set or a related type instead."So far in my Perl 6 exploration I don't think I've used/needed junctions -- strikes me as a specific sort of use-case, but maybe familiarity would help me spot more (useful) opportunities.
[1] http://doc.perl6.org/type/Junction, though like all P6 docs needs more contributions
If you wanted, you could get pretty close in ruby with only a sprinkle of ill-advised metaprogramming.
> junc{5|4} + 1
any(6, 5)
> junc{5&4} + 1
all(6, 5)
> x = junc{5|4|3|2}
any(5, 4, 3, 2)
> puts "yep!" if x + 2 =~ 7
yep!
> junc{(2|3|4|5|6|7) & (3|4)} + 1 =~ 5
True
> junc{(2|3|4|5|6|7) & (3|4)} + 1 =~ 6
False
would be possible.I guess I'm just curious if this is a situation that comes up often enough to need a built in literal syntax.
http://doc.perl6.org/type/Junction
I could copy and paste the definition but it wouldn't be too helpful without context.
When it says autothread does it mean actual separate threads/CPUs?
if all(@ages) >= 18 {
# let 'em in the club
}
Or: if any(@ages) < 18 {
# don't let 'em in the club
}
Or: if none(@ages) < 18 {
# don't let 'em in the club
}
So I use logic like the above quite a bit, however, there are plenty of areas where the above can be better if it's deeply integrated into the language. In this case, as already mentioned, it's auto-threading where appropriate. That's not an easy feature to get right if it's not baked into the language, but it's a huge win if done right.Perl 6 also has gradual typing baked in. Other languages have gradual typing as a library, but that often fails dramatically (http://blog.circleci.com/why-were-no-longer-using-core-typed...). In Perl 6, because it's built-in, not only are the failures described something Perl 6 can avoid, but there are also plenty of type checks Perl 6 can avoid at run time with integrated gradual typing (imagine that benefit in hot loops).
You could even combine that with native junction auto-threading and presumably have super-fast comparisons where the needs for checking types is eliminated at run time because it's already been done at compile time. If you do that with libraries, it's awfully tricky to get right, if not impossible.
If I look at the examples on this page https://en.wikibooks.org/wiki/Perl_6_Programming/Junctions it doesn't seem to be.
For example "if ($x == 2 || $x == 4 || $x == 5 || $x == "hello" || $x == 42 || $x == 3.14)" can be done in Perl6 as "if ($x == (2|4|5|"hello"|42|3.14))" but in Ruby this would equally easy been done with "if [2,4,5,"hello",42,3.14].include?(x)".
Ruby also has set operations defined on its container classes (e.g. [1,2,3]&[2,3,4] => [2,3]) and any?, all?, none? methods that take blocks.
Perl6 looks like a language that might have been great if it had been released in the 90s but nowadays I wonder if it will gain enough traction from non perl programmers.
[2,3,5,"hello",42,3.14].any ~~ $x
But that's not really the same, since it converts the entire array to a junction and then does the match. Really this is a lot closer: [2,3,5,"hello",42,3.14].first($x):p
Which returns the first match (as a pair (hence the :p adverb) so it won't be false even if it is a false value)... but it isn't right either because it gets mad at comparing numbers and strings (I'm asking about this in #perl6 now on irc).Ultimately: it would be trivial to port ALL Enumerable methods to Perl 6 List (or some role to cover all iterables or such), and do it in a library even if it wasn't in the core standard lib.
I'm always fascinated by how much of Ruby (and lots of other languages) are more about their Standard Lib than about their language. In the Ruby world, lots of people end up with ActiveSupport, which sprinkles in all sorts of cool stuff into the standard lib -- and I've ever seen a native 'for' loop rather than a .each in pragmatic Ruby.
But that isn't the same is it. That's only a related feature because Ruby doesn't have first class Junctions.
> I wonder if it will gain enough traction from non perl programmers.
These days people have been taught to be arrogant. To assume their language is the best. This is what makes things a tough challenge.
At least in this case, the only difference I see is that this is a language feature in Perl6 and a method from the standard lib in Ruby.
And it has to be a language feature in Perl 6 as there you don't have open classes as in Ruby or an equivalent feature for overriding operators or adding functionality to standard lib types.
More typical uses are:
die "unauthorized value" if $_ == 1|2;
grep none(1, 2), @values;
say "$a and $b are even" if ($a & $b) %% 2;
Basically : junctions are not sets. Don't try to use them for set operations. Perl 6 has a Set structure. Use that instead.The third example shows the so-called auto-threading behavior. I think it's significantly different than what you can do with sets.
A Junction in Perl 6 is "a superposition of data values pretending to be a single value". So for instance any algebraic expression can be used with a junction as if it was a scalar. The result will be a junction.
In this example the expression is $_ %% 2, which is Perl 6's way of writing the boolean statement "the variable $_ is divisible by 2". We use this expression with ($a & $b) instead of $_.
In Ruby, you could express the same with `[2,4,6].reduce(true) {|even,num| even & num.even? }` or more clearer IMO `[2,4,6].map(&:even?).reduce(&:&)`.
The issue is, why would anyone want to move from Ruby/Python/Js to Perl in 2016...
Obviously most Perl users understand the benefits of Perl 6.
I've been using Perl since 1994, built a company around Perl 5 code and the attractiveness of Perl 6 for me so far is: 0. I know the price paid (later) for ease of writing (maintainability or lack thereof and lots of traps for the unwary - using Perl::Critic has a devastating effect on perceived "freedom" and simplicity) and a language crammed full of fancy features (the Perl 5 interpreter code base is widely considered unmaintainable these days). I honestly can't think of a single use case of Perl 6 with more than 10 lines or so where it'll work better than e.g. Go.
People love to say this, but having read a fair chunk of the sources to perl5, cpython, ruby, Tcl and erlang's VMs, my semi-educated conclusion is "reasonably fast interpreters written in portable C all end up as their own slightly bizarre CPP-supported C dialect, and all end up more similar than they are different".
It's not that simple. Tcl, Ruby and Python all have several competing implementations, while to my knowledge nobody has even written a complete Perl 5 parser (except the one in the official Perl 5 code).
I've been reading about, playing with, and really enjoying perl6 since the christmas announcements.
The idea of a 'fun hackers language' really appeals. There's a lot of 'oh sweeeeeet!' moments. I still won't be using perl for any production projects / work stuff for a while, but as a fun out-of-hours playground, this really does look like a cool new language. I'm pretty excited by it.
actually not quite. given the plethora of libraries/frameworks etc. for perl-5, why would perl-5 programmers move to perl-6 ?
I'm a Perl 5 programmer. Perl 6 is a more perly Perl. I can use my Perl 5 modules if I really want, but I can write better specified, safer and more logical code. Just having simple functions like 'whenever' makes developing fun and easy.
Please see http://jnthn.net/papers/2015-yapcasia-concurrency.pdf for context
People in the first group would switch if Perl6 looks like a better tool. Short of revelation the second group won't. Hardcore Perl programmers have had a long time to think about Perl 6 and come to their conclusions. It's not a community where evangelism is likely to make a difference these days. I don't think the Perl community is like the Python community for cultural reasons that stem from their histories.
I get that learning Perl is not a very attractive proposition these days, and Perl6 currently does not have the vast library/framework ecosystem Perl5 has.
But I think Perl6 is not just for Perl5 programmers. In fact, I think a lot of Perl5 people are going to stick with Perl5 for a while due to a) libraries/frameworks and b) existing code that needs to be maintained.
- Version 6.c? Why not 6.0?
- What's with the whole "language" and "compiler" distinctions no one cares about?
- Why is the first stable release of the compiler not optimized to the max?
- Is there a need for a new Perl? What is it good for?
- What is its business case?
- Why in the world would anyone use Perl 6?!
If I want to transform my 100.000 line program to a smaller one I won't grab Perl 6 to transform it to 50.000 but I will grab Clojure for example to transform it to an 5.000 one. Is that the only argument for using Perl 6?
- Version 6.c? Why not 6.0?
This is first, a reflection of the playfulness of Perl, and second, a statement about language design. The first release, an alpha, was 6.a. The second, a beta, was 6.b. The third, the actual 'final' release, was 6....c? Since it was being released on Christmas, and 'c' fits, it was decided that releases of Perl 6 would be named after holidays, and they went back and found them for A and B too.As for the statement about language design, I'll add that onto the next one, as it makes more sense in that context.
- What's with the whole "language" and "compiler" distinctions no one cares about?
"Perl 6" is a _language_, not an _implementation_. There's a language spec, and any implementation of this spec is a Perl 6. This is a distinction that a lot of projects make, but is a lot fuzzier, because they don't have specs. Consider Ruby: yes, JRuby is also a Ruby, but since there's no language spec, people still assume MRI when you say "Ruby". Perl people don't want you to assume Rakudo when discussing the language itself.This is why there's no minor version of "Perl 6". Language specifications change a lot less frequently than compilers.
- Why is the first stable release of the compiler not optimized to the max?
Like most projects, as long as performance is Good Enough, it's good to get people start using it, and then work on performance after. Especially for a language where performance isn't a main goal, like Perl. As long as you haven't painted yourself into a corner with language decisions, performance improvement is refinement work. - Is there a need for a new Perl? What is it good for?
I don't know if there's a _need_, but Perl 6 sure improves on a ton of things about Perl 5. It's the stuff that makes Perl Perl, but turned up to 22, not just 11.The last two are questions I can't really answer.
People care about distiguishing C89 and C99 from GCC and clang and their versions. If we don't want to block the road to future compilers for the same language (and we had other compilers in the past, they just aren't maintained anymore), we'd better be careful to distinguish them.
> - Why is the first stable release of the compiler not optimized to the max?
Because it's the first stable release, not the last. We expect to improve still.
For Clojure's target audience of people who already know Java (or JavaScript) there's a lot of evidence that it was a good decision. Tools like Leiningen can use a familar tree structure and offer the potential benefit of configuration via code in comparison to other Java build tools. But the point of comparison is at a particular level of overhead and that level of overhead is assumed. With ClojureScript, the toolchain is more complicated than a typical JavaScript tool chain. Again that's a tradeoff.
Which again, I think Clojure is great. That doesn't mean I think that those tradeoffs are always appropriate. YMMV.
Things were going great until I used a validation library with HTML form input to check some numeric ranges. Boom: cannot convert java.lang.String to java.lang.Integer. Would the same thing happen in clojurescript? If it obeys js semantics then I won't get an exception, but "200" will become 200 and things will work as expected.
If you have a language defined by a test suite that exists separately from your compilers, then perhaps you can avoid these kinds of problems.
What a weirdly arrogant and ignorant statement. If you're writing 20x as much code instead of using Clojure, then you're doing some pretty terrible programming.
I fail to believe that those 6 points could have been written by someone unbiased. Please show me some Clojure that's 10x more succinct than Perl 6. Otherwise then surely this counts as trolling.
Perl 6 loses quite a bit of the Write Only type syntax, and should be very succinct and expressive, but people just type nonsense :(
Sorry for the sarcasm, but the author hasn't given a single reason beyond some trivial (and inconsequential, imo) syntactic shortcuts and his personal preference for the language.
I haven't had much need of Perl recently; trying to force myself to switch to Python (a jarring psychological experience) not because I hate Perl but because Python seems to be where a lot of the demand is these days.
But I learned something else of great importance from this article: cowsay
I'd never heard of cowsay before but it's an amazing tool! I installed it on my SuSE workstation (sudo zypper install cowsay) and on my Mac (brew install cowsay) and it just makes me happy! My favorite command is:
ls|cowsay
So you have some old perl scripts laying around, but they work well enough and some guy takes care of them, updating them when they need. He knows perl and that's his job, so whatever. One day, the architecture changes and the scripts need to go parallel. That's a problem because the perl guy doesn't know Pony (a promising language with a community even smaller than perl6...) and really needs to get these scripts running again.
So he uses Perl6 along with the inline module, and things are working again. Over time, he hacks up a better system in vanilla Perl6, and deploys that too. He had such a great time using Perl6 that he even hacks up a few more tools he could use, etc etc, next thing you know he's a Perl6 developer.
I write ruby because it is modeled similarly to how I think about problems, but if I was a perl guy, I could see the appeal to Perl6, but saying that it's a dinosaur is both wrong and irrelevant to the FUD surrounding Perl6 right now. At this point, it's about adoption.
In any case, the fact that the project wasn't abandoned after all that speaks for itself. It's here and the future was never brigher for it than it is now.
It might not prosper, but it will prevail.
Why should anybody have hopes for anything, they don't like.
>>It took 16(!) years to implement features other languages already have.
Like what? Have you even looked at the Perl 6 feature list?
>>And CPAN is the dark, sad pit of forgotten and abandoned packages.
Clearly you have no active involvement with the Perl community.
That said, it is still good practice to try to avoid dependencies on packages that are not maintained, or you might find yourself the de-facto maintainer of the package. This is true across all languages.
Perhaps one of the most enduring legacies of Perl is that no language that comes after it can be considered complete until it has its own CPAN like package management system. That and the regular expression engine of course.
Perl is still by and large the only language with that many amount of library options, the only other language I can think which rivals that is Java.
The trick of course is that then your libraries effectively define your language. There are various sweet-spots of native-language features, standard-lib features, and external libraries. I think it is a matter of taste and trade-offs.
Why not "if 5 < x < 100"? Sigils look awful.
Also you get to know if a variable is only block scope, method scope, class variable, etc.
Twigils in Perl 6 are where the scope indicators come in, clarifying class instance vars, dynamic scope, and so on.
So if I see %.foo I can tell you that this variable can be used as the Associative role, that it is scoped as an instance variable, and that it has an accessor with the same name.
For more, see the first few sections of http://doc.perl6.org/language/variables
Because sigils tell you things. What if 'x' in your example is a list? Are you now checking the length of the list rather than the value? Sounds like room for a security bug to me.
Only if your language is really awful. A good language shouldn't even let you run "5 < x" when x is a list, but even a mediocre one would surely at least make that error out at runtime rather than giving a nonsense answer.
It depends what you consider "Nonsense". Python for example has no reliable way to differentiate between a string and a list. Strings are iterable, but lists can't be compared with the < syntax for example.
My point is simply that $x very clearly says (in Perl 6) "A single value called x" wheras @x is "A list of values called x". In python, "x" is indeterminate even at runtime.
Oh, and you can declare barewords with \x for example, if you really want to, it is Perl after all.
This is really no different than how Lisp uses parenthesis in a different way than C, except that Lisp has the benefit of being more visually distinct so people that are familiar with C and C-like semantics don't immediately assume they know what's going on an why when they see Lisp constructs. Perl is different as well, but it often looks similar enough to cause people concern before they know what they are really looking at.
As for this specific example, arrays evaluated in scalar context (as opposed to list context) return the number of elements in the array. There is no array length function or method, as it's superfluous. 0+@x is the number of items in @x, and 5 < @x tests whether @x has more than 5 items, since < imposes scalar context. There are many, many places in the language where context is used to simplify operations, this is just a very simplistic example, but it should illustrate why sigils are important, as they change how operations are evaluated.
Put simply, it's not possible to make a coherent criticism of Perl's use of sigils without understanding context and how it's used within the language, and factoring the benefits and drawbacks of that into your criticism. To criticize without this knowledge is to do so from ignorance (in the literal sense, not as an insult).
my %clients vs my @clients
Do you name your variables
client_list .. client_dictionary? No? Then sigils aren't superfluous.