CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions:
Do you plan to switch to perl 6 ?

 



ningji
User

Sep 30, 2017, 8:47 PM

Post #1 of 6 (777 views)
Do you plan to switch to perl 6 ? Can't Post

I myself am very disappointed that perl 6 changed many syntax from perl 5,

Was: $#array+1 or scalar(@array)
Now: @array.elems
Index of last element in an array:
Was: $#array
Now: @array.end

Regex match is done with the smart match operator ~~, the perl 5 match operator =~ is gone.
if "abc" ~~ m/a/ { ... }

Was: for ($i=0; $i<10; $i++) { ... }
Now: loop ($i=0; $i<10; $i++) { ... }
loop can also be used for infinite loops:
Was: while (1) { ... }
Now: loop { ... }

Don't understand why to break backwards compatibility, very sad.


FishMonger
Veteran / Moderator

Oct 1, 2017, 9:06 AM

Post #2 of 6 (775 views)
Re: [ningji] Do you plan to switch to perl 6 ? [In reply to] Can't Post

They did not break backwards compatibility.

While they do share the same root name and a number of other things, they are entirely different languages.


Quote
Was: $#array+1 or scalar(@array)

Yuck, why would you use that "was" syntax? That is rarely ever coded that way or at least I should say is should not be coded that way. You don't show how you would actually use it, but here is the normal way to code that.

Code
my $cnt = @array;


Similarly, your perl 5 (C style) for loop syntax is highly discouraged by most Perl coders. Instead you should be using Perl's for loop style.

Code
for (0..9) { ... }

Perl 6 should also support that style. In fact the documentation actually shows that style but puts the range in an array.

I have not tested perl 6 yet, but I plan on doing so soon. For the vast majority of the Perl coders, it's not a decision of whether or not to "switch"; it's a decision of whether or not to add another language to your repertoire.


(This post was edited by FishMonger on Oct 1, 2017, 9:23 AM)


ningji
User

Oct 1, 2017, 10:30 AM

Post #3 of 6 (765 views)
Re: [FishMonger] Do you plan to switch to perl 6 ? [In reply to] Can't Post

ok, if perl 6 is a different language, then should just name it sth. else. I've been waiting for the new perl to beat python, but seems many perl coders like me won't jump into perl 6 yet.

I haven't gone through all your reply yet, but at least for this one, why do they want to change this ?

Regex match is done with the smart match operator ~~, the perl 5 match operator =~ is gone.
if "abc" ~~ m/a/ { ... }

I'm pretty upset.


FishMonger
Veteran / Moderator

Oct 1, 2017, 2:35 PM

Post #4 of 6 (761 views)
Re: [ningji] Do you plan to switch to perl 6 ? [In reply to] Can't Post

That's a strange thing to be upset about. It's a change of 1 character.

I don't know why they made that decision but I'm sure the answer is available on multiple perl 6 mailing lists.
https://perl6.org/archive/lists/
https://perl6.org/community/

You might also want to search youtube for YAPC talks related to perl 6, especially ones given by Larry. He often explains some of the design decisions.


(This post was edited by FishMonger on Oct 1, 2017, 2:40 PM)


Laurent_R
Veteran / Moderator

Oct 5, 2017, 1:48 AM

Post #5 of 6 (725 views)
Re: [ningji] Do you plan to switch to perl 6 ? [In reply to] Can't Post

Hi Ninji,

although I'm still using Perl 5 most of the time, almost daily in fact (at least on working days), I started to learn Perl 6 a few years ago. At the very beginning, I was also somewhat upset by syntax changes such as some you describe, but once you get into it, you figure out that there are very good reasons for that and that, at the end of the day, the Perl 6 syntax is much more consistent than Perl 5 ever was. These syntax changes really make a lot of sense.

I should add that, if you know P5, then P6 is very easy to learn, because P6 really has the same spirit as P5.

I could write much longer on this -- after all, I wrote a full book on Perl 6, which you can read online for free or buy in printed form from Amazon and other book stores (http://greenteapress.com/wp/think-perl-6/. But, for now, I will only say that P6 is really a nice language which keeps everything nice that P5 has, and adds much more. Once you get past the few syntactical changes compared to P5 (which really does not take too much effort), you really feel at home and just enjoy it even more.


ningji
User

Oct 5, 2017, 6:17 PM

Post #6 of 6 (711 views)
Re: [Laurent_R] Do you plan to switch to perl 6 ? [In reply to] Can't Post


In Reply To
Hi Ninji,

although I'm still using Perl 5 most of the time, almost daily in fact (at least on working days), I started to learn Perl 6 a few years ago. At the very beginning, I was also somewhat upset by syntax changes such as some you describe, but once you get into it, you figure out that there are very good reasons for that and that, at the end of the day, the Perl 6 syntax is much more consistent than Perl 5 ever was. These syntax changes really make a lot of sense.

I should add that, if you know P5, then P6 is very easy to learn, because P6 really has the same spirit as P5.

I could write much longer on this -- after all, I wrote a full book on Perl 6, which you can read online for free or buy in printed form from Amazon and other book stores (http://greenteapress.com/wp/think-perl-6/. But, for now, I will only say that P6 is really a nice language which keeps everything nice that P5 has, and adds much more. Once you get past the few syntactical changes compared to P5 (which really does not take too much effort), you really feel at home and just enjoy it even more.


Thanks very much for the link of your book, i'll definitely read it this weekend.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives