3 ms·
Compile OCaml to JavaScript, use ReactJS, bindings to ReactJS, several examples
- e_d_g_a_r 10y agoopam version is a little bit behind curve, use `opam pin add -y reactjs git@github.com:fxfactorial/ocaml-reactjs.git`
- magnumkarter 10y agoI've been learning OCaml and hoped I could find something like this. Thank you.
- e_d_g_a_r 10y agoThanks! Star it if you like it, use it and open issues if any arise.
- btown 10y agoFor those interested in this, https://github.com/bloomberg/bucklescript https://github.com/bloomberg/bucklescript is an alternate (albeit new) OCaml to JS compiler. There's already talk about supporting JSX syntax: https://github.com/bloomberg/bucklescript/issues/162 https://github.com/bloomberg/bucklescript/issues/162
- Scarbutt 10y agoDifferences from js_of_ocaml (not an easy find) Js_of_ocaml takes lowlevel bytecode from OCaml compiler, BuckleScript takes the highlevel rawlambda representation from OCaml compiler Js_of_ocaml focuses more on existing OCaml eco-system(opam) while BuckleScript's major goal is to target npm 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. Both projects are improving quickly, so this can change in the future!
- rajington 10y agoI haven't really gotten into much ML yet, and I'm curious to hear what people knowledgeable with OCaml think about http://facebook.github.io/reason/ http://facebook.github.io/reason/ The name makes it impossible to research to find any blog posts or anything, but the familiar syntax alone might make it at least a first step for me.
- e_d_g_a_r 10y agoSpeaking for myself, I think Reason is a very good thing and rewriting this in Reason or adding a Reason layer is a goal/TODO.
- rajington 10y agoThat's awesome and great work. I know it's dumb that the thing holding me back from OCaml is the syntax, but after giving up on an Om project I've come to accept js will always be the greatest common denominator.
- bsimpson 10y agoAs I recall, Reason is the current project of React originator Jordan Walke and React contributor Cheng Lou. I wouldn't be at all surprised to see a Facebook project emerge that allows you to author React apps in Reason with Bucklescript.
- LeonidasXIV 10y ago
- jordwalke 10y agoSander sent a [Pull Request](https://github.com/facebook/reason/pull/647 https://github.com/facebook/reason/pull/647) to [Reason](http://facebook.github.io/reason/ http://facebook.github.io/reason/) which adds JSX syntax (which many React developers have found helpful) Reason doesn't yet work with Edgar(OP)'s React bindings yet, but it could easily (and therefore JSX would work as well).
- deleted 10y ago[deleted]
- ilostmykeys 10y agoWhy?
- klibertp 10y agoA sane, powerful type system is actually enough of a rationale and a selling point, at least for me. Also, allowing side-effects while still providing the mentioned type system makes it potentially much easier to integrate with existing JS code.
- cies 10y agoAnother reason for it being "much easier to integrate with existing JS code" is strict evaluation. Haskell is lazy, which means using GHCJS to compile it to JS produces code full of explicit thunks (think of promises). Both Elm and PureScript are compile-to-JS-languages that inherit a lot from Haskell, but not it's laziness.
- jackmott 10y agoYou should give one of the OCaml languages a try. OCaml or F#. They have some very pleasant properties. Generally this whole idea would make sense when you are writing a web application and you are using OCaml or F# on the server and want to use it for the client code too. Same justification for using node.js, but in reverse. But I know that the Ionide plugin for Atom and VSCode is written in F# compiled to javascript just because the developers like to code in F#
- ilostmykeys 10y agoI got downloaded for asking Why. Seriously sad.
- xamlhacker 10y agoIn the same vein, there are also some F# to JS compiler projects such as Funscript (http://funscript.info/ http://funscript.info/) and Fable (https://github.com/fsprojects/Fable https://github.com/fsprojects/Fable). F# is an open-source Ocaml inspired language for .net.
- piaste 10y agoAlso plugging Websharper (http://websharper.com/ http://websharper.com/) which is a full web framework that includes a F# to JS compiler to write the client-side part of the code. Though you can use just the compiler inside a regular ASP.NET MVC project, if you so choose.
- hongboz 10y agoFYI: you can try bucklescript compiler in browser, and see generated JS code side by side instantly https://bloomberg.github.io/bucklescript/js-demo/ https://bloomberg.github.io/bucklescript/js-demo/
- amelius 10y agoHow is the performance? Imho, we need an equivalent of the "great programming language shootout" for all the AltJS languages.
- hongboz 10y agoFor bucklescript, the performance is excellent, better than handwritten JS: https://github.com/bloomberg/bucklescript#more-examples-1 https://github.com/bloomberg/bucklescript#more-examples-1
- galfarragem 10y agoIsn't this a less polished version of Elm?
- e_d_g_a_r 10y agoThis has nothing to do with elm..
- jiyinyiyong 10y agoClojureScript is better than that, except for the type system.
- sgrove 10y agoIt's probably worth elaborating your opinion here. I've used ClojureScript heavily and feel I have a good sense of the comparison, but someone else reading your comment wouldn't be any better informed for it. I'm genuinely curious as to your comparison though, would love to read it!
- e_d_g_a_r 10y agoSean just made this awesome much more real world usage example of a TODO MVC : https://www.dropbox.com/s/um29z2793ta7s9l/todomvc_state_replay.mp4?dl=0 https://www.dropbox.com/s/um29z2793ta7s9l/todomvc_state_repl...