Release the Turducken!!!!
about me
public class AboutMe {
public static void main(String[] args) {
System.out.println("Java Developer and Trainer");
}
}
#!/usr/bin/env perl
print 'I used to be a Perl Dev.', "\n";
!expert
but ... why?!
maybe there is something you can do faster in java?
maybe you have something in java you don't want to rewrite?
you say po-tay-toe, i say po-tah-toe
Perl 6
has two backends
== Installing modules for JVM
cd modules/panda && sh -c "PATH=/home/ghost/rakudo-star-2016.07/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /home/ghost/rakudo-star-2016.07/install/bin/perl6-j bootstrap.pl"
^@==> Bootstrapping Panda
^@^@^@Cannot unbox a type object
perl Configure.pl --backends=moar,jvm --gen-moar
Perl 6
Please note that this release of Rakudo Star is not fully functional with the
JVM backend from the Rakudo compiler. Please use the MoarVM backend only.
#perl6 confirms jvm backend !works since at least the GLR in December-ish
requires J7, no panda, no zef
install/bin/nqp-j:exec java -Xss1m -Xmx512m
can we ...
- call java from perl 5?
- call perl 6 from perl 5?
- call perl 5 from java?
can we ...
- call java from perl 6?
- call perl 5 from perl 6?
- call perl 6 from java?
can we ...
java
from
perl 5
from
perl 6
??!!
ingredients
- Inline::Java
- java compiler into perl
- Inline::Perl5
- perl interpreter into perl6
- Inline::Perl6
- moar backend into perl
Inline::Java
Warning: Cannot install Inline::Java, don't know what it is.
The PerlInterpreter extension allows Inline::Java to be loaded directly from
Java using an embedded Perl interpreter. It is still EXPERIMENTAL and
may not build or work properly on all platforms. See documentation for
more details.
Do you wish to build the PerlInterpreter extension? [n] n
__DATA__ ok ...
Inline::Perl5
- >= 5.16
-
-Duseshrplib
-
-Dusemultiplicity
-
-fPIC
-
- $=data, say qq:to/EOF/; not ok ...
Inline::Perl6
- must be installed after Inline::Perl5
- must know where Perl 6 is
java from perl5 from perl6 ... the turducken!!
#!/usr/bin/env perl6
use Inline::Perl5;
my $p5 = Inline::Perl5.new;
$p5.run(q|
use Inline Java => <<'END_OF_JAVA_CODE' ;
class Pod_alu {
public Pod_alu(){ }
public int add(int i, int j){ return i + j ; }
public int subtract(int i, int j){ return i - j ; }
}
END_OF_JAVA_CODE
my $alu = new Pod_alu() ;
print($alu->add(9, 16) . "\n") ; # prints 25
print($alu->subtract(9, 16) . "\n") ; # prints -7
|);
what doesn't work?
- reading p6,p5 in from a file to the other
- jvm backend, PerlInterpreter option Inline::Java
- stuff already mentioned
links
- http://search.cpan.org/~ingy/Inline-0.80/lib/Inline.pod
- https://metacpan.org/pod/Inline::Perl6
- https://github.com/niner/Inline-Perl5
- http://search.cpan.org/dist/Inline-Java/Java.pod
- https://github.com/elohmrow/turducken
#!/usr/bin/env perl
use strict;
use warnings;
use Inline Java => 'DATA';
my $java = new Hello();
$java->printSomething("Hello Bradley!");
__DATA__
__Java__
public class Hello {
public void printSomething(final String something) {
System.out.println(something);
}
}
java from perl 5 ... the ducken
perl 5 from perl 6 ... the turduck
#!/usr/bin/env perl6
use Inline::Perl5;
my $p5 = Inline::Perl5.new;
$p5.run(q|
package Person;
use Moose;
has 'name' => (is => 'rw');
1;
|);
$p5.use('Person');
EVAL q|
my $person = Person->new(name => 'Bradley');
print 'Hello ', $person->name, "!\n";
|, :lang<Perl5>;
#!/usr/bin/env perl
use strict;
use warnings;
use Inline::Perl6;
my $p6 = Inline::Perl6->new;
$p6->run('
class Person {
has Stringy $.name;
}
say "Hello ", Person.new(name => "Bradley").name(), "!";
');
perl 6 from perl 5 ... the reverse turduck
perl 6 from java ... the reverse turen
perl 5 from java ... the reverse ducken
java from perl 6 ... the turen
Release the Turducken!!!!
By elohmrow
Release the Turducken!!!!
- 1,217