About BuckleScript

BuckleScript is an optimizing compiler which compiles OCaml to readable JS. It is open sourced by Bloomberg since 2016.

BuckleScript is also the official JS bakcend for Facebook ReasonML, it has first class support for both vanilla OCaml and Reason syntax. It is also used by companies like Facebook in https://messenger.com and Google in cross-compiling WebAssembly interpreter into JS.

BuckleScript compiles one OCaml module into one JS module without name mangling, users can try it in the playground, the manual is available.

BuckleScript is focused on JS developer experience and NPM ecosystem, it is supported on all major platforms including Windows, Linux and Mac, users can install it in one line npm i -g bs-platform, it comes with its dedicated blazing fast build system working on all platforms.

BuckleScript Community

Incomplete online resources

3 Likes

I’m sure this is a faq, but I haven’t found an answer yet:

Does Reason work with the OCaml bytecode and native code compilers, or with js_of_ocaml? Since it’s just an alternative syntax, it should be possible to use it with any compiler, at least eventually, right? I only see Reason mentioned as an alternative syntax with Bucklescript, though.

You can already use Reason with all your existing tools. The only catch is you have to use refmt (a tool Reason provides) to convert your Reason files to OCaml files. Recently jbuilder and bsb started supporting Reason out of the box so you don’t even have to run refmt.

This post https://spyder.wordpress.com/2017/05/14/ocaml-to-javascript-buzzwords/ provides in depth explanation of how everything fits together.

4 Likes

Thanks vramana. That’s very helpful.

That’s a great blog post. I hadn’t seen it.

1 Like

I fully understand the argument.

But from what I see of Js_of_OCaml, a lot of efforts have been implemented to be “more pleasant to use” including for a JavaScript developer with a background in OCaml. (SourceMap for example).

In the long term, is not the presence of this alternative likely to be a little detrimental?

I am really tired of comparing it to js_of_ocaml. That’s why I made the
comparison very high level. You can always try it by yourself and pick the
one you like most !

Really sorry if my message was interpreted as a negative criticism, it was not at all the purpose of my message.

Detrimental for whom? I can’t see it being detrimental to either projects because they have different target audience. BuckleScript targets JavaScript developers and gives them fast and type safe language. Jsoo on the other hand targets developers with OCaml background and let them write web applications. So they can co-exist and complement each other.

May be your argument was it’s detrimental for the community since there are two competing solutions which will divide the community. I don’t percieve it that way, I feel that opposite in fact. Both Bucklescript & Reason paves a way for more people (mainly JS developers) to try out and discover OCaml in an approachable way and increase the exisiting OCaml community.

Hi, it is not your issue, just I am really tired of such questions. Since day one we announced bucklescript, almost all responses we got from some OCaml programmers is “How is it different from js_of_ocaml” or “Why not contribute to jsoo directly”

In case you are curious, I shared my ideas with jsoo developers before I started my project: https://github.com/ocsigen/js_of_ocaml/issues/338

I am a fan of js_of_ocaml, and I believe both are great tools, there is a place for both tools, I think the difference is quite obvious, pick the one you like or actually you can use both in the same time.

2 Likes

I do not speak very well English (I get helped by Google translate), so maybe my statement is a little too strong.

2 Likes

For the bucklescript-tea project I’ve been writing a set of blog posts to show the basics of how to use it: https://blog.overminddl1.com/tags/overbots/

Or see the main Bucklescript tag for everything Bucklescript related on my blog: https://blog.overminddl1.com/tags/bucklescript/
Or for everything Bucklescript-TEA specific: https``://blog.overminddl1.com/tags/bucklescript-tea/

1 Like

Just an old topic, but I do agree it should be in a FAQ somewhere for reference and easy linking.

And apparently my post I just made vanished, so instead of editing this in, new post… Something seems a bit borked here…

Copy/Pasting it in here:

For the bucklescript-tea project (linked in the primary post) I’ve been writing a set of blog posts to show the basics of how to use it: Posts about overbots | Hyperglot Programmer

Or see the main Bucklescript tag for everything Bucklescript related on my blog: Posts about bucklescript | Hyperglot Programmer
Or for everything Bucklescript-TEA specific: Posts about bucklescript-tea | Hyperglot Programmer

I’m writing a chess-themed tutorial on creating an SPA with Bucklescript-TEA. So far, 8 out of 12 parts are online, and I will post the remaining parts in the next few days (and probably refine what I wrote so far).

Here’s the code: https://github.com/quernd/tea-chess
Here’s the writeup: https://quernd.github.io/tutorials/tea-chess/

4 Likes

the Bucklescript category has been replaced by a tag instead and this post is linked to from the central FAQ.

Would you like to edit the original post here to direct users to the bucklescript tag? Alternatively, we can also turn this topic into a wiki page that makes it editable by other users to make it easier to maintain the list of resources above.