Bloomberg Open-sources BuckleScript, JavaScript Backend for OCaml

| by Sergio De Simone Follow 12 Followers on Mar 22, 2016. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Recently open-sourced BuckleScript, a JavaScript backend for OCaml, aims to bring OCaml type safe, high performance code to any JavaScript execution engine, Bloomberg say.

BuckleScript, originally released under the name of OcamlScript then renamed to avoid confusion with another project, has been developed at Bloomberg Labs and aims to enable large scale JavaScript programming. According to Bloomberg, this is made possible by combining OCaml’s industrial strength type system with a fast compiler and offline, i.e., compile time optimizer.

BuckleScript was inspired by js_of_ocaml, according to its main authors, but it has different goals. In particular, BuckleScript is designed to help easier integration with existing JavaScript system, which means that it is possible to call a function defined in an BuckleScript from a plain JavaScript module. This is made possible by the fact that each BuckleScript module is translated into an ES6 module, a concept known as separate compilation that is also available in TypeScript, and that no name mangling is used, which also makes it possible to generate debuggable JavaScript.

As an example of that, the following OCaml code:

let sum n =
    let v  = ref 0 in
    for i = 0 to n do
       v := !v + i

is translated into:

function sum(n) {
  var v = 0;
  for(var i = 0; i<= n; ++i){
    v += i;
  return v;

BuckleScript can in certain cases outperforn carefully implemented JavaScript libraries, Bloomberg’s engineers say. In particular, a BuckleScript implementation of Facebook’s immutable library shows a twofold performance improvement and a drastic reduction in code size.

Still in its early stages, BuckleScript is available both for Linux and Mac OS X, while Windows support is in the workings. Its source code is available on GitHub. It can be also tried out through its web-based REPL.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you