3 ms·
Yes. OCaml + all of the 3 OCaml-to-JS compilers support OCaml syntax. Dream itself demonstrates: - Server and client both written in Reason, using ocamlc+Mela
by antron-prime 5y ago
Yes. OCaml + all of the 3 OCaml-to-JS compilers support OCaml syntax.
Dream itself demonstrates:
- Server and client both written in Reason, using ocamlc+Melange https://github.com/aantron/dream/tree/master/example/r-fullstack-melange#readme https://github.com/aantron/dream/tree/master/example/r-fulls...
That example could also have been written in OCaml syntax, because ocamlc (native) and Melange (JS) both support OCaml. However, Reason is nicer if you want to use React with JSX on the client.
- Server and client both written in OCaml, using ocamlc+Js_of_ocaml https://github.com/aantron/dream/tree/master/example/w-fullstack-jsoo#readme https://github.com/aantron/dream/tree/master/example/w-fulls...
- The remaining example uses Ocaml on the server and ReScript on the client, using the ReScript compiler. However, you could use OCaml on the client with the ReScript compiler. Just as with Melange, you would lose access to nice JSX syntax https://github.com/aantron/dream/tree/master/example/w-fullstack-rescript#readme https://github.com/aantron/dream/tree/master/example/w-fulls...
It's definitely a lot and not user-friendly to have to decide between all these options, but the community is experimenting greatly right now... so it's good and bad, and that's how it is :/
As for Node.js, using ReScript syntax requires you to use Node.js on the server side, but that is the only coupling. If you write your server side in OCaml or Reason, you can compile it to native code with ocamlc (technically, ocamlopt is the internal command; nobody uses either one directly, but the build system calls them).
EDIT to clarify the last paragraph: the only coupling is that ReScript compiles only to JS. Everything else compiles to both JS and native and by multiple compilers...