News for hackers. Stuff that matters.
Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by krat0sprakhar on Wednesday April 13, 2016 @09:56AM (#11488146)
For those wondering how this differs from js_of_ocaml - https://github.com/bloomberg/bucklescript/wiki/Difference-fr...

TL;DR

- Debuggable output

- Better interoperability

- Faster compilation

Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by jallmann on Wednesday April 13, 2016 @12:06PM (#11489420)
js_of_ocaml has deep integration with the DOM, event handling, and tyxml (to emit HTML5 in a type-safe manner). It had a fine-grained reactive DOM before Facebook React was even a thing... Bucklescript could add those features, but it'd take a lot of work, and I'm not sure there would be much benefit over what js_of_ocaml offers.

The sweet spot for Bucklescript seems to be in exposing bits of computation-heavy logic through OCaml. The reimplementation of a 55k Immutable.js in 899 bytes of compiled JS makes me go oh-damn-did-you-see-that! On the other hand, js_of_ocaml has rather unparalleled support for building UIs -- which probably makes it a better choice if you want to do your whole web app in OCaml, especially in combination with frameworks like Eliom.

Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by erichocean on Wednesday April 13, 2016 @03:59PM (#11491674)
> The reimplementation of a 55k Immutable.js in 899 bytes of compiled JS makes me go oh-damn-did-you-see-that!

Link?

Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by jallmann on Wednesday April 13, 2016 @04:26PM (#11491884)
Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by afrisch on Thursday April 14, 2016 @05:03AM (#11495187)
I guess Bucklescript aims at a smoother integration with the JS ecosystem, which means binding to existing frameworks rather than creating new ones (such as tyxml or Eliom). These are different approaches which make sense for different target audiences.

That said, it is also quite easy to bind to the JS world with js_of_ocaml and nothing forces you to rely on tyxml or Eliom. You can use either the FFI which comes with js_of_ocaml, or gen_js_api ( https://github.com/LexiFi/gen_js_api ) which we have created to abstract OCaml/JS bindings from the underlying OCaml->JS compilation technology (we hope that Buckescript will support gen_js_api). The web client-side frontend of my company is using exclusively gen_js_api + the js_of_ocaml compiler (but not its FFI nor its standard library), which should make it straightforward to port to Buckescript at some point if the need arise.

Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by seliopou on Wednesday April 13, 2016 @08:24AM (#11487533)
For those interested in compiling OCaml to JavaScript, check out js_of_ocaml[0]. It's been around since 2011 or so, produces source maps, and has a nice FFI. It also works over the output of the bytecode compiler so there's no need to run a fork of the compiler. In my experience it's quite nice to work with.

[0]: http://ocsigen.org/js_of_ocaml/

Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by cwyers on Wednesday April 13, 2016 @09:57AM (#11488155)
This is apparently a fork of js_of_ocaml. I am not sure that I understand what Bloomberg has added/changed to make it this.
Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by krat0sprakhar on Wednesday April 13, 2016 @10:03AM (#11488222)
It's not a fork - it only uses a few parts of the JS pretty printer and runtime support. https://github.com/bloomberg/bucklescript#licensing
Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by elcapitan on Wednesday April 13, 2016 @11:44AM (#11489166)
Their example is a bit of an odd choice, as it shows an imperative Ocaml function resolving 1:1 into javascript, would be nice to see a small example with some functional programming and how that translates.
Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by steego on Wednesday April 13, 2016 @02:42PM (#11491002)
Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by erichocean on Wednesday April 13, 2016 @03:55PM (#11491638)
Can BuckleScript translate (some?) Coq output to JavaScript? If so, what are the limitations?

UPDATE: Looks like the answer is (usually) "no"—Ocaml code generated by Coq frequently uses Obj.magic, which BuckleScript does not support. sigh

Re:Bloomberg/bucklescript: A back end for the OCaml compiler... by jeffsco on Monday April 18, 2016 @01:10AM (#11517825)
What happens if you declare an external function of type 'a -> 'b? Obj.magic is trivial to implement, it's just the typing that is wonky. (Disclaimer: I have never looked at BuckleScript or js_of_ocaml.)