ocsigen / js_of_ocaml

Compiler from OCaml to Javascript.
http://ocsigen.org/js_of_ocaml/
Other
951 stars 185 forks source link

[FEATURE REQUEST] JS-agnostic intermediate representation #1075

Open Lupus opened 3 years ago

Lupus commented 3 years ago

js_of_ocaml is a really cool compiler! I'm fascinated with that it can do. Yet it targets only one language - JavaScript, while it's certainly feasible to target more languages with bytecode approach, rehp has Php backend working along with JS, and there is Go backend in a separate project.

The bytecode parsing machinery up to generate.ml is in general agnostic to target language. What Rehp does is adding intermediate representation layer for program tree, that is also agnostic to target language. Having that alone in js_of_ocaml can enable one to use it as a library to produce the IR, and take it from there to target whatever language desired.

Bytecode based approach is considered the best, and js_of_ocaml can become a solid foundation for various compilers going this route.

/cc @jordwalke

hhugo commented 3 years ago

Contributions are welcome