It’s nice to get some js code from reasonml or OCaml.
But as I have no specific interest in js and because I have no legacy js code at all, I don’t see the interest in reasonML over using OCaml and targeting js thanks to js_of_ocaml.
In BS documentation Comparison to Js_of_ocaml, I can read that there are three main differences between js_of_ocaml and BS which appear not to be decisive for using BS over js_of_ocaml:
- js_of_ocaml takes low-level bytecode from OCaml compiler, BuckleScript takes the high-level rawlambda representation from OCaml compiler.
- js_of_ocaml focuses more on existing OCaml ecosystem (OPAM) while BuckleScript’s major goal is to target NPM/Yarn and existing JS workflows.
- js_of_ocaml and BuckleScript have slightly different runtime encoding in several places. For example, BuckleScript encodes OCaml Array as JS Array while js_of_ocaml requires its index 0 to be of value 0.
Indeed my main concern is to create the GUI (web pages with some forms, a menu, etc. with interactive features, server side or client side). How do you “use js to interact with browser”?
I’m currently reading the Elm documentation. I don’t see yet a clear difference between Elm Model/Update/View pattern and MVC pattern (Model/View/Controler). Is there any?
view : Model -> Html Msg
The signature is clear.
view is a place holder for the UI controls (buttons, text fields, etc.).
Let’s consider that my business objects are clearly defined. It looks like my issue with creating a web interface is mainly about mixing up some html tagged elements that will hold the business objects and their related controls ; css will define the layout. For a simple web page/site, that’s quite fine to create them by hand., even if I’m not used to.
But when the website size is increasing, is there a simple way to create the html skeleton from a web page definition that specifies the layout (how business objetcs are tagged so that css can handle them). Webdevelopers should have an efficient way for doing that.
I had a look at opium. It seems to be mainly dedicated to the business logic and to middleware.
I found quite nothing about creating web UI. In hello_world_html.ml, I just found how some html can be inserted.
I had to fix the two examples to make them work. It was enough to replace
opium (in the ocamlbuild command or in the dune file).
Maybe @rgrinberg can give us more explanation about how to make a web UI (a View) with opium?