Hacker News new | ask | show | jobs
by inopinatus 3940 days ago
> a lot of the community has wandered off to other 'cool' languages and frameworks

I am just one such. Half my career was writing Perl. But these days, most of my work is in Ruby and as a longtime fan of Erlang (but never having had the opportunity to use it in production), I'm taking a long look at Elixir+Phoenix. This tutorial wasn't enough to entice me back to Perl, and I'm wondering if there is anything at all that could.

In general we choose a language for their applicability to the problem domain. The focus on text manipulation in Perl 4, and then extension of this with an object framework in Perl 5, made it a shoo-in in the 90s and early C21 when we all needed form parsing, HTML template stuffing, and email mangling tools. In these days of dynamic DOM manipulation and event-driven microservices, it doesn't seem so relevant; whilst Node and Go and Elixir look entirely on point.

If you go look at the Perl 6 FAQ, there's a section, "Why should I learn Perl 6?". It lists a grab-bag of language features, rather than a set of problems that Perl 6's new design can solve. As a result it feels much like a solution in search of a problem. That wasn't even ever true of JavaScript, even though JS took years to come of age.

If I was designing a language today, and I am not, but if I were, I would look at how dominant Java seems to be in the big data community and try knocking it off that perch with appropriate language primitives, constructs and libraries. It seems to me this is the modern problem domain homologous to the bulk text mangling for which Perl originally became famous.

3 comments

For event-driven microservices, I think Perl 6 is actually a great choice. I have experience writing some small things in Go and Node.js, but Perl 6 offers much more powerful high-level features for handling async, concurrency, and parallelism.

Promise combinators are built into the language to provide composable concurrency. But unlike using something like Q in Node.js, you can truly perform tasks across promises in parallel (and with static typing to boot!)

Perl 6 has channels for when you want Go style semantics, but you also have Supplies for when you want their dual: instead of pushing events through channels you pull them reactively. This allows you to write highly declarative code; see https://gist.github.com/muraiki/222814d5928f648be3c1

I think that P6 will also be awesome for data munging. Here's a pipeline that processes text from a file with 4 parallel workers.

  my $lines = open('foo.json', :r).lines.hyper(batch => 20, degree => 4)
  my $filter = $lines.grep: -> $line { $line ~~ /someregex/ };
  my $json = $filter.map: &from-json;
  my $foos = $json.grep: *<some_property> == 'foo';
  say $foos.list[8];
Since the operations are done in scalar context, they essentially operate lazily, pulling one value through the chain at a time. The pipeline is only activated once coerced to list context at the end, and only enough values as are required to find the 9th match are processed.

I've used Elixir before. It has some great features and having the power of BEAM and OTP is quite awesome. But sometimes the actor model is not what you want. I think that Perl 6 will be not just a great glue language, but also a powerful language for writing multi-paradigm applications that meet the demands of modern systems.

Fyi, Jonathan recently wrote:

> Also, the name channel is evocative of the concept in Go, but our channels aren't like that. They don't block senders until the receiver is ready, for example. While a blocking queue is a very useful thing to have in a language, and we should keep it, we may want to stop calling it Channel, to avoid confusion (and keep the name free for something that has the Go-ish semantics).

(from https://gist.github.com/jnthn/a56fd4a22e7c43080078)

(note that most of the changes mentioned in the gist have since been implemented)

>>I'm wondering if there is anything at all that could.

Ok, I've been following Perl 6 for quite a while and learning it these days. So that I could use it for my day to day work after its production release in Christmas.

If you liked Perl in the past, and like Ruby. You will absolutely love Perl 6. It has a lot more cleaned up syntax. And the language as such is very Perlish. You will enjoy grammars and macros. And please don't think arrival of JSON and XML has solved and eliminated all text processing problems on earth. If anything arrival of any standard format, only emphasizes the importance of good text processing tools. One size fits all approach doesn't work for common place problems. Sooner or later you will see people shoe horning all kinds of solutions into problem domains they don't belong. The net result looks more like a kludge, than a real solution. This is the whole problem facing people today, because we are forced to use solutions which were not invented to solve the problems they were designed to solve.

>>In general we choose a language for their applicability to the problem domain.

Perl 6 is a language designed to provide you tools to work with any problem domain, while adopting without breaking backwards compatibility. If this is your concern, then you only have good news to listen.

>>As a result it feels much like a solution in search of a problem.

iPhone, Unix, C, the original perl itself were all solutions in search of a problem. None of them had prior users or had well marketed audience to begin with. Sometimes people don't know what they want unless they are shown the solution. Tools are not designed based on survey results. Else we wouldn't have cars today, only faster horse carriages.

>>I would look at how dominant Java seems to be in the big data community and try knocking it off that perch with appropriate language primitives, constructs and libraries.

Java as a benchmark is worst design point you can start with. Only reason why Java is even surviving today is because of its enterprise inertia, and unlimited supply of cheap programmers. At some point in time a massive reset to Java way of doing things is imminent. Language as a whole is old, the original platform-independent goal is now common place in all tools. They can't seem to add anything new or useful without breaking backwards compatibility and the power is falling in the face of newer and powerful languages.

Having somehow avoided much Perl for most of my working life, I've recently done quite a bit of it (Perl 5 this is), and I have found it, syntactically, a painful experience when compared to Ruby and Python. The one thing I have loved compared to those two though is the performance. If Perl 6 retains that performance edge it may gather mindshare, but otoh my impression of Perlists that I work with is that they are quite content with Perl 5's warts, so I am not convinced that 6 will have much of an impact.
If I have one piece of advice for people coming from other languages into Perl 5, it's to not be fooled by some similar looking syntax into thinking it should be used like C or any other C-like language. I find assumptions in that vein are often what leads people to painful assumptions about the language.

If I had time for a second piece of advice, it would to be sure you understand context in Perl 5[1]. Everything is based around context, and to not be aware of how it factors in to the current expression often leads to befuddlement (at best) or anger. On the flip side, context is often where Perl shines. I recommend Chromatic's excellent Modern Perl: The Book[1] if you feel any of this might apply to you.

Finally, Perl can be a very Lispy language. Avoiding those parts (map, grep, etc) is sort of like consciously avoiding every even gear when driving a car. Possible, but much more painful than using it as designed.

Edit: Oh, you probably want that reference I implied up above.

1: http://modernperlbooks.com/books/modern_perl_2014/ covers context in multiple sections.