Despite looking through Aether and CodeCombat’s repository (and associated wikis), I couldn’t find out:
what is meant by transpiling;
what are the interfaces to provide code to Aether ?
Indeed, “[being] able to get the player’s code from the source language into the first step of Aether’s transpilation pipeline” [0] isn’t exactly helpful.
The motivation here is that I would love to be able to use js_of_ocaml, an OCaml to JS compiler (which has been used to run the OCaml REPL in the browser) and enable people to play CodeCombat with OCaml code.
“Transpiling” is trans-compiling: basically compiling, but maintaining the same level of abstraction (like CoffeeScript to JavaScript) rather than going to a more specific level (C to machine language).
For the js_of_ocaml, it looks like it is an OCaml program itself, not something that can be run to live-transpile JavaScript within the browser? It can produce the JS to handle an OCaml REPL, but we would need something that produced the JS just to handle the parser part of it (code -> abstract syntax tree). We’d also need to convert that AST to the Mozilla format so all the rest of the tools can work on it from there, and do something to figure out basic standard library stuff (since the players need to end up using JavaScript’s standard library stuff for compatibility with the other levels).
Ok, transpiling makes sense, now (though compilation is usually understood in the generic sense of “a semantic-preserving transformation”, e.g. with source-to-source compilation).
Thanks
The idea was to compile parts of the OCaml compiler (already known to work) and of js_of_ocaml to JavaScript (using js_of_ocaml itself) in order to get such a pipeline in the browser:
Yes, so that we can match up the original OCaml statements to the transpiled JS that ends up running for things like flow visualization and error messages. If we were just getting JavaScript out of the js_of_ocaml compiler, without range information, then we can’t just parse that JS again to make the AST that Aether needs. Does the js_of_ocaml compiler support source maps?