Re: Perl 5, Python, Rakudo, C/C++, Java, Lua?
by Arunbear (Prior) on Mar 12, 2015 at 10:40 UTC
|
Does Inline::Perl5 embed the Perl5 interpreter in the Perl6 one?
| [reply] |
|
|
| [reply] |
Re: Perl 5, Python, Rakudo, C/C++, Java, Lua?
by Tux (Canon) on Mar 14, 2015 at 10:08 UTC
|
Inline::Perl5 now supports passing IO (including deep and dark IO from within XS), so this code works:
use v6;
use Slang::Tuxic;
use Inline::Perl5;
my $p5 = Inline::Perl5.new;
$p5.use ("Text::CSV_XS");
my @rows;
my $csv = $p5.invoke ("Text::CSV_XS", "new")
or die "Cannot use CSV: ", $p5.invoke ("Text::CSV_XS", "error_diag
+");
$csv.binary (1);
$csv.auto_diag (1);
my $fh = open "/tmp/hello.csv", :r, chomp => False;
my Int $sum = 0;
while (my $r = $csv.getline ($fh)) {
$sum += +$r;
}
$sum.say;
To give an example of performance (seconds needed to parse 10000 lines of 5 fields each). Note that Text::CSV::Easy_* only accepts valid CSV and has no options.
When I started in october 2014, the Regex based solution took 260 seconds, so improvement in the language itself is made on a daily basis!
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] |
|
|
Thanks for the benchmarks! Come back when, or I should rather say, if you succeed to make something that's not several hundred times slower than something that actually works. I doubt you ever will.
Ada attracted much attention from the programming community as a whole during its early days. Its backers and others predicted that it might become a dominant language for general purpose programming and not just defense-related work. Ichbiah publicly stated that within ten years, only two programming languages would remain, Ada and Lisp. Early Ada compilers struggled to implement the large, complex language, and both compile-time and run-time performance tended to be slow and tools primitive. Compiler vendors expended most of their efforts in passing the massive, language-conformance-testing, government-required "ACVC" validation suite that was required in another novel feature of the Ada language effort.
You are building another Ada, this time without the backing of DoD and, more importantly, with no chance of a Perl6 mandate.
Jenda
Enoch was right!
Enjoy the last years of Rome.
| [reply] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|
Re: Perl 5, Python, Rakudo, C/C++, Java, Lua?
by einhverfr (Friar) on Apr 01, 2015 at 13:29 UTC
|
Looks interesting. I am watching some parts of Perl 6 and this could be quite helpful. I am however taken aback by "most of CPAN should work" because I am not sure what would be the obstacles there. Are there specific features that would not work? Like maybe tail calls via goto &subname? Or is this more like "we haven't tested it entirely?
If Perl 5 modules work flawlessly in Perl 6 including language features unsupported in the latter, then that would give me additional confidence. I actually use tail calls in Perl 5 and that is one of the larger features that if it is not supported would keep me from upgrading, but if I can put it in a Perl 5 module, then no harm done.
| [reply] |
|
|
I'd not be surprised if the total number of CPAN modules actually tested by everyone who's tried Inline::Perl5 is less than 100 so far. A few folk on #perl6 have mentioned using it. Tux has mentioned using Inline::Perl5 with Text::CSV_XS elsewhere in this thread. Stefan Seifert, the author of Inline::Perl5, said it was working with DBI a few days after his first commits to Inline::Perl5 and he's since demo'd using it with Catalyst.
Stefan has also briefly touched on some Perl 5 features that are not expected to work with Inline::Perl5.
Another important option when considering mixing Perl 5 and Perl 6 is Inline::Perl6.
Btw `&foo.nextwith...` is supposed to one day tailcall the `foo` sub but it's not yet been implemented in Rakudo.
| [reply] |
|
|
Thanks for the nextwith stuff. I will keep an eye on that.
| [reply] |
|
|
You can do tail calls in Perl5 now: 5.4.2 Creating Tail Calls in Higher Order Perl; see also Sub::Call::Tail.
The CPAN has plenty of “interesting” code that doesn’t work everywhere Perl5 does. It seems likely that a slightly smaller portion would be able work under any kind of harness, Perl6 or otherwise.
| [reply] |
|
|
Yes you can. goto &subname also does them. I don't see anything in Perl 6 docs for this functionality however.
| [reply] |
Re: Perl 5, Python, Rakudo, C/C++, Java, Lua?
by Jenda (Abbot) on Mar 14, 2015 at 01:03 UTC
|
. o { "No, it would not." }
Jenda
Enoch was right!
Enjoy the last years of Rome.
| [reply] |
| A reply falls below the community's threshold of quality. You may see it by logging in. |
| A reply falls below the community's threshold of quality. You may see it by logging in. |