9 ms·
Perl 6 hands-on tutorial – A small introduction to a big language [pdf]
- deleted 11y ago[deleted]
- cms07 11y agoI absolutely love Perl, and I think that the newest versions of Perl 5 have taken much of the good things that Perl 6 promised and added them. I really think that Perl 6 misses the point and removes all of the charm of Perl. Why change sigils and all of these operators? The people who don't like them aren't using Perl anyway, and they won't be using Perl 6 just because it implements them in a more obvious but less meaningful way. I also don't think the addition of a more mainstream object system is a positive thing, but that's a debate for another time. Edit: And it's not just about sigils, but about changing things for no meaningful reason, especially things that set Perl apart and make it what it is.
- liveoneggs 11y agoAre you talking about changing $foo[0] to @foo[0] ?
- MadcapJake 11y agoName some things that they changed for "no meaningful reason". As you state, Perl 5 has added a number of things that Perl 6 promised. So why would you want Perl 6 to just be what Perl 5 has become? They're two completely separate languages with some shared syntax/semantics.
- hayksaakian 11y agoFrom an outside perspective, the distinction between Perl 5 and Perl 6 is confusing. Are they literally separate languages? Did Perl 5 come after Perl 6?
- kbenson 11y agoPerl 6 is like Python 3, but they decided early on that if it wasn't going to be backwards compatible they might as well go wild with enhancements and fixes to earlier mistakes. As such, while Perl 6 is seen as a successor to Perl 5, it doesn't obsolete Perl 5. There's still plenty of active development and new features happening in Perl 5 (after a lull in development, likely because of Perl 6). It's widely accepted at this point that the name could and would have been better off as something else, like Perl NG (there is good reason to want to retain some Perl mindshare, it is very related at a language level) or something, but by the point that was realized the damage was done. People still argue over whether they should change it to clear this issue up for the layman, but there are good reasons to not want to give up the long past associated with the Perl 6 name. It's becoming slightly less important now that Perl 6 can now inline a lot of Perl 5 code and modules (including modules with compiled code)[1]. 1: https://github.com/niner/Inline-Perl5 https://github.com/niner/Inline-Perl5
- jasonjayr 11y agoPerl 6 started around when perl 5.8 was released. Then Perl 5 went stagnant while most of the core language developers were working on Perl 6. After a few years where there were competing implementations of perl 6, and still some wild ideas being tested, folks that still were using Perl 5 watched the rest of the languages develop, and the growing buglist against perl 5, and starting poaching ideas from Perl 6, ruby, python, and improving the Perl 5 runtime. Eventually, The Perl 5 camp committed to regular releases, and continued renewed development in the engine, and it is still pretty good. But the damage has been done @ this point -- a lot of the community has wandered off to other 'cool' languages and frameworks. The confusion will continue, especially since it's become clear Perl 6 is quite the departure from Perl 5, and there is a LOT of code in the wild using Perl 5. I've seen some talk of the Perl 5 folks asking Larry Wall to rename Perl 6, but he's declined to do so. With perl6's grammar support, some folks are working on importing the perl5 grammar into perl6[0]. Fortunately, there's a very rich testing environment(in the form of CPAN) to ensure this effort will be stable. [0] https://github.com/rakudo-p5/v5/ https://github.com/rakudo-p5/v5/
- kbenson 11y ago
- cwyers 11y agoI mean, if Perl 6 didn't want to be confused with being the same language as Perl 5, it didn't have to increment the version number by one and keep the name. As far as why one would want Perl 6 to just be Perl 5 plus some new stuff, that's really how most languages handle keeping the same name and incrementing the version by one. People who have Perl 5 code and want to keep writing in the same language but with more whathaveyou probably want Perl 6 The Completely Separate Language to go away so that Perl can get the kind of Perl 6 any other language would've gotten by now.
- keeperofdakeys 11y agoAs someone who is relatively new to perl, I think perl 6 is definitely a positive direction. It removes lots of inconsistencies, while providing a clean base for future expansion. For something like the sigils, what's more important - to know that a variable is a scalar, or that it's some kind of hash/array? The second would definitely be less confusing when learning the language. There are also definitely some good things coming out of perl 6, like this https://www.youtube.com/watch?v=JpqnNCx7wVY https://www.youtube.com/watch?v=JpqnNCx7wVY
- 221541281e0 11y agoododafa
- logicallee 11y agostopped reading on slide 7. What do you think this does: say 1.WHAT; "say" prints something, and nothing was previously declared. What do you think it prints?
- dmux 11y agointeger?
- logicallee 11y agoyes. Maybe it's more reasonable than I thought (or I gave more information than reasonable - I've now removed some.) I don't think "say 1.WHAT" is reasonable syntax in the slightest.
- labster 11y agoWell, "1.WHAT.say" is also available. But Perl 6 is designed to put code smells in capital letters. EVAL, for example. WHAT shouldn't be used in normal code, but it's useful as a teaching tool or for debugging. If you want to test if something is an integer, you'll want "1 ~~ Int" instead.
- logicallee 11y agoLet me get this straight - the first example in the tutorial is code that you shouldn't write. Got it. By the way guys, string concatenation isn't . or + or a comma or something. It's a tilde: ~ 'a' ~ 'b' to get 'ab'. Because it looks like a "piece of string" ... that ties ... strings together, apparently.
- SamReidHughes 11y agoGetting the type of a value is useful to beginners and belongs in a tutorial. The one time I tried Perl 6 was a few weeks ago, and it took a while to find out how to do this exact thing.
- natch 11y ago"Try 0.1 + 0.2 == 0.3 in some other language, then try it in Perl 6." Whoa, wtf python: $ python Python 3.4.3 (default, Jul 13 2015, 12:18:23) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 0.1 + 0.2 == 0.3 False >>>
- schoen 11y agoPeople have also very often been freaked out by >>> 1/2 0 >>> 2/3 0 ... and this has changed from Python 2 to Python 3. But the floating-point vs. rational/decimal hasn't. You might get what you want from >>> import decimal >>> decimal.Decimal('0.1') + decimal.Decimal('0.2') == decimal.Decimal('0.3') True Still, that seems like a bunch of extra work compared to the more obvious way to type in numbers!
- natch 11y agoCue the sophomoric replies about IEEE floating point number representation. One of the cool things about Perl, though I haven't used it much for years and have been enjoying my break from it (hello, Python!) is the DWIM philosophy.
- mollmerx 11y agoI had to look that one up: DWIM = Do What I Mean
- chubot 11y agoWhy is this surprising? Floats are defined by the hardware essentially, not the language. And this is how they work: they're binary, not decimal. Computers are binary, not decimal. 0.1 can't be represented exactly as binary. Python has a decimal type, if that's what you want: https://docs.python.org/2/library/decimal.html https://docs.python.org/2/library/decimal.html I consider it a basic point of computer literacy to understand this.
- _pmf_ 11y ago> I consider it a basic point of computer literacy to understand this. Yes, but just because fractional notation defaults to a floating point representation in most languages does not mean that the option of defaulting to decimal/rational notation at the language level should be ruled out generally.
- the-owlery 11y agoIt's great that this is available (haven't worked through it yet). Two major show-stoppers for me right now though: * In the Perl 6 repl, I can't use my up/down arrows, or ^p/^n to get at previous lines I typed, nor ^a/^e and alt-B/alt-F to navigate on the line. * In the repl, I can't do `doc(some-func)` to get at docstrings.
- kbenson 11y ago> In the Perl 6 repl, I can't use my up/down arrows, or ^p/^n to get at previous lines I typed, nor ^a/^e and alt-B/alt-F to navigate on the line. Really? In they version I have access to arrow keys and ^p/^n/^a/^e all function. I've just been informed that what you need is "panda install Linenoise" to install the Linenoise module to get this functionality. I agree documentation in the language would be nice. A module could handle that nicely.
- kamaal 11y agoI think this kind of stuff should be available out of the box. I'm learning Perl 6 too, Inability to use the arrow keys has almost left the REPL unusable to me. I'm just writing programs in proper files and executing them.
- kbenson 11y agoI agree. Maybe rakudobrew should have a target that hits install, panda and p6doc and that being the default for new setups. FYI, you can install p6doc with "panda install p6doc", which is the Perl 6 equivalent of perldoc. I don't believe it has in-language methods yet, but I imagine it wouldn't be that hard. For now, it's a CLI tool. # p6doc Str.tclc routine tclc multi sub tclc(Str:D ) returns Str:D multi method tclc(Str:D:) returns Str:D Turns the first character to title case, and all other characters to lower case (not implemented in Niecza)
- the-owlery 11y agoThanks. Tried installing but got errors. ==> Fetching p6doc ==> Building p6doc ==> Testing p6doc # Failed test 'empty blocks argument gives undefined content' # at t/pod-convenience.t line 31 # Looks like you failed 1 test of 7 # Failed test 'pod-with-title' # at t/pod-convenience.t line 23 t/pod-convenience.t .. Failed 2/10 subtests t/pod-htmlify.t ...... ok Method 'super' not found for invocant of class 'Array' in sub visit at /home/me/.panda-work/1441386381_4/lib/Perl6/TypeGraph.pm:89 in sub visit at /home/me/.panda-work/1441386381_4/lib/Perl6/TypeGraph.pm:89 in method topo-sort at /home/me/.panda-work/1441386381_4/lib/Perl6/TypeGraph.pm:92 in method parse-from-file at /home/me/.panda-work/1441386381_4/lib/Perl6/TypeGraph.pm:82 in method new-from-file at /home/me/.panda-work/1441386381_4/lib/Perl6/TypeGraph.pm:30 in block <unit> at t/typegraph.t:8 t/typegraph.t ........ Dubious, test returned 255 (wstat 65280, 0xff00) Failed 8/8 subtests This is with a fresh (as of minutes ago) `rakudobrew build moar`: $ perl6 -v This is perl6 version 2015.07.1-728-g9c5cb50 built on MoarVM version 2015.07-108-g7e9f29e