4 ms·
Note that its more or less "how to write perl 5 in perl 6" Sorta like the old F2C, Fortran to C, converter. You don't get idiomatic C, but you do get a fortra
by VLM 11y ago
Note that its more or less "how to write perl 5 in perl 6"
Sorta like the old F2C, Fortran to C, converter. You don't get idiomatic C, but you do get a fortran program that compiles and runs as a C program, more or less.
Some parts of perl6 are annoyingly urbit-y, come on, you guys just had to rename ARGV and rename scalar and the for-foreach transition is ridiculous. I suspect at least a decade of people pointing at items and verbally calling them scalars and so on. Urbit is cool but is most famous for feeling the need to rename everything.
Here's a slide stack for going from MOOSE (more or less the most popular "real" perl5 OO implementation, technically an "add on" for perl5 although many people will only program perl5 with MOOSE) to perl6 OO. At least toward the middle there are adjacent slides of "this is how you do it in MOOSE" "this is how you do it in perl6"
http://www.slideshare.net/lichtkind/p6-oo-vs-moose-moo http://www.slideshare.net/lichtkind/p6-oo-vs-moose-moo
I'd like to read a book titled something like "Modern Perl; For Perl 6.0"
The transition will be such fun; I have some business logic libraries where I'll have to replicate behavior and test suites simultaneously for awhile in MOOSE/5.0 and in 6.0.
(response to unfortunately hellbanned berntb question about replication, the codebase is huge and interrelated and can't be forklift upgraded all at once; its already non-trivial to do stuff in both perl and scala, and now it would be perl5 perl6 and scala all more or less interoperating)
- berntb 11y agoIt might be too much stress or too little coffee, but I don't understand the last part. Why would you need to replicate behaviour and tests? You mean it will take time before you trust the "use Perl 5 code in Perl 6" bridge that is worked on, so it isn't enough to run the Perl 5 tests and then use that code in Perl 6? (Or you think there will be bad interactions with Moose and Perl 6 OO?) Edit: Huh, I was shortly un-hellbanned and am Hellbanned again since the previous comment didn't live up to some interesting-level standard? :-)
- amyjess 11y ago> Edit: Huh, I was shortly un-hellbanned and am Hellbanned again since the previous comment didn't live up to some interesting-level standard? :-) Maybe your comment got rescued by someone using the new vouch feature?
- rurban 11y agoBecause you cannot trust the 5-to-6 translators yet, so you have to test the translated perl6 code in perl6. It's a completely new VM, with new syntax, compiler and run-time. Even with Inline::Perl5 you need to test the implicit 5<->6 casts with the perl6 vm (which might be rakudo or some other engine). Moose contains only a small subset of the Perl6 OO, and has also different syntax. E.g. in perl6 types lead to optimizations, in Moose to pessimizations. Rewriting in Perl6 is always preferred, as Perl6 is a much nicer language.
- zoffix222 11y agoJust keep that codebase in Perl 5? Perl 6 isn't a replacement for Perl 5. It's a whole new language. Perl 5 is still actively maintained and used.
- dragonwriter 11y ago> Perl 6 isn't a replacement for Perl 5. It's a whole new language. ...with an exceedingly poorly chosen name. (Which is not to diminish how good it is as a language.)
- kbenson 11y agoI don't think anyone disagrees with that at this point, but hindsight is 20/20. I personally wouldn't mind if there was a slow shift towards using the current main implementation's name (Rakudo) or some other (NG Perl?) for the language down the line, but I think doing so before release would just make every problem worse, including Perl 5's ("Oh, Perl 6 is no more? It failed? I knew it would... Perl is a dead end.")
- kbenson 11y agoIn Perl 5, for and foreach have been aliases for eachover for a very, very long time. # perl -E 'foreach (my $i=0; $i<3; $i++) { say $i }' 0 1 2 # perl -E 'for my $i (0..2) { say $i }' 0 1 2 I never use foreach in Perl 5, and that's what I'm paid to write in. This is just a reaffirming that "for" is the preferred syntax (and this isn't a TMTOWTDI thing, this is two reserved words for the exact same code construct thing). Moose, interestingly enough, is based on backporting the then-proposed Perl 6 object system, so a lot of the concept sand terminology will be the same. But it sounds like you are talking about transitioning from Perl 5 to Perl 6. Why? The naming is confusing, but most people are not expected to convert codebases to Perl 6. It's not an upgrade, it an also. If you want both, use Inline::Perl5[1] and just call back and forth between the interpreters. 1: https://github.com/niner/Inline-Perl5 https://github.com/niner/Inline-Perl5
- colomon 11y agoThough to be fair, for the last year or so, every time I've needed to hack on a p5 script for $work, my first step has been to convert it to p6. It usually is pretty quick for 50-100 line scripts, and generally it's a lot easier to reason about changing the code once it's in p6.
- raiph 11y agoWith apologies for the blizzard of questions: Do you have/write test suites? In P5? P6? Have you seriously tried any of the p5-to-p6 translators with your scripts? Was the usage message typically much-improved, about-the-same, or needs-work after your first successful compile? Same question for command line argument binding? Any speed stories? Scripts that started unacceptably slow but eventually got there? Ones that beat their Perl 5 originals? Ones that didn't really make it yet? Have you converted any of your Perl 6 conversions back in to Perl 5 code (to retain the clarity developed in the conversion to 6 but regain the speed that Perl 5 has)? Do any of your conversions use Perl 5 modules?