809 points · by MilnerRoute · 11y ago · 319 comments
At work, I have been using Perl 5 increasingly often over the past two years, mainly because handling unicode in Python 2 is not a lot of fun (and I still haven't come around to learning Python 3), and I have rediscovered why I used to like it so much.
So far I have not looked into Perl 6 seriously, because I did not see the point to do so before it was finished. Guess I know now what I'll be doing this Christmas. :)
Also, you gotta love Larry for quotes like this one: "This is why we say all languages are religious dialects of Perl 6..."
I'm not using it everyday yet either, but it's not a whole new language. More like just a few cleanups to sensitive portions of the API.
That's completely different compared to the case of Python, where Python 3 is a continuation from Python 2. But breaks backwards compatibility with the entire ecosystem. Bulk of the language remains same, you are migrating non backwards compatible parts.
Doesn't look small and I already saw several things I was using that have changed behaviour. Someday I might even learn how to use them. :)
I don't know Perl, but I saw the presentation and was blown away. Installed it today, and definitely will try building something with it soon.
Even in Perl's supposedly superior support has issues. See how deep the rabbit hole goes by reading the first response to the question here:
https://stackoverflow.com/questions/6162484/why-does-modern-...
There is really no way for a simple program to account for all of those possible edge cases. Something as simple as a print of a string can be a minefield depending on what is in those characters. And it's not like the old days where you could safely filter out all non-printable characters to avoid most problems. Have you considered how your formatting is going to look when people intersperse Right to Left words in your output for example?
The post to linked you contained a piece of boiler-plate code which accounts for said cases.
> Have you considered how your formatting is going to look when people intersperse Right to Left words in your output for example?
There are modules to handle this. It of course means that you have to stop using non-Unicode-aware functions like `sprintf`.
This is a serious problem and will I suspect one day be understood to be the biggest long-term mistake made when designing Python 3.
I wrote a comment about this a few months back at https://news.ycombinator.com/item?id=9791211 (see second half of the initial comment and then the followups).
Why?
say 1, 2, 4 ... 2**32
> This correctly produced a nice tidy list of just 32 values -- rather than the 4,294,967,296 you might expect.Someone with more time than me needs to find an IQ test that is based around sequence questions like this and plug them all into Perl 6. So we can find out what Perl 6's IQ is and whether it has achieved AI.
1 2 3 4 5 4 5 4 3 2 1
corresponds to the second 3 in this one? 1 2 3 2 3 2 1
If that seemed too easy, what's the corresponding number in this one? 5 4 3 2 1 2 1 2 3 4 5
How about this? 1 2 3 4 5 6 7 6 5 4 5 4 3 2 1 2, 4 ... * # linear
2, 4, 8 ... * # exponential
1, 1 ... * # constant
1, 1, * + * ... * # Fibonacci
The last expression is equivalent to the more verbose variant 1, 1, -> $a, $b { $a + $b } ... *
that makes use of an 'pointy block' (ie lambda function) instead of the Whatever-*. [x*2 | x <- [1..10]] -- linear
[2^x | x <- [1..10]] -- exponential
[1 | x <- [1..10]] -- constant
IIRC haskell list comprehensions can't do fib without naming the list so it can refer to itself. OTOH, these perl list comprehensions seems unable to express things that combine values from several lists, eg: [ x*y | x <- [2,4..8], y <- [-1,0,1] ] -- [-2,0,2,-4,0,4,-6,0,6,-8,0,8]
Course, haskell also has a weak form of [x1,x2..xn] syntax for a linear sequence, as in [2,4..8]. That's always felt a bit of an unnecessary wart in haskell to me, although the simpler [x..y] and [x..] are very handy syntaxes.TBH, I almost never use list comprehensions either, preferring regular functions, and the list monad or applicative.
(*2) [1..10] -- linear
(2^) [1..10] -- exponential
repeat 1 -- constant
fibs = 0 : 1 : zipWith (+) fibs (tail fibs) -- fibonacci obvs
(*) <$> [2,4..8] <*> [-1,0,1] -- same as [ x*y | x <- [2,4..8], y <- [-1,0,1] ] constant primes = grep { .is-prime }, 1 .. *;You are correct, however. I did try learning Japanese and was just as unsuccessful at that as with Perl; I did maintain an old Perl codebase at one point and learned enough to get by but I would never jump at the opportunity to do it again!
I have the same feeling when gcc shit itself STL compiling errors.
> say 1, 2, 4, 2**32That has 46 terms before hitting the right pattern.
It also gives http://oeis.org/A188668 which has only four terms before hitting 1, -2, 4, ..., -232.
I guess one could try and tweak either to get a matching sequence, but I don't see a trivial way to do it that is mathematically 'nice'.
It is easier to start with http://oeis.org/search?q=0%2C0%2C1%2C_%2C_%2C_%2C_%2C_%2C_%2..., though.
It gives me http://oeis.org/A242067 "Number of triangular numbers between n^2 and n^3 (excluding the bounds)."
So, this sequence 'must' be "n plus number of triangular numbers between n^2 and n^3 (excluding the bounds)."
33, not 32, right? (20 through 232, inclusive)
# perl6 -e 'say +(1, 2, 4 ... 2**32).elems;'
33If perl 6 turns out to be useful for the larger software engineering community (and is more widely adopted), this is wonderful. If not, then we still have another interesting language in the great river of interesting tech things.
Either way, the perl community will continue to do what it does best!
Perl is for poetry. For seeing the impossible and going back.
Perl, never stop being you
react { whenever } # Code runs when a condition is met.
I can only think this must be a generic https://en.wikipedia.org/wiki/COMEFROM. It is sure going to create some viciously subtle bugs.> Perl 6 has an asynchronous looping construct called whenever ... runs whenever a value arrives ... can live in a ... react block (works like entering an event loop)
my $code = supply {
whenever IO::Notification.watch-path($src-dir) {
emit .path if .path ~~ /<.pm .p6> $/;
}
}
So now, whenever something in $src-dir changes and its path ends with '.pm' or '.p6' that path will be emitted -- which in this case means it'll be pushed to any construct pulling from $code. Such as: react {
whenever $code -> $path {
say "Code file $path changed!";
}
}The "react" keyword is just a channel subscription, and inside it has a pattern matcher. Channels are first-class citizens, and you're encouraged to chain channels rather than falling into callback hell. It's like Go and Ruby had a child.
If anything piqued my interest in Perl 6, it was this.
Given how much of contemporary programming is munging, I can see it really picking up steam.
Kudos to Larry for sticking with it, and for (I'm sure) introducing interesting ideas into the world of programming languages. That said, I have to wonder how many people will really use Perl 6 in their day-to-day work, and how many will look at it as a curiosity.
For me, I'm afraid that Python and Ruby have replaced Perl, despite more than 10 years in which Perl was my go-to language. Maybe I'll return to it, but I sorta doubt it.
http://learnxinyminutes.com/docs/perl6/ is a pretty good intro to Perl 6 if you just want to jump into things.
http://www.jnthn.net/papers/2015-spw-perl6-course.pdf is more slowly paced but provides greater detail.
Also, the people in #perl6 on Freenode are all awesome and are usually quick to help beginners unless they are in the middle of fixing some crazy bug.
I mean, whatever floats your boat, but HN, is this really one of your go-to trusted news sources?
[0] http://www.pigdog.org/in_the_pink/html/interview_with_a_stri... [1] http://www.pigdog.org/pooniedog/
I guess it's just a Perl thing...
http://perl6releasetalk.ticketleap.com/perl-tech-talk/detail...
"The Night Larry Wall Unveiled Perl 6"
http://www.10zenmonkeys.com/2015/10/06/the-night-larry-wall-...
Even if it's true, if they want anybody to pay attention they should announce it on perl6.org or at least a more professional looking page. If I were at work and opened a page with rotten.com banner ads, and "software jihad" all over the place, I'd close it immediately and hope nobody saw it.
Right. I think that's the intent -- this christmas.
But Larry can't stop someone posting an article that incorrectly suggests that 6.0.0 has been launched and then someone else posting an HN article/thread that you and lots of others (me too) decide to participate in.
http://perl6releasetalk.ticketleap.com/perl-tech-talk/detail...
From what little I've played around with the language in the past, I really like it, and I'm glad the community can put the "still in development" talking point behind it.
Also, one of my favorite things about Perl 6 is that the Rakudo interpreter prints some of the nicest error messages I've ever seen. It actually offers suggested solutions, and it points out Perl 5->6 migration gotchas.
Basically "No method modifiers and I have to write my own constructors? Really?" always drives me away within a few hours.
As for writing your own constructors, you only need to do so if you actually need to initialize something, and since instance variables can be used without having initialized them in a constructor (they'll just default to nil), I'm curious what you mean here too.
I don't know how to convert this into ruby then without needing to manually gensym a bunch of names:
use Class::Method::Modifiers;
sub foo { 2 }
before foo => sub { warn "before foo 1" };
around foo => sub {
my ($orig, $self) = (shift, shift);
warn "around foo";
(1, $orig->$self(@_), 3);
};
before foo => sub { warn "before foo 2" };
> As for writing your own constructors, you only need to do so if you actually need to initialize somethingWhich is required if you're going to use value objects as much as possible rather than spraying mutable state everywhere.
Those who want to play can install from http://rakudo.org/how-to-get-rakudo/
Larry's talk was a lot of fun, especially the way he zipped around between vi and terminal windows -- no need for presentation software.
- Perl 6 right now runs very well on two back ends: a custom VM and the JVM. It is spinning up a Javascript back end, I think primarily for NodeJS.
- Concrete representations are carefully separated from core semantics, so Perl 6 currently supports native values from C, Perl 5, Python, etc. It should be able to support native arrays as required for high performance scientific computing etc.
https://www.ohloh.net/p/parrot (contributor graph at the bottom)
Currently there are two in rakudo, in parrot can be re-added trivially, e.g. to support other architectures and a better threading model
(I'm randomly scanning http://faq.perl6.org)
One thing Go does well is provide the gofmt tool. There is only one way to format code properly.
Does Perl 6 have something like this?
Perl 5 has a Tidy'ing tool[0], as well as a Lint[1] tool. Both are based on rules created from (originally) Best Practices [2]. These rules of course can be modified to taste, so you can set your own rules/filters before checking in your changes to a repo (or, whatever)
[0] https://metacpan.org/pod/distribution/Perl-Tidy/lib/Perl/Tid...
I imagine something on this front will materialize for Perl 6 sooner than later.
Um, this has been there for decades:
$a = '123';
$b = '123.0';
print $a == $b ? 'y' : 'n'; # prints y
print $a eq $b ? 'y' : 'n'; # prints nI believe the article was referencing this, and so while yes, anyone who knows how to use Perl will use the appropriate operator for the appropriate type of type operation, there are reasons to still want to distinguish what type of match is done by the smart match operator, '~~'.
""Any infix operator can be replaced by itself in square brackets..." Later someone asked, "In a world of user-defined operators everywhere, how do you define precedence?" And Larry pulled out is tighter() and is looser(), noting that Perl 6 even has customizable precedence levels. "You can add an infinite number...""
It's been said that most of programming is about managing complexity. I'm unhappy with Perl in general because it makes it really easy to hide complexity. Perl 6 looks like it makes it even worse.
Yes, it looks like an amazingly powerful and sophisticated language, and an amazing and respectable accomplishment, but my gut feeling is I'll hate seeing some in production...
Python took Perl's place on my belt. I'm using Python2, because all the reasons everyone else gives, and because it's Python2 at work. I've been wondering when I'd finally decide/be able to move to Python3.
And now I'm rubbing that faint Leatherman imprint on my belt, and wondering if I'll just skip Python3 for Perl6.
Good to see it still has a dedicated following.
I used to be a big fan of Perl but it seems to have fallen behind the times, I doubt Perl 6 is enough to catch up.
But I don't really want to give a laundry list of features, because that alone is not a compelling enough reason to pick a language (P6 obviously needs to develop an ecosystem). As someone who appreciates both OO and FP, both static and dynamic typing, P6 really hits a sweet spot. I encourage you to look at Perl 6 as a new language with the feel of Perl but which solves many modern problems.
1) Async. While I was initially enamored of core.async, I've found promise combinators and supplies to be a more useful and higher level abstraction for the type of work I do. I also had huge problems debugging generated core.async code, but maybe that's changed over time. I suppose I could use RxJava with Clojure for supplies, but I have a feeling that it's not really seen as being in the same style. This is also why I'm not as big of a fan of Go as I once was, too.
2) As peatmoss mentioned, startup time. I work at a web hosting company and as you can imagine we write lots of small scripts. Clojure really can't compete in this area.
3) Gradual typing. Perl 6 supports gradual typing, with functions being checked at compile time and methods being checked at run time (the latter was a decision to allow both a powerful metaobject protocol and also easy interop with other languages using things like Inline::Python). I know that Clojure has core.typed, but that's not really what I'm looking for, although I do think it's an excellent project.
A final quality of life difference: Perl 6 has invested a lot of effort into awesome error messages, including things like suggesting a close lexical variable if you mistyped one. While every Clojurist learns to deal with the stack trace o' doom, there's something good to be said about this. :)
Why build something in Perl? The same reasons you'd write something in Python, Ruby, C#, Java, etc:
- Mature tooling - Excellent library support - Code samples written for relevant projects by vendors for their libraries [0] - Experts available
Given the fact that there are a lot of good options, it's probably best to factor in, "Do I like it?" and/or "Would someone pay me for it?". For all the above the answer is yes.
Additionally, Perl 6 is more or less a new language. If it scratches enough developer's itches, it'll likely take off on its own. It's mostly getting flack due to taking forever and Perl 5's perceived lack of sex appeal. I think if you frame your question with languages like Lua, Haskel, Schema, etc you'll find a good set of answers from users in each community.
[0] https://www.elastic.co/guide/en/elasticsearch/guide/current/...
> There are quite a few Perl shops in LA writing new code
These include Broadbean (in Irvine) and ZipRecruiter in central LA.TicketMaster used to have a Perl codebase but I think the murmurings I've heard point to them having switched everything to Java.
ps: I found this talk pretty convincing about pragmatism https://www.youtube.com/watch?v=lpu-3UF_b48
One interesting thing Larry mentioned related to that long term view was that due to Perl 6 being a multi paradigm language, it could potentially become the defacto teaching language in academia, because it fulfills the roles of OO, functional, procedural, and logic programming in a single package. Eventually, that new generation of Perl 6 learners would go on to form startups and create bigger and better things. I'm not sure if this will come to fruition, but I think it's certainly worth keeping an eye on.
By that logic we should just stick to assembler or C. You can built anything in C, if you really wanted to.
Perl or any other language, remains relevant as long as there are system depending on it and developers who use it. I view Perl a little like Cobol, you and I might not see it every day, but for a rather large, and perhaps a little obscure, subset of people it's still the tool they use every day.
If you have 10 Perl developers employed already, it might be a wasted of effort to retrain to Python, Node, C# or what ever, and just do you next project in Perl 6.
The biggest threat to Perl 6 might be Perl 5 though.
>What would you build in Perl today that you wouldn't build in another language instead?
You could turn it around too: what could you build in another language that you couldn't build in Perl? Well, nothing really. It's a matter of taste, and I think what continues to set Perl apart is its syntax, which could be really good and readable when you don't try to do code golf.
print "match" if something =~ /thing/i
Captures with $1 etc. are there as are named captures using the same syntax in the regex.
But this thread really ought to be focused on Perl 6.
In Perl 6 one can write:
print "match" if something ~~ /<thing>/
It looks superficially similar. But it's a scalable parsing feature, not a mere regex. That line of code will work when `something` is ten thousand lines of complex Perl 6 code and `thing` is the top rule in a grammar for parsing Perl 6 code.Perl 6 is not Perl 5.
I'm also curious in which type of application regex is so important that it will be a deciding factor of language choice. I mean, if you have a regex in one out of 100 files, does it really matter if you have to write 2 lines instead of one.
I mean, yeah. We're all going to be using Node.js in another year or two. But that's because our industry is bloody ridiculous. Not because Perl is ill-equipped for the "modern" age (People raving about MVC, the actor model, and promises in 2015 is tiring)
Accordingly, the official 6.0 release is also known as 6.Christmas. Right now, we're only at 6.Birthday.
Jnthn made a list of things that are supposed to be fixed by Christmas [1] as well as a list of things that probably won't make it into the 6.0 release [2].
$ brew install rakudo-star
<.... snip ....>
$ perl6
> say "hello world, sorry for the wait"
hello world, sorry for the wait
>Larry goes by the handle TimToady
http://pmthium.com/2014/10/apw2014/
"What exactly is the “Great List Refactor” (GLR)? For several years Rakudo developers and users have identified a number of problems with the existing implementation of list types — most notably performance. But we’ve also observed the need for user-facing changes in the design, especially in generating and flattening lists. So the term GLR now encompasses all of the list-related changes that seem to want to be made."
Completely brilliant.
Larry Wall's comment recognizes Ruby culture and acknowledges that it is a good thing. Not surprising given that Perl 6, like Ruby is an everything-is-an-object language with a lineage from Smalltalk. Programmer productivity/happiness was one of its goals as well.
[1]: http://siliconangle.com/blog/2011/08/31/qa-with-yukihiro-mat...
The "worst" I could imagine is that he was poking a little fun at Ruby programmers. I'm sure he was just trying to be funny, but sometimes it's easy to misinterpret what people mean when you don't actually hear them say it, but only read it in print.
I'd be very surprised if the comment was at all malicious.
Get 6 pages of build output and a broken install.
Its one of the first repos, a great idea, its just frustratingly obtuse.
At a previous job perl was used everywhere. As a language, it's quite nice. CPAN is horrible, though. No staging/stable/whatever versioning, new modules requires updating versions of existing modules which frequently broke - it's just not something that's enterprise friendly.
I tried but failed to find a company that would support and curate a subset of CPAN modules properly. Does one exist now?
And then you have a well documented mental migration path to Perl 6 since it tends to be explained in terms of deltas to Perl 5.
> get that they're different languages
I'm not sure you do get it, unless you are talking about the "feel" of using it, in which case use either. They aren't just different languages because there's some things that break backwards compatibility, they are vastly different in many ways.
If you want to know what current deployed Perl is like, look at Perl 5. If you want to look at what the "Perl" future is, look at both Perl 5 and Perl 6, since they'll both be around. If you want to see something new and different, look at Perl 6.
I want to know what "Perl" is like, but the fact that Perl 5 and 6 share the same name is a tad confusing for a newcomer. Precisely because I have no idea what "standard" Perl is.
I guess Perl 5 it is, since it's already on my machine.
For web development, check out Mojolicious[2] or Dancer2[3]
And Task::Kensho[4] lists recommended modules for various tasks.
[1] http://modernperlbooks.com/books/modern_perl_2014/
[2] https://metacpan.org/release/Mojolicious
The one main hint I have for you (beyond reviewing the Modern Perl book, as my sibling comment recommends) is to understand context and what that means in Perl. Perl can look deceptively similar to C and other procedural languages, but there are some somewhat (still) radical ideas underneath that will leave you either scratching your head or grumbling in frustration if you don't understand context (list or scalar), and how it's relevant in almost everything Perl does.
Pretty excited about Perl 6. Haven't used Perl in a long time but there seems to be quite a bit of cool stuff and I'm very excited to see what a language where Larry had more free reign will be like. Xmas reading/coding here we go (how fitting)
Its just one of those little things we don't think of often, but a lot of folks buy these devices and its a weird form of censorship beyond what's normally intended.
Flexibility is Perl's greatest strength and weakness. Perl forces you into dealing with other people's thought processes as a consequence of allowing your own code to be expressive and better reflect your thought processes. If this is not a tradeoff you're willing to make, Perl is most likely not for you. But I find it to be educational to see the variety in well-written Perl code (i.e. not from from Matt's Script Archive).
For whatever reason, I went the PHP route and I can say from nearly 20 years experience that PHP has the same problem even if it doesn't have the same philosophical approaches as Perl. Too many people who never actually learned the language producing near unmaintainable code.
The worst part is that people who believe they learned Perl by doing, instead of reading the reference docs and structured introductory texts, believe themselves to know Perl and speak publicly in the belief that the knowledge gained that way represents universal fact.
Perl is not the first nor will it be the last (imperative) programming language helps people fail too easy.
But Python3 is mostly just Python2 with a print function instead of a print keyword. It is occasionally non-trivial to port large existing code bases from Python2 to Python3, but it is practically always trivial for a Python2 programmer to write new code in Python3.
I hope Perl 6 will get its own camel book!
I imagine its relevance to the Perl 6 that was announced today is next to nil.
Until you need to use some library that doesn't support python3. I think I've made the transition from python3 to python2 more than I have the other way around.
More and more of the bigger libraries are ported already, and a lot of the others have been replaced by newer libraries that work with Python 3. If the library you're trying to use doesn't support Python 3, it's probably a good indication most people have moved on to something better...
>>> b"%u" % 5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'bytes' and 'int': )
I commented because I didn't want the top comment to devolve into a Perl v. Python argument because I love both.
Looking at my comment now, it doesn't read as on topic.
Thank you for moderating. HN is my favorite place to read the news!
What ends up becoming off-topic on HN, btw, is as much about upvotes and replies as it is about the original comment.
There's a pretty big page of changes, rules for maintaining compatibility and suggestions and it pretty much killed all my enthusiasm.
I'm speaking from memory and might be wrong, but one annoying thing was that I couldn't detect the Python version and print an error message, instead the P2 interpreter would throw an error at runtime when encountering a P3 construct.
There are many nice P3 books and libraries, but 2 vs 3 is still a PITA.
If there is a operator in Perl 6, which you don't have in Python- Your options are to rewrite those semantics in Python most of them pretty large, and they won't be easy to read either.
Ease of learning is a irrelevant metric. You can't use a needle to replace a saw, if you do you are only going to end up doing more work.
> Ease of learning is a irrelevant metric. You can't use a needle to replace a saw, if you do you are only going to end up doing more work.
I adore the elegance of your wording.
That's the new headline that sums up Perl: an anachronistic programming language that may never recover from the perl 5->6 decade long 'freeze'. Also the language is crazy to write substantial programs in!
Making a backwards-incompatible change to a programming language == making and launching a new language, with all its difficulties.
I would not want to write anything big in Perl 5. But for small-ish scripts (say, less than a thousand lines) it is pretty hard to beat.
This is not so much a problem with the language as it is with programmers not learning to agree on a set of idioms that they will use for a project. They are not reading each others code and having discussions about what they want to see.
Languages that impose "the one true way" cut down on the apparent problems, but you are still going to have massive issues down the road if you build large projects because nobody is paying attention to what the other people are doing. Especially on large projects, it is vital that people read and comment usefully about design issues. In such large projects, removing the choice of idioms available though language design is a bit like deciding not to carry a canary down the mine with you because it keeps getting killed by poisonous gas.
The expressiveness of Perl allows you to choose the idioms that will work best for your team/project. It is true that it requires more discipline and communication, but these are the things that are necessary for success on a big project anyway.
I haven't written any Perl code for years now, but I have always been fond of it. I find that I can write better code in Perl than in many of the more restrictive languages that I've used.
This isn't even remotely true. No static types, no thank you. Runtime errors due to misspelled methods? Missing hash keys? Hilarious.
Boy, I hope this scalar isn't undefined!
I can write a web application in some homebrew <insert language> and it can grow to 40 developers, 1000 db tables and thousands of files. But it would be terrible to work on (I know I've seen it). Or i can write the same thing with a framework, and have it much more manageable.
Realistically, when was the last time you say down and wrote a big application in vanilla <insert language>?
Perl 6 needs to find a problem that it can solve well. Perhaps a great web framework?
It's like the perl developers saw the comments about perl being indistinguishable from line noise and decided to make it even more so. WTF?
Disclaimer: I don't know Perl and I have no opinion if this rant is deserved or not yet it's an enjoyable read.
Javascript would fare much worse than perl with these arguments. It is far more dynamic, far more unregular and produces even worse code than perl5. See e.g. http://archive.oreilly.com/pub/a/javascript/excerpts/javascr...
perl is kind of a lisp - much more than javascript - with some clojure like features, like shorter hash and array syntax.
AFAIK Erik Naggum used Perl for a fair amount of time so I wouldn't call it a "fear and hate of the unknown" and it is about Perl hence also on topic.
So your point is? Did you even bother reading it?
You bothered to link to it.
> side note about rewarding idiotic behaviour
The raw and naked idea is not entirely incorrect. Literally everything else in the sentences making up that section is.
> Erik Naggum used Perl for a fair amount of time
> Did you even bother reading it?
Did you? I quote from the screed:
I once studied perl enough to read perl code and spot bugs in other
people's programs [...], but I don't write in it and I don't ever
plan to use it for anything
I don't know about you, but i find that unambiguous.