It there a tutorial for `js_of_ocaml` with simple graphics?

I have a simple application that uses the Graphics module to show some results (and that will be extended with simple interactions), and I would like to make it available as a web page. It seems that js_of_ocaml is the tool to use for that, but I could not find a tutorial showing how to do it. Is there one available that covers the ml part, the js part, and the html part?

3 Likes

Are none of the examples in the js_of_ocaml repo helpful?

Are none of the examples in the js_of_ocaml repo helpful?

Personally, I found those examples quite helpful, but an example is not a tutorial.

@brab I also been teaching myself how to use js_of_ocaml and have managed to put the basics together. I’m sure my current practice is not ideal, since I’m just figuring things out myself, but hopefully these resources might be some assistance to others in a similar boat.

For the basic project setup, so far I’ve found the first example in incr_dom to be the clearest minimal example. If you’re not interested in using incr_dom, you can just ignore all the parts pertaining to it. Just look at the dune file, the index.html (for how to reference the main.js) and the main.ml file. You can replace the code in main.ml with your code for a start.

For use of the Js_of_ocaml library itself, I haven’t found anything better than code examples and the API Docs.

I’ve been taking some notes as I set up a fullstack OCaml project, with a mind to refining them into a tutorial if the project goes well. The notes are very rough, but you might still find it useful nd_project/front-end-ocaml-intro.org at master · shonfeder/nd_project · GitHub.

3 Likes

Thanks a lot, this is most helpful.

Best,

Alan

1 Like

Glad to hear it. If you take some additional/related/similar notes and want to combine material into a more polished tutorial for beginners, let me know. I’d be happy to pool such resources.

1 Like

I recently started to write metaphorm but it’s not yet ready, but may be helpful here.

This is a really, really late reply but this youtube video was very helpful to me …

3 Likes