10 ms·
Perl 6 Advent Calendar
- Phlogistique 9y agoThis is frankly terrible advertisement for Perl 6. I guess it is targeted at people that are already well-versed in Perl 6 (or at least Perl 5)? Maybe it should say so at the top so that people like me do not get a terrible first impression of it.
- chombier 9y agoIt made me wonder whether OP's goal was no in fact to drive people away from Perl by posting this.
- tomalpha 9y agoBack in the day, I wrote a load of Perl 5 and certainly used to consider myself well-versed in it. Perl 6, at least seen through the lens of this post, doesn't appear to have fixed the write-only nature of Perl 5 and it's amazing ability to help you create truly obfuscated code first time round. No tools required. unit module Jolly; sub term:«\c[INVISIBLE TIMES]» is export { 42 } sub infix:«\c[INVISIBLE TIMES]» is export { $^a × $^b } sub prefix:«\c[INVISIBLE SEPARATOR]» (|) is looser(&[,]) is export { say "Ho-ho-ho!"; } In order to have the line: say 42; # OUTPUT: # 1764 # Ho-ho-ho! Neat tricks within the scope of the language itself perhaps, and despite everything it is great to see progress on Perl 6 even if only for reasons of nostalgia. Not a great advert for a modern language though.
- colomon 9y agoPerl 6 contains a bunch of really powerful tools, like the ability to create operators from any (non-whitespace) Unicode string, wrap subs and methods, or rewire the language's grammar on the fly. Unsurprisingly, this sort of power can cause a lot of trouble if used with ill-intent. It also can make for wonderfully expressive, clean programs.
- petre 9y agoWith great power comes great responsibility.
- smacktoward 9y ago> Perl 6, at least seen through the lens of this post, doesn't appear to have fixed the write-only nature of Perl 5 and it's amazing ability to help you create truly obfuscated code first time round. Despite all evidence, the Perl community persists in considering this a feature, not a bug. Which is a big part of why the Perl community is so much smaller these days than it used to be.
- mhd 9y agoThe Perl advent calenders have a pretty long tradition and are mostly about tinkering with the language, presenting new modules etc. Often with a christmas/Santa theme. In other words, they're about "hacking"... They also server as a decent health check (e.g. Catalyst seems pretty much dead), but aren't really about advertising.
- acomjean 9y agoI want to like perl6, I really do. The language has some simply great features. I agree with the parent, this seems like a terrible way to get people new into the language. I do a fair amount of perl5 script maintenance, so am familiar with the language. Advents calendars are daily small chunks, an Ideal way to introduce the language but they turned this into a "look how clever" our language is post, which to me is "wow this is hard to read and maintain." Lamentably these examples don't give me hope that Perl6 is going to be any better at being maintained.
- dsnuh 9y agoI still think that if they had just called it something other than Perl, they may have picked up a little more traction.
- jrs95 9y agoPerhaps it's not too late for rebranding it?
- dsnuh 9y agoI'm not sure at this point. I used to write quite a bit of Perl 5 and didn't really understand why Perl 6 seemed like it was trying to be everything to everyone and I didn't see what problem domain it was really the obvious choice for picking it over another easier to comprehend language.
- natch 9y agoThey are stuck with the community and the culture they have, I think. A different name would not change the nature of what it is.
- dsnuh 9y agoTrue, but even if they had just called it Parrot or Lerp or Rakudo or really anything but Perl 6, I feel like they could have attracted the kind of new userbase to augment an already thriving community. I didn't follow along with all 594 years of development, it seemed to me like Larry just went nuts with adding every CS novelty. It didn't feel like a language for mere mortals to me anymore.
- stevekemp 9y agohttp://www.perladvent.org/2017/ http://www.perladvent.org/2017/ might be a better link.
- Phlogistique 9y agoNo; OP is about Perl 6 while this link is about Perl 5. Perl 5 (a.k.a Perl) and Perl 6 are different languages.
- Ultimatt 9y agoI think you just got the "joke".
- usrme 9y agoDoes anyone know of something equivalent to this in, for example, Python, but where the author starts off light and progressively ups the ante in terms of concepts introduced? I'm looking to learn more about Python, but having a hard time finding a solid starting point; I've tried 'Learn Python the Hard Way', but it doesn't seem to keep me engaged to the point where the material being learned is of interest.
- arunix 9y agoThere is a book you can try: "Automate the Boring Stuff with Python" https://automatetheboringstuff.com/ https://automatetheboringstuff.com/
- asicsp 9y agoyup, this is a good resource for beginner and related udemy course free offer ends today, see author's post for details (https://www.reddit.com/r/learnprogramming/comments/7fxq5o/im_releasing_a_free_code_for_my_automate_the/ https://www.reddit.com/r/learnprogramming/comments/7fxq5o/im...)
- giancarlostoro 9y agoNot sure if it counts, but High Performance Python[0] starts you out from the bottom explaining the hardware and how it has to process your code, and they go from there. It's a really good read, was recommended by a coworker and I haven't had issues reading through it so far. Also you might learn things to consider when writing or refactoring Python code that affect performance (I always suggest never to "solve" a performance issue that isn't there yet but to instead write something that works first, then try to optimize the code once it works). http://shop.oreilly.com/product/0636920028963.do http://shop.oreilly.com/product/0636920028963.do
- manaskarekar 9y agoCheck out 'Fluent Python' for juicier python concepts. Can't recommend it enough. Disclaimer: no affiliation whatsoever.
- geraldbauer 9y agoFYI: I've started an advent calendar for ruby - a language inspired by perl :-) 25 days of ruby gems / libraries from December 1 to December 25. See https://planetruby.github.io/advent2017 https://planetruby.github.io/advent2017 Enjoy.
- curveship 9y agoPerl 6 feels like what happens when your answer to all bike-shedding questions is "both!" and your answer to the follow-up question "how will we tell them apart?" is "we'll add a secret codeword." Still, I have to love the fun some Perl coders feel in their language.
- junkscience2017 9y agoThe Perl6 Advent calendars are great year after year. The language is a huge beast that demands a curious mind. You won't arrive at Perl6 if you are just looking for just a tool. If you are interested in what a modern dynamic language might look like (concurrency, gradual typing, metaprogramming), check it out.
- richard_todd 9y ago> 'That override will work even if we stick it into a module.' That's the line where they lost me. Who wants to debug a situation where two unrelated modules clash because they wanted incompatible weird effects added to stdin? It would be better to have a situation like scala implicits, where you at least have to import the providing module to bring in the effects. Modules are only as useful as they are composable, in projects of any size.
- cygx 9y agoIn Perl6, effects of importing modules are mostly lexical, ie bound to the surrounding block. However, this particular code basically just modifies a global variable (technically a dynamic one, but you get the point) - and modifications of global state will be globally visible no matter the language
- richard_todd 9y agoYeah it will pretty much always boil down to mutable global state when you have "spooky action at a distance." Like, in python, there is one import cache, so I can import os, and redefine os.pipe() to be some other function. Then any other module importing os get's MY version of pipe(). That's a recipe for disaster and of course the real-world answer in all these cases is "don't do that." I love Perl5, smalltalk, lisp, etc., and I guess for that reason I feel like we have plenty of great languages where these hazards are exposed already. I'm not excited by yet another one. I'm more interested in new languages that attempt to allow crazy hacks in a contained way, so things still compose in the large.
- bdmatatu 9y agoIn the example, the effects of "use Jolly" are restricted to the enclosing scope, e.g. use lib <.>; { use Jolly; # inner scope } # TODO: this does not throw an error
- richard_todd 9y ago
- nopacience 9y ago#!/usr/bin/env perl python, ruby, perl5 ... agile and fun to work with. perl5 is the fastest. Being around for so long means there are a lot of libraries at http://metacpan.org/ http://metacpan.org/ . If interested, search for... "twitter", "google", "oauth", or any other technology/api to find out there are a lot of new and maintened libraries. perl5 libraries have great documentation, ie: - https://metacpan.org/pod/AnyEvent::Memcached https://metacpan.org/pod/AnyEvent::Memcached - https://metacpan.org/pod/distribution/Net-Twitter/lib/Net/Twitter.pod https://metacpan.org/pod/distribution/Net-Twitter/lib/Net/Tw... A lot of perl communication happens directly with developers over IRC. Yes, perl community runs irc.perl .. if IRC is not your thing, you can email the developer shown at metacpan (example in links above) Also not less important is the fact every library uploaded to metacpan gets tested in multiple platforms: https://cpantesters.org/distro/U/uri.html https://cpantesters.org/distro/U/uri.html And, what this means is the library author uploads the library and 2 days later its possible to check if library is broken in any platform. And of course a lot of top notch sites use perl. Many dont promote it, but check metacpan.org home for example of some sponsors. Too bad some people that never learned perl spread the wrong message. It is a great language. And perl6 is another language that just happens to be named "perl" and was developed in conjunction with top perl5/other lang. developers. exit;
- nopacience 9y agoSome other sponsors: http://www.perlfoundation.org/sponsors http://www.perlfoundation.org/sponsors https://metacpan.org/about/sponsors https://metacpan.org/about/sponsors http://www.yapcna.org/yn2016/sponsors.html http://www.yapcna.org/yn2016/sponsors.html http://www.yapcna.org/yn2015/sponsors.html http://www.yapcna.org/yn2015/sponsors.html https://www.perl.org/siteinfo.html https://www.perl.org/siteinfo.html
- chomp 9y agoYou chose exceptional libraries to provide as examples. It's my experience that a huge chunk of modules on CPAN are not well maintained, suffer from poor implementation decisions, have decade old bugs, or just have plain bad documentation. Perl5 despite its warts is a decent "just get moving" language, but it's easy to get frustrated with some of the community modules.
- systems 9y agoi guess if you dont know what a role is in perl6, its futile to try to read this article this is an article for people who already know perl6, and know it well i doubt this is meant to promote perl6 outside of the perl6 community
- Ultimatt 9y agoRole == Mixin == Interface Its not meant to promote anything, this article especially is more a challenge. The point of all tech advents IMHO is for the community to have something nice to open in the morning with their coffee. This certainly achieved that.
- wlll 9y agoAn operator for each of the 18000 days of Christmas!
- bcatanzaro 9y agoHonestly, I couldn't tell whether this was a satire. Does anyone know the author's intent: are they genuinely excited about the stuff in this post or are they horrified? My mind was so blown after day 1 of this advent calendar that I think reading the remaining 24 days might be hazardous to my sanity.
- kbenson 9y agoI think at this point they've been doing Advent calendars for Perl 6 for enough years that they are reaching some more esoteric features. A year or two ago I decided that Perl 6 was too far along the spectrum of complexity and required front-loading of learning the language for my tastes. I program Perl 5 for a living, and love it, but I feel Perl 6 has too much stuff built in for be to devote the time to actually learning it all usefully enough to want to do anything professional in it, or want to use anything professionally written in it that I might have to poke in the code. And this comes as someone that followed development since the Parrot days, and actually read through all the Synopsis documents almost a decade ago. That said, it's likely a phenomenally fun language to play with (it's even fun to read about development of, and novel solution in, IMO). I've seen really clever solutions using the interesting features it has (and it has a LOT of interesting features). Built in grammars, for example, are something I think is awesome, and simplify a lot of parsing code to the point of triviality. There's a spectrum of features, which at some point starts mapping fairly evenly to TIMTOWTDI. On this spectrum I find Python too stifling, Perl 5 a happy medium, and Perl 6 providing way too much freedom (at least for work related things).
- b2gills 9y agoActually I think you have that backwards, as far as front-loading. For just about everything you do in Perl 5 there is an equivalent in Perl 6 that is simpler to remember and is more general in its use. For example using an iterator variable other than `$_` in a for loop: Perl 5: for my $line (...) {...} Perl 6: for (...) -> $line {...} Note that you can also use this for any keyword that has the form `KEYWORD CONDITION {BLOCK}` if $a.method() -> $result {...} You can also use this exact same syntax for a lambda: @a.sort( -> $a, $b {...} ) So you can see it is more general, and since you can and do use it everywhere it is easier to remember. The other day I was trying to remember how to alias two subroutines in Perl 5; *foo = \&bar; I can easily remember how to do it in Perl 6 my &foo = &bar; The things shown in this article would be very much black magic Perl 5 code, but are completely doable. If you can manage to keep from writing source filters, I think you can avoid doing the things shown in the article. I will note that this mutability makes it so that for example OO::Monitors http://modules.perl6.org/dist/OO::Monitors:github:Jonathan%20Worthington http://modules.perl6.org/dist/OO::Monitors:github:Jonathan%2... can be made easily. The mutability is also the reason you can import modules from other languages as if they were written in Perl 6. You just have to make sure you have the appropriate Inline module installed and loaded.
- MikeTaylor 9y ago> [`but` is] an infix operator that first clones the object on the left hand side and then mixes in a role provided on the right hand side into the clone. Yeah, thanks. I always wanted an operator that did that. I wonder why Perl 6 hasn't caught on?
- deleted 9y ago[deleted]
- natch 9y agoI was interested in Perl 6 and hopeful it would fix some of the Perl 5 community’s problems until I read this post. Now I’m wondering if the remaining Perl 6 community is just a bunch of basically compulsively clever show-off blowhards that I would never want to work with. There were always some of them with Perl 5 too (along with plenty of let’s-get-stuff-done people who I do like) but the unpleasant ones seem to have firmly taken over now. And that’s not just looking at the spirit of this blog post... it’s looking at some of the language features that they decided to have.
- jxramos 9y agoI'm in this camp too, knowing how Python is growing in adoption because of its stylistic expressiveness conventions I wonder what the growth rate of Perl has been. I was at a company 6 years ago that wrote Perl scripts but two companies since I have yet to see it again. Various companies I've interviewed at in the meantime don't have it as part of their tech-stack either. Where is this stuff being used exactly?
- colordrops 9y agoThe community and marketing around perl6 has gone almost as weird as the urbit folks.
- Ultimatt 9y agoWhy on earth do you consider this "marketing". I just signed up for writing the 16th entry. Im just some random Perl 6 programmer. My motivation for writing an article is to share something I think is interesting with the community...
- colordrops 9y agoSorry to offend you. I used the term "community" as well to capture that. I also used the term "weird" as it is not inherently negative.
- zoffix222 9y agoAuthor here. Thanks for reading my post! :) To answer some of the comments: no, this isn't satire, nor is it a marketing or advertisement piece. I'm just having fun with the language and wrote a post in the voice of The Grinch (https://en.wikipedia.org/wiki/Grinch https://en.wikipedia.org/wiki/Grinch). It's meant to be mean. That's all there is to it. Tomorrow's article (coincidentally, also written by me), will have a more sober tone and will describe Perl 6's system of containers and variables. See if you like it more. I'm OK if you don't like Perl 6 :) That's why we have so many different wonderful languages: everyone can find what they love. I love Perl 6. You should try it out.
- jprzybyl 9y agoThank you for the post! It was very fun. Some fuddy-duddies think that preferring expression over safety is irresponsible. They might be right, but Perl is a language that doesn't have to justify itself: https://www.perl.com/pub/1999/03/pm.html https://www.perl.com/pub/1999/03/pm.html Can't wait for the next one!
- sbmassey 9y agoWhat are some more reasonable uses for the but operator, then?
- zoffix222 9y agoMixing in out-of-band data
- CodeWriter23 9y agoI’m glad you’re having some fun. I still code in Perl 5 regularly and reading your code is causing my brain to invert. I’m not sure if you’re a Contrary Warrior or an Assassin whose primary weapon is Brainstem Autodissection. It’s like learning Perl all over again.
- nerdponx 9y agoCan someone explain this code in English? Is any of this actually useful, in Perl 6 or otherwise?
- Ultimatt 9y agoDefine "useful" none of it is something you'd ever write or use for any real world task. Its useful to illustrate some of the corners of the language that could cause problems if they were ever abused in horrific/wonderful ways.
- nerdponx 9y agoSomebody must have thought "but" was a useful operator at some point. But from this demo I have absolutely no idea what it does.
- b2gills 9y agoIt mixes in additional features to a given instance my $old = 0; my $val = $old but True; say $old.Bool; # False say $val.Bool; # True say $val.Numeric; # 0 Which can be thought of as short for my $old = 0; my $val = class :: is Int { method Bool (){ True } }.new( $old ) say $old.Bool; # False say $val.Bool; # True say $val.Numeric; # 0 Note that under the hood it is a little more complicated so that it will work on any instance. I think this was added as a generalization which replaces the following in Perl 5. my $val = "0 but true"; say $val ? "True" : "False"; # True say 0+$val; # 0
- logicallee 9y agoAll I see in this thread are a bunch of pre-modernists stuck in the middle of the 20th century. Perl 6 is the only language in the world suitable for metaphorical programming. For example, how would you implement a load-balanced pool of HTTP web servers over Port 80 in a language like Python, serving Hello World? In Perl 6 this is just five lines: imagine web servers, like the droplets of mists of fog as many as the sun shines through. A clarion: Hello world. The sun? An http server, its port 80. Cast off! I'll steer when I'm ready. And that's it. What's great about Perl is that you're not stuck with a nautical analogy, you are free to mix metaphors. For example this is another way to do the exact same thing: race, ye hogs of web servers the killing time is near. Your cries? Hello world. The abattoir? An http server, its port 80. Cast off! I'll steer ye when I'm ready. Even though it would hurt any poet's brain to read a metaphor this mixed, there's more than one way to do it, and this is really where Perl 6 shines.
- lilactown 9y agoI now want to try writing web-sonnets using Perl 6's grammar...
- Ultimatt 9y agoLooks more like this... via http://mi.cro.services/ http://mi.cro.services/ use Cro::HTTP::Server; use Cro::HTTP::Router; my $app = route { get -> { content 'text/html', 'Hello World! ' ~ DateTime.now() } } my Cro::Service $service = Cro::HTTP::Server.new( :host('localhost'), :port(9000), :$app ); $service.start; react whenever signal(SIGINT) { $service.stop; say "Goodbye!"; exit; }
- nige123 9y agofear -> anger -> hate -> suffering Sadly some programmers went down this path when they first encountered Perl - that gnarly Perl 5 regex that stopped them in their tracks. WTF they cried - and they never forgot that feeling. The flipside to Perl's expressive power is the potential to disempower those that don't look deep enough to get it. Perl 6 takes this expressivity and whipupitude to another level. I suspect this Advent post has touched a raw nerve with some commenters because they feel disempowered all over again. Please don't be! Perl 6 is a playful language optimised for fun: https://perl6advent.wordpress.com/2015/12/20/perl-6-christmas-have-an-appropriate-amount-of-fun/ https://perl6advent.wordpress.com/2015/12/20/perl-6-christma... Look deeper and you'll be rewarded.
- MilnerRoute 9y agoThere is also a separate advent calendar for Perl 5. http://perladvent.org/2017/ http://perladvent.org/2017/
- smonff 9y agoLove Christmas Camelia!
- donaldihunter 9y agoI'm currently solving both last and this year's AoC in Perl 6. Really good fun.