back to listing index

Announcing BuckleScript 1.0

[web search]
Original source (bloomberg.github.io)
Tags: bucklescript ocaml
Clipped on: 2016-08-31

Announcing BuckleScript 1.0

September 1, 2016 by Hongbo Zhang

BuckleScript is an optimizing compiler which compiles OCaml into JavaScript module by module without name mangling. The generated code is highly readable and super small, see Hello world example and examples of calling JS libraries. BuckleScript is strongly inspired by TypeScript, BabelJS - we consider readability and easy integration with existing JS libraries to be essential.

There are a few things we believe BuckleScript does better compared with TypeScript:

More type safe and more efficient code generated

BuckleScript is not a new language, it is OCaml. OCaml offers an industrial-strength state-of-the-art type system and provides very strong type inference (i.e. unlike TypeScript, no verbose type annotation is required), which proves invaluable in managing large projects.
OCaml’s type system is not just for tooling; it is a sound type system which means it is guaranteed there will be no runtime type errors after type checking. Based on this guarantee, BuckleScript provides many optimizations during offline compilation. You can view a simple benchmark here!

All the benefits of OCaml with a feature rich and efficient FFI

Your program can be compiled into native code, JS and even a unikernel. The BuckleScript compiler is expected to become even faster and produce even faster code owing to more and more optimizations in the upstream OCaml compiler.
Thanks to OCaml’s native support of the Object structural type system, BuckleScript’s FFI(foreign function interface) can model JS objects natively. Some powerful type system features like polymorphic variants and GADTs are also invaluable in modeling existing JS libraries.
Unlike most language FFIs, the design goal of BuckleScript FFI is to avoid writing any unsafe JS "stub" code with a performance cost. In particular, we try to avoid any unnecessary memory allocations in the FFI.

Compilation speed is key to a good developer experience

Our internal benchmarks shows that BuckleScript compiles at least 10x faster than TypeScript. There is no magic here, the BuckleScript compiler is written in OCaml which is compiled to blazing fast native code.
However, it does not limit the availability of BuckleScript compiler: it is also compiled to a JS file (gzipped: 700KB for pure OCaml + 300KB for Reason support).
The playground is powered by the compiler compiled to JS, which demonstrates a nearly real-time compilation speed, imagine how fast the native compiler would be.

We are pleased to announce a stable 1.0 release of BuckleScript, which covers the whole OCaml language (except some features highly coupled with runtime, like the Gc and Unix modules etc.). To learn more about BuckleScript, please refer to the user manual and we welcome your feedback.

Last updated 2016-08-31 14:31:06 EDT