11 ms·
Perl 6 Introduction
- s_kilk 11y agoI've got to say, perl6 is really, really fun to play with. (and I say this as someone who had not used perl before) So far I've gotten the impression it's made by a bunch of smart, friendly hackers who care about quality in their software. To anyone reading this, I'd strongly recommend casting aside any preconceived notions about perl and giving perl6 an honest shot.
- user9756 11y agoI'd like to take perl6 for a spin. However, other than playing with it I'm not sure how it compares to say python or ruby in terms of strong sides. I mean what are the cases perl6 would shine in comparison? (NOT TO FLAME! I'm asking for ideas to when perl6 would be an interesting tool for the job. AFAIK it had a good string manipulation ~ also I'm still reading the tut and currently it feels very bash and somewhat ugly (although helpful) with the % & @ prefixes).
- s_kilk 11y agoA few upsides I perceive: - optional, well-integrated gradual typing system. - perl6 is the first mainstream(ish) dynamic language to not suffer from a GIL of some kind. You can do real concurrency and parallelism in perl6. - perl6 is both equally as powerful, and much more simple than previous versions of perl. - a bunch of good ideas stolen from other languages. go-routines are in there, pattern-matching, gradual typing, classes, etc. Plus, functional programming is a first-class-citizen of perl6. There's so much good stuff in there. - overall, I think perl6 has the potential to become a very powerful (and yet robust and well engineered) hacker language, where you will not be constrained by implementation details of the VM the language runs on (I'm looking at you, GIL). I'd also recommend reading Curtis Poe's answer to a similar question: https://www.quora.com/Perl-programming-language-1/Should-I-be-interested-in-Perl6 https://www.quora.com/Perl-programming-language-1/Should-I-b...
- _wmd 11y ago> - perl6 is the first mainstream(ish) dynamic language to not suffer from a GIL of some kind. You can do real concurrency and parallelism in perl6. I went digging to try and understand what this meant, and seems it's referring to syntactic support for promises, which in at least the Rakudo implementation amount to a wrapper around a forking multiprocessing system (like the Python multiprocessing module). From my perspective this concurrency isn't any more "real" than equivalents available in existing languages, but maybe I'm looking at the wrong thing - you mention global interpreter locks, and usually they refer to threading. Does some implementation of perl6 have non-GIL threading? edit: from <https://perl6advent.wordpress.com/2012/12/11/day-11-parrot-threads/> https://perl6advent.wordpress.com/2012/12/11/day-11-parrot-t...: > The solution for these problems implemented in hybrid threads is to sidestep them altogether by disallowing write access to shared variables. The programmer (or in most cases the compiler) is obliged to declare a list of all shared variables before a newly created task is started. The interpreter would then create proxy objects for these variables which the task can use to access the data. These proxies contain references to the original objects. They use these references to forward all reading vtable functions to the originals. Write access on the other hand would lead to a runtime error. > In other words, all data is owned by the thread creating it and only the owner may write to it. Other threads have only read access. > For threads to be able to communicate with their creators and other threads, they still need to write to shared variables. This is where green threads come into play. Since green threads are light weight, it is feasible for a thread to create a task just for updating a variable. This task is scheduled on the interpreter owning this variable. To reduce latency, the task is flagged to run immediately. The data-owning interpreter will preempt the currently running task and process the new write task. Put another way, the data-owning interpreter is told what to write to its variables, so other threads don’t have to.
- gpvos 11y agoGIL stands for the Global Interpreter Lock, which python has been criticized for a lot. I don't know whether perl5 or other languages have one, really.
- 11y ago
- cpplinuxdude 11y agoLet's not forget what perl was created for; it's a practical extraction and report language. Initially it was used to extract tables from text documents, and its always had a strong focus on text manipulation and regular expressions. Its implicit variables and syntax mean you can write very, very concise code. Yet by following stylistic guidelines of your choice, you can write code that looks sane and maintainable. I really like the fact you can import os commands and call them as a part of the language. It makes writing scripts a breeze. In fact writing anything in perl is a breeze. Check rosetta code, you'll see Perl 6 is one of the most concise at every turn. As much as I really like python, I find that calling system commands is a pain.. calling os.system is obviously far from great, and calling subprocess can get cumbersome. I haven't played with perl in a while, but my past experiences with perl was always getting a lot done, with very little work.
- pyre 11y agoJust to note that it's not all puppies and unicorns. There are a lot of low-level commands that are all tied up in different modules in Perl. Like having to remember where what you want falls into the File::* namespace... or maybe what you need is in Cwd. I worked with Perl for 4 years, and while it's not the gauntlet of pain that people make it out to be, there were several annoyances (like needing to always hit the docs for that stuff).
- cpplinuxdude 11y agoI only used it for small scripts. I'd think twice before using it for anything more significant. What did you use it for, if I may ask? What how big a project are we talking about? I would have thought hitting the docs wouldn't be a part of the annoyances list. Did you feel you had to hit the docs more than with any other language?
- awwaiid 11y agoNote, however, that Perl6 is a completely different language with a different set of standard libraries and ecosystem and pros-and-cons. You'd be as well off comparing Perl6 to Ruby as you would Perl5.
- guelo 11y agoPerl 6 continues linguist Larry Wall's vision of making a very expressive language that matches the way humans think. To me the most unique aspect is Perl 6's unicode string handling which is probably the best unicode support of any language out there. I could see it catching on in niches that need to do heavy cross-characterset text processing.
- mundanevoice 11y agoI am curious, what's the use of learning perl6 in 2015?
- s_kilk 11y agoSame use as in learning any other language. We could very well have asked what was the use in learning Go in 2010, but look how that turned out. Perl6 is currently a very interesting language with a relatively weak module ecosystem. Which is a position many languages have been in before. Let's not dismiss it out of hand.
- jsnathan 11y agoI wonder what ever happened to the dream of Perl 6 running (or interfacing with) Perl 5 code out of the box, and thus having access to all of CPAN from the get-go. Does anyone know if that is still a goal? I always thought that would make a world of a difference.
- peteretep 11y agohttps://github.com/niner/Inline-Perl5/ https://github.com/niner/Inline-Perl5/ https://github.com/rakudo-p5/v5/ https://github.com/rakudo-p5/v5/
- cygx 11y agov5 isn't in a usable state right now.
- awwaiid 11y agoPerl6 is such a completely different language and implementation that calling Perl5 is no different than calling Ruby or Python -- they all involve effectively embedding or calling out to the other language. Here is a gist where I'm calling out to some Python. It is not done in the magical future way (which is in progress) of just doing "use matplotlib::pyplot:from<python2>" or similar, but not too bad. https://gist.github.com/awwaiid/ef3f0abcfa96e34977b4 https://gist.github.com/awwaiid/ef3f0abcfa96e34977b4 (I wrote this some months ago -- it can be a bit cleaner now)
- peteretep 11y agoI wish programmers could break away from "tutorials" and "introductions" that are just lists of syntax and keywords. I want short examples, brief explanations of those, and then some problems to solve.
- grondilu 11y agoHave you looked at the synopses (1)? That's how I've learnt Perl 6, and I've never been convinced by any other kind of Perl 6 documentation. To me the synopses are complete and explanatory enough. As far as problems to solve, there are the various entries in rosettacode (2). 1. http://design.perl6.org/ http://design.perl6.org/ 2. http://rosettacode.org/wiki/Category:Perl_6 http://rosettacode.org/wiki/Category:Perl_6
- thalesmello 11y agolearnxinyminutes.com solves your problem about how the language works, but doesn't give you problems to work with.
- stesch 11y agomonthly-salary = daily-rate * working-days Wow. This will make a few people happy who think underlines and camel case are ugly.
- Sharlin 11y agoAdding the missing $ sigils will uglify it quite a bit, though.
- zoffix222 11y agoThey don't need to be "missing". my \working-days = 200; Creates a working-days variable that you can't change.
- awwaiid 11y agoIsn't that sort of a mis-feature that we don't expect to see in code very much? I thought mainly people would be using sigils, and ideally the correct sort of sigil to indicate if it is a single thing, list of things, hash of things, callable thing, etc.
- zoffix222 11y agoI wouldn't call it a misfeature. I think especially in math stuff it would be useful. I've used Δ in my math for Color module and it both has the natural mathematical meaning and must not change after I calculate it: https://github.com/zoffixznet/perl6-Color/blob/master/lib/Color.pm6#L231 https://github.com/zoffixznet/perl6-Color/blob/master/lib/Co... What is a mis-feature is you can't assign-create to these variables when they're part with sigil-bearing variables, so, for example, here I ended up using a sigiled-Δ, which isn't as pretty :) https://github.com/zoffixznet/perl6-Color/blob/master/lib/Color.pm6#L142 https://github.com/zoffixznet/perl6-Color/blob/master/lib/Co...
- raiph 11y agoAiui it's for any time a coder prefers that a noun's name does not emphasize/convey the basic nature of the thing the noun refers to. Fwiw you can assign to such "raw" nouns if you declare that the raw noun you're declaring refers in turn to a rw container. For example, a plain `$` is a container (an anonymous Scalar): my \Δ = my $ = 100; Δ = 200; I came up with the following idiom when pondering snippets on twitter and the fundamental problem that twitter treats strings of the form `@foo` as twitter handles which messes up the formatting of tweets containing `@` sigil'd nouns: my \array =@= 1,2,3; array[2] = 200; say array; displays [1 2 200]
- krylon 11y agoI really like the fact that Perl6 has a proper type system. I like even more that you can mix static and dynamic typing, so to speak. After taking their sweet time, I am not overly confident about adoption of Perl6, but I hope I'm wrong. At least, from what I can tell so far, Perl6 manages to keep the spirit of Perl, while fixing a number of things that were wrong, or at least problematic, in Perl5.
- HeadlessChild 11y agoWhen is Perl 6 going to be a standard installed package for the Linux distributions (Debian, CentOS, Ubuntu)?
- perlgeek 11y agoI don't think anybody can predict the future well enough to answer that. Languages become part of the standard installation by having very commonly used toos written in them. I might be wrong, but I'm pretty sure ruby isn't part of a standard Debian installation, and neither is lua, for example. Ruby is very popular for web apps, but you don't need web apps to boot the computer, start a GUI and install packages, so it's not part of the standard installation. But it's only an 'apt-get install ruby2.1' or so away, and so is rakudo (the current Perl 6 implementation). The debian package in stable is outdated, but work on newer versions is in progress. (Don't know about CentOS, sorry).
- zimbatm 11y agoDoes Perl 6 have fundamental features that don't exist in other languages ? Just curious.
- perlgeek 11y agoI don't know if any of these features are really unique, but the combination of having them all is certainly unique: * Strings that are made of Unicode grapheme clusters instead of codepoints or bytes. This means that a substr() operation for example can't even accidentally rip a apart a base character and a combining character on top of it * Grammars as a language feature * Gradual typing * A built-in meta object protocol * Concurrency based on high-level primitives (promises, queues, supplies, ...) with syntactic support (instead of threads and locks; which are still available if necessary, but discouraged, because they don't compose well). * Lazy lists
- Woodi 11y agoYea, grammars looks simple-the-unique thing other languages don't have in 2015, 2016 and, I bet, 2017 too. Maybe even longer :)
- kamaal 11y agoThat's only at level 1, until you realize Perl 6 code is parsed by a grammar written in Perl 6. Its power is amplified by the part Perl 6 regexes are better than anything there is out there. Even better, this extends beyond ASCII and applies to Unicode too. And will work with other powerful control structures. I'd fix that date to something like 2027.
- draegtun 11y agoWhile Grammars as a language feature aren't mainstream (yet!) they're not a unique feature either. For eg. See the parse dialect which is a TDPL that comes with Rebol / Red - http://www.rebol.com/docs/core23/rebolcore-15.html http://www.rebol.com/docs/core23/rebolcore-15.html - https://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/Parse/Parse_expressions https://en.wikibooks.org/wiki/REBOL_Programming/Language_Fea... - http://www.red-lang.org/2013/11/041-introducing-parse.html http://www.red-lang.org/2013/11/041-introducing-parse.html
- user9756 11y agoGreat (basic) introduction with exception to the regex chapter because it felt like an introduction to regex instead of the regex features of perl6. Some things I found interesting (in addition to what s_kilk mentioned and linked to and others have already mentioned some of them) * Gradual typed! * Multi subroutine * Hyphen in variable names * @numbers.=sort * .WHAT * Catch blocks * .defined * Unless It will be fun :) I however don't understand the reason for the naming of eg elsif, my, slurp/spurt?? (instead of else if or local or fread/fwrite) Is it a perl culture thing? Because they mention in the tutorial that Perl 6 belongs to the C-family languages (and then call the "for" loop in C "loop").
- username223 11y ago> I however don't understand the reason for naming of eg elsif, my, slurp/spurt?? Yes, it's for historical reasons. "elsif" is spelled that way in Perl 5. Perl 5 has both "my" and "local" to specify lexical and dynamic scoping, respectively, so Perl 6 using "local" for lexical scope would be confusing. "slurp" is a common term for reading the entire contents of a file at once.
- cafard 11y ago"my" arrived after "local". The former is true lexical scoping, the latter isn't quite.
- tbrownaw 11y agoRight. As gp says, "local" is dynamic scoping. It's available as long as the declaration stays on the call stack. It more-or-less allows globals to be temporarily redefined.
- DonHopkins 11y agoThink locally, act globally.
- omaranto 11y ago
- imglorp 11y agoI am so happy they've included kebab-case identifiers :-) I've always thought they made more sense than camel or snake, because there's no shift key involved. It also brings fond memories of fun in lisp land.
- jrumbut 11y agoI'm so happy to learn the term kebab-case (and agree that it's very usable and supremely typable)
- ihsw 11y agoFor those looking to get started with Perl6 in Docker -- here is the related Docker Hub page: https://hub.docker.com/_/rakudo-star/ https://hub.docker.com/_/rakudo-star/ And its GitHub repo: https://github.com/perl6/docker https://github.com/perl6/docker
- lovboat 11y agoAt first sight I find amusing comparing Ruby to Perl 6. (a=. sort) (a.sort!) (a.what) (a.class) (say a) (puts a) (for @a=>item) (a.each {|item| ..} ) and the similarities, push, shift, splice, ... I see nothing new here. But I must say that Perl 6 seems to be easier to learn than Perl 5 for beginners.
- justinator 11y agoThis is just a little intro cheat sheet, it's not supposed to be scary - quite the opposite, in fact. Easy things should be easy. The magic is in the more advanced parts of the language. The, "hard things should be possible" parts.
- lovboat 11y agoShow me the more advanced parts of the language, are they transducers, monads, functors, natural transformations, auto-compilers, self-replicating systems, high AI in action, ML, NLP. What is the honey spot for this new language?
- justinator 11y agoIt may be Perl 6, but it's still Perl - and Perl is good for, "Getting Your Shit Done"
- raiph 11y agoA lot of the advanced stuff is internal work leading to a simple exterior (at least in principle, modulo bugs and optimization work). Think "tormenting implementors on behalf of users". For example, in Perl 6 a character at the language level is a grapheme. This is per a proper understanding of the Unicode standard. It seems that most folk (and language designers/designs, including eg gvr/py3) don't/didn't realize that Unicode always intended graphemes as the obligatory ultimate destination for modelling "characters" and providing truly clean Unicode text handling. (Swift has attempted the same thing but their current character iterating implementation and API are clearly inappropriate long term for a performant text manipulation focused language so they'll surely have to redo that part of Swift over the coming years.) Another example is the parallelizing, async, and concurrency features in Perl 6. These are all surprisingly simple to use and performant but took a lot of design talent, and engineering talent under the hood, to get right internally and simple externally. Sticking to positive stuff for a moment longer, some features bring important concepts from decades past in to this century. Most notably, afaict, Perl 6 provides a universal unrestricted grammar[1]. Aiui this could put help put "string rewriting", a relatively neglected mathematically proven isomorphism to the lambda calculus and turing machine models of computation, back on the map. It will be interesting to see what happens as Perl 6 matures. The biggest downside I see, beyond widespread negative associations with the name 'Perl', is immaturity. Perl 6 has lots of bugs, poor doc, is currently slow as molasses for a lot of stuff, and so on. [1] https://en.wikipedia.org/wiki/Unrestricted_grammar https://en.wikipedia.org/wiki/Unrestricted_grammar
- sigzero 11y agoI love that Perl 6 has a proper REPL now.
- raiph 11y agoA note of caution; it's way better than nothing and will get where it needs to be one day, hopefully in 2016, but it currently uses some awful hacks that make it suck for a lot of stuff.
- doodpants 11y agoThis guide is gorgeous; the choices made for fonts, styling, and formatting are just perfect. I wish more online documentation looked this good.
- justinator 11y agoPeeping at the source code, looks like this may have been generated by http://asciidoctor.org http://asciidoctor.org (in case you would like something similar for yourself). For Perl-folk, there is a module to convert between POD and Asciidoc: https://metacpan.org/pod/Pod::AsciiDoctor https://metacpan.org/pod/Pod::AsciiDoctor
- DyslexicAtheist 11y agoI'm looking for several Perl developers in Berlin for a full-time permanent position: http://valbonne-consulting.com/job/perl-or-lua-software-developers-real-time-bidding/ http://valbonne-consulting.com/job/perl-or-lua-software-deve...