Perlito Perl programming language compiler
Perlito, a compiler collection that implements Perl 5 and Perl 6.
Perl to Java compiler
PPC Portable Perl Compiler
PPC Portable Perl Compiler
Flávio S. Glock
Booking.com
PPC Team
Perl to Java compiler
Fun: Hackathons, community
Technical: Typed variables; explore the limits
Business: Hadoop, Android
Perl to Java compiler
https://github.com/fglock/Perlito
https://metacpan.org/pod/Perlito5
Not so easy in Java world
Nice things in Java world
Work in progress
Perl5 Grammar
token stmt_yadayada {
'...'
{
$MATCH->{capture} = Perlito5::AST::Apply->new(
code => 'die',
namespace => '',
arguments => [ Perlito5::AST::Buf->new( buf => 'Unimplemented' ) ],
);
}
};
link: https://github.com/fglock/Perlito
Perl5 BEGIN blocks
BEGIN {
for my $i ("first", "second", "third") {
*{"main::sub_$i"} = sub {
say "This is $i";
};
}
}
java -jar perlito5.jar -I src5/lib -Cperl5 demo_begin.pl
Perl5 eval-string
say "input: ";
my $x = <>;
eval <<~'EOT';
chomp $x;
say '$x = ', $x;
say "next: ", ++$x;
EOT
java -jar perlito5.jar -I src5/lib demo_eval.pl
java -jar perlito5.jar -I src5/lib -Cjava demo_eval.pl
Perl to Java compiler
Perl to Java compiler
// print “hello, World!\n”;
PlCORE.print(
PlCx.VOID,
PlCx.STDOUT,
new PlArray(
new PlString("hello, World!" + (char)10)
)
);
Perl to Java compiler
Perl to Java compiler
Java Extensions
use feature 'say';
use strict;
package Calendar { import => "java.util.Calendar" }
package TimeZone { import => "java.util.TimeZone" }
my Calendar $calNewYork = Calendar->getInstance();�
$calNewYork->setTimeZone(TimeZone->getTimeZone("America/New_York"));
my $hour = $calNewYork->get(Calendar->HOUR_OF_DAY);
my $min = $calNewYork->get(Calendar->MINUTE);
say "Time in New York: $hour:$min";
Dual object system
https://github.com/fglock/Perlito/blob/master/misc/Java/TestThread2.pl
perl perlito5.pl -Isrc5/lib -Cjava misc/Java/TestThread2.pl > Main.java ; javac Main.java ; java Main
Perl to Java compiler
Command line compiler
Runtime library
Parser development
DSL for Java imports
Compiler optimization
Perl to Java compiler
Android test suite
Code extracted from “lib/Bookings/Tools/UserAgent.pm”
(code is not shared with main.git)
http-tests/src/test/perl/UserAgent.pm
http-tests/src/test/java/com/booking/common/http/UserAgentPerl.java
Perl to Java compiler
Android development environment
Android specific targeting
Android <> Java SE
Integration with “Android Studio”
- Gradle task
- special “-Candroid” compiler switch
Perl to Java compiler
about 10 people have worked in compiler internals.
We’ve used the Perl to Java compiler in places where rewriting code in Java was painful, such as in regex-heavy business rules.
Perl to Java compiler
Still fun to work with, developing a community
Still technical challenges
Still going after more business
java -jar perlito5.jar -I src5/lib -Cjava camel.pl
Perl to Java compiler
Pugs, v6.pm: Audrey, "putter"
Perlito5: Jesse, “pmurias”, Shlomi, Simon
Perlito5-Java: Bosko, Yati, Bruno, Bas, Ovidiu,
Emmanuel, Frederico, Imran, Luca�
Perlito Perl language compiler
Flávio S. Glock