News for hackers. Stuff that matters.
Re:Compile OCaml to JavaScript, Run on Node by junke on Thursday December 03, 2015 @03:04PM (#10672190)
The static types protect you from undesired runtime behaviors with respect to OCaml's runtime semantics, but what about Javascript's one?

This is better than nothing, sure, because your code is first checked in OCaml but once the code is running, it does it according to Javascript rules.

I imagine there could be subtle bugs introduced during this process (e.g. your OCaml code manipulate integers, but Javascript has numbers, a.k.a. double floats, as far as I know).

Re:Compile OCaml to JavaScript, Run on Node by Drup on Thursday December 03, 2015 @03:24PM (#10672319)
This is no different than trusting the processor for running the emmited assembly according to the model you have for what assembly is supposed to do.

Here, the compiler emits (a subset of) javascript which are assumed to have a semantics, and we trust the browser engine to execute it according to the semantic.

Of course we don't assume the semantic of javascript to be sane, we just assume it follows the spec (and we emit accordingly).

Re:Compile OCaml to JavaScript, Run on Node by rlander on Thursday December 03, 2015 @03:48PM (#10672508)
I see your point, but that's like arguing compiled Haskell code is unsafe, since Haskell has type erasure.

Any code generation machinery is subject to subtle bugs and especially so the flesh and bones kind ;)

Re:Compile OCaml to JavaScript, Run on Node by e_d_g_a_r on Thursday December 03, 2015 @04:00PM (#10672603)
I haven't had a single problem at all and I've wrapped even the most sensitive stuff like the event emitter itself and streams.