scribble

Meta9

Home About Blog Gallery Tech

17 Apr 2016
Bucklescript -- great language for great platform

As we know, Javascript platform is everywhere, and its performance is good to deliver most applications, the no installation process makes it the best channel to deliver your programs. Javascript is currently the best platform.

However, Javascript is not designed for large scale programming on Day One, it was rushed in 10 Days, as people started to grow its Javascript applications, transpliers are in high demand, and indeed there are tons of them,
so how bucklescript is unique here?

Unlike most transpilers, bucklescript has several advantages:

  1. It’s OCaml with excellent FFI support.

    OCaml has a ML like type system, advanced module system.

    Unlike Haskell, two features really make

    1. structural typing and row polymorphism: the best part to model JS FFI

      OCaml’s built-in support of structual typing and row polymorphism makes writing type description file in OCaml for JS much easier

    2. straigtforward imperative programming

      OCaml is a practical language, it is not opinionated, it encourages people do functional programmming in general, but when people really need do some mutations, it does not get in your way, you don’t need struggle with the type system.

      Array and Hashtbl are first class data structures in OCaml

  2. Compiles just so fast, no longer waiting for compilation!

    The original OCaml compiler is already among one of the fastest compilers, instead of emitting asm code or byte code, we emit JS directly which also saves the time for linking, since the generated JS code is just plain commonJS code.

    With the forthcoming flambda optimization, bucklescript will simply benefit from all optimizations on the asm backend.

    You can play with the playground: bucklescript compiler in Js backend, even the JS backend is pretty fast.

  3. OCaml Module To JS Module: file local transformations, clean, readable Javascript Output.

  4. Brings more backend to OCaml language: from Javascript platforms, iOS/Android native backend to unikernel


scribble

Home About Blog Gallery Tech