News for hackers. Stuff that matters.

hongboz

Re:From first principles: Why I bet on Scala.js on Wednesday August 10, 2016 @01:54PM (#12263599)
For people who want to do typed functional programming on JS platform, there is another candidate: BuckleScript for OCaml: https://bloomberg.github.io/bucklescript/js-demo/

The compiler is compiled into JS and native code.

It generates highly readable JS code and easier FFI.

It compiles super fast (generally 10~100 faster than Scala) and generates optimized code.

For bucklescript, the performance is excellent, better than handwritten JS: https://github.com/bloomberg/bucklescript#more-examples-1
FYI: you can try bucklescript compiler in browser, and see generated JS code side by side instantly https://bloomberg.github.io/bucklescript/js-demo/
Re:OCaml in Operations on Tuesday April 12, 2016 @09:12AM (#11479209)
Re:OCamlScript – a JavaScript back end for OCaml on Friday January 08, 2016 @01:48PM (#10867187)
List.fold_left is compiled into a while loop in ocamlscript. The main reason that I used for loop is that the generated code is the same as hand written js, so the comparison is more reasonable

Edit: I am a practical programmer, I am in favor of both for loop and recursion as long as it is readable

Re:OCamlScript – a JavaScript back end for OCaml on Friday January 08, 2016 @11:39AM (#10866113)
Hi, thanks for your interest in it.

This project has been released to exchange some ideas and collect feedback from the OCaml and JavaScript communities. It is still in an very early stage and more like research projects though we already had some good results.

Note that ocamlscript is inspired from typescript and js_of_ocaml, we like the readability of typescript generated js code, while don't want to loose the expressivity of a powerful langauge, ocaml, here in particular.

The main difference from js_of_ocaml is that js_of_ocaml maps the whole bytecode program into a js file while ocamlscript maps an ocaml module to es6 module.

Indeed, there is some difference in the runtime representation between js_of_ocaml and ocaml, for example, ocamlscript uses js string and array for ocaml string and arrray(we do this since we want an optimal js output at the price of a bit runtime incompability), this may make interaction between js_of_ocaml and ocaml a bit harder, but that's exactly why we made an early release to hear what other people may think. js_of_ocaml is an excellent project and we learned a lot from it and will seek some collaborations to share some workload.

Re:OCamlScript – a JavaScript back end for OCaml on Friday January 08, 2016 @10:48AM (#10865661)
self tail call is supported. mutual recursive tailcall can be done partially, but there is not a strong guarantee
Re:OCamlScript – a JavaScript back end for OCaml on Thursday January 07, 2016 @08:21PM (#10862249)
actually we have great relationship with Lexifi, and we did exchange some ideas about ocamlscript before, I think mostly we are on the same page, there is enough room for two compilers :-)
Re:OCamlScript – a JavaScript back end for OCaml on Thursday January 07, 2016 @06:58PM (#10861834)
Author here, just created a new account : ). I think ocamlscript is complementary to js_of_ocaml, actually it is inspired from js_of_ocaml. For those who like to write ocaml only application, js_of_ocaml is perfect, ocamlscript is designed to help easier integration with existing javascript system.

Design goals here: http://bloomberg.github.io/ocamlscript/