Live data from Hacker News

Announcing BuckleScript 1.0

bloomberg.github.io

51–60 of 78 posts

Re: Announcing BuckleScript 1.0

#51

Earlier quoted context omitted.

I've been meaning to get into ClojureScript. Can you elaborate on why it leaves a bad taste in your mouth?

Well, first off, I don't really like Java or the JVM. That in itself is a pretty strong reason to not get into Clojure. Secondly, I don't really like Clojure as a language: It's strongly opinionated, and made some unorthodox (for a lisp) design choices which I dislike. Finally, Clojurescript is really heavyweight, dragging along not only its own runtime, but also the google closure library and compiler, making the en…

Not an expert, but having dabbled in cljs, I think this misrepresents it. The closure dependency makes things arguably heavier at dev time, but at compile time it allows for a lot of dead code elimination and other optimization that makes the actual output much more light weight. It doesn't slow down development, but allows for a much better product to be deployed.

Re: Announcing BuckleScript 1.0

#52
post #45

I am one of the authors of BuckleScript, you can try BuckleScript in the browser: http://bloomberg.github.io/bucklescript/js-demo/ Click Examples see how the JS code generated, questions are welcome!

Thanks for this! Really awesome stuff! One question here: how tight the compiler is binded to OCaml semantics? Besides Reason, do you think it's possible to build a frontend for other languages and integrate the backend of BuckleScript to generate beautiful JS as well? Or in other words, what property do you think a language should have so we can generate this level of beautiful JS outputs? BTW: Please understand I'm…

OCaml compiler is designed in an extremely modular style. Actually you can design any syntax for OCaml (including lisp style) and produce the OCaml data structure, then it should work with BuckleScript, that's how Reason works

Re: Announcing BuckleScript 1.0

#53
post #35

Earlier quoted context omitted.

we have an intern this summer create bindings for our internal JS stack. we have some internal stuff running on server side in OCaml which we wish to move to client side. I would say many thanks to my boss and employer's great support

BTW, congratulations on the 1.0 milestone! How did you become so proficient with the OCaml compiler internals? When you started the project did you already know that you can compile to idiomatic js or was that discovered through experimentation?

Thanks! I have some experience in ocaml compiler internals, I reimplemented camlp4 called Fan. Yes, I made a prototype in 2 weekends and showed it to my boss and got very good feedback

Re: Announcing BuckleScript 1.0

#54

I am one of the authors of BuckleScript, you can try BuckleScript in the browser: http://bloomberg.github.io/bucklescript/js-demo/ Click Examples see how the JS code generated, questions are welcome!

This is really cool! I took some OCaml code I'd written a while ago and pasted it in and the output was shockingly legible even with the calls to functions in stuff like Caml_int32 and Pervasives. Very impressive!

Re: Announcing BuckleScript 1.0

#56

Earlier quoted context omitted.

yes, we will have this warning when upgraded into OCaml 4.04 Note that optimizing mutual recursive call is a very hard problem it needs VM level support

Mutual tail call optimization requires VM level support in general but can be accomplished within a compiliation unit (module) via inlining.

Seems like it should also be possible to have the compiler employ JavaScript generator functions (i.e. `yield`) and iteration as a substitute for growing the stack, which might be a bit more flexible than rewriting in terms of loops+thunks, though the concept is the same.

Re: Announcing BuckleScript 1.0

#57
post #27

Earlier quoted context omitted.

> Currently it's a syntax on top of OCaml. Does this just mean it compiles to OCaml?

There's a crucial distinction! OCaml's compilation command takes in a `-pp` flag (preprocessor), which accepts a command that takes in a file and outputs an OCaml AST tree. We're basically using that. In that sense, the official OCaml syntax is really just that: another syntax like Reason, but official, and goes back two decades. Because of the clean mapping from one syntax to another, you can toggle between the two…

Interesting. Thanks for explaining that.

Re: Announcing BuckleScript 1.0

#58
OCaml seems to be on an upswing in popularity/hype recently. As someone who's threading the waters in Clojure but not a fan of the JVM developer experience I'm curious why OCaml is a great choice.

I would love to hear some stories from people using it in production. I'm leaning towards wanting to use a LISP as it's just so elegant... but I feel that getting boggled down in "hard core" functional programming is a bit daunting and limiting.

Re: Announcing BuckleScript 1.0

#59
post #31

Earlier quoted context omitted.

Very neat. Can BuckleScript compile Core?

as long as it is vanilla OCaml (no c stubs), it should be fine

Uh, given that you don't respect ocaml's memory model and force -safe-string, that's just not true. Any Obj.magic that is correct in OCaml is probably not going to be correct in bucklescript.

Did you actually tried to compile core ?

Re: Announcing BuckleScript 1.0

#60
post #31

I am one of the authors of BuckleScript, you can try BuckleScript in the browser: http://bloomberg.github.io/bucklescript/js-demo/ Click Examples see how the JS code generated, questions are welcome!

Very neat. Can BuckleScript compile Core?

If you want to use the OCaml ecosystem, use js_of_ocaml. It has much better compatibility and there is no perf difference.

In particular, js_of_ocaml works with both core_kernel and async_kernel.

Post reply on HN