- running a single page app in a browser (using react.js/jquery or just vanilla js).
- running on top of node.js
- running on top of react.native on a mobile phone
- exploring Perl 6 in your browser (having a awesome REPL, being able to execute snippets etc.)
# save this as hello-world.nqp use QAST::Compiler; my $sc := nqp::createsc('TEST_SC'); nqp::scsetdesc($sc, "description"); my $qast := QAST::Block.new( :blocktype('immediate'), QAST::Op.new( :op('say'), QAST::Op.new( :op('concat'), QAST::SVal.new(:value("Hello ")), QAST::SVal.new(:value("World")) ) ) ); my $compunit := QAST::CompUnit.new( :sc($sc), :code_ref_blocks(nqp::list()), $qast ); my $compiler := QAST::CompilerJS.new(); say($compiler.emit($compunit));
Run it like
make js-all make js-bootstrap ./nqp-js hello-world.nqp | node
Today I have unbitrotted the existing code at https://github.com/pmurias/rakudo-js by handling QAST::Var's with decl set to "static" (variables that don't change at runtime) the same as ones with "var" (normal ones). As such I have completed the first of 15 inchstones ;)