About BuckleScript

bucklescript
faq

#1

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


Which categories to create in the site
(WIP) Frequently Asked Questions
#2

#3

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.


#4

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.


#5

Thanks vramana. That’s very helpful.

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


#6

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?


#7

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 !


#8

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


#9

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.


#10

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.


#11

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


#12

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/


#13

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: 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/


#14

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/


#15

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.