• Haven’t we been here before?
• Has anything changed?
• Is C-based Perl a 10-point Stag?
• Doesn’t Perl already have a VM?
• Isn’t Java really slow?
• Isn’t Java proprietary / not OSS?
What could we gain?
• Uniformity of Deployments
• Performance (mostly via JIT tech)
• Interop (not just with Java)
• Static type improvements
Open Source Aspects
• Java is, to all intents and purposes, Open Source
• Virtually everything is GPL, Iced Tea is plugging the
tiny remaining gaps
• Open processes, as well as open code - this has
problems as well as beneﬁts
• Consensus building among competing vendors is
important - similar to standards work in some ways
• MLVM and jvm-l
• Stack-based VM : No Registers
• Single byte opcodes, with restricted args
• Constant pools
• JIT subsystem
• Almost-typelessness of JVM (as opposed
• Perl package == Java class
• Perl function == Java method
• Perl object == Instance of subclass of SV
• Aligned calling conventions
• Java types hosted as a ‘foreign’ type within
The SV class
• Houses all basic SV information
• New “foreign object” slot - for proxying
Java (and other) objects
• AV and HV are subclasses of SV
• AOT to begin with (no eval)
• No way to directly manipulate the JVM stack frame
• JVM has several invoke* opcodes
• All are tightly type-constrained at compile time
• Not good for dynamic languages
• JRuby tries to get round it - but problems
• Some dynlangs invent private calling conventions -
• Need a “typesafe function pointer”
• New opcode, and a new “bootstrap” type - MethodHandle
• invoke() doesn’t exist at compile-time
• will use the new invokedynamic bytecode
• This is all pre-release and may change a bit before Java 7...
Tools for Compilation
• AOT Compilation to start with (ie no eval)
• Choice of an AST / Codegen lib:
• Homegrown, using ASM + invokedynamic
• Kawa (Scheme implementation)
• Automated Parser Generator
• Java-based (some .NET support)
• Compiles a grammar to a set of Node
• Automatic CST to AST transformations
• Node is a class, not an interface, subclasses
• Walks of the parse tree cannot directly
annotate it - have to use auxiliary structures
for semantic information
• Very nice and clean AST
• Pretty damn close in many ways...
• Everything-Is-An-Object seems unPerly
• Ruby strings are fubared from a Perl POV
• Plenty of ideas to borrow
• Key people are approachable and friendly
• Basic approach - take a yacc parser and port it
directly to Java as a starting point seems sound
A Modest Proposal
• Restricted semantics (also: new)
• Subset of syntax?
• Moose as new core keywords
• New keywords for exceptions?
• Sanitizing a core set of Pure-Perl modules
• Lots of work needed to get the parser right
• Tasks should segregate well, once the
parser was approaching decent coverage