Using the Compiler
The Raven compiler is distributed as a Julia package, so you'll need to run it from inside a Julia REPL. (The workflow is currently geared towards language developers, rather than users.)
The following is a valid Raven script, in its entirety:
println("Hello, World!")
Like Ruby, Python and other scripting languages, there's no need for a main
function. Code at the top level (outside of a function) will just run.
Here's how we ran our "hello, world" program.
julia> using Raven
julia> Raven.exec("hello.rv")
Hello, World!
This runs our code immediately, as if using an interpreter. But Raven.exec
actually involves two separate steps: (1) compiling the code to WebAssembly, and (2) running the compiled code using Node.js. Here's how we can break those steps down.
julia> Raven.compile("hello.rv");
shell> node hello.js
Hello, World!
After running Raven.compile
, you'll notice that two extra files have been created, hello.wasm
and hello.js
. The Raven code itself has been compiled into WebAssembly, contained in hello.wasm
. hello.js
is just a support script that tells Node.js how to run hello.wasm
.
Although we used it to compile our code, the Julia compiler/runtime isn't involved at all when executing Raven. We can equally run our compiled code from the shell.
$ node test.js
Hello, World!