Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What is ReasonML?

What is ReasonML?

Axel Rauschmayer

February 01, 2018
Tweet

More Decks by Axel Rauschmayer

Other Decks in Programming

Transcript

  1. ReasonML • A new programming language by Facebook. • Supports

    several styles: • Functional programming • Imperative programming • Object-oriented programming In a nutshell: different syntax for OCaml
  2. OCaml syntax (.ml, .mli) ReasonML syntax (.re, .rei) OCaml AST

    Bytecode Native code JavaScript BuckleScript ocamlopt ocamlc ReasonML inside the OCaml ecosystem
  3. type tree = Leaf | Node(int, tree, tree); let rec

    sum = (x) => switch (x) { | Leaf => 0 | Node(value, left, right) => value + sum(left) + sum(right); }; let myTree = Node( 1, Node(2, Node(4, Leaf, Leaf), Node(6, Leaf, Leaf)), Node(3, Node(5, Leaf, Leaf), Node(7, Leaf, Leaf)) ); sum(myTree) |> print_int; • Syntax: JS • Style: FP • No type annotations
 (x, myTree)
  4. Dr. Axel Rauschmayer, @rauschma Foundation: OCaml • Proven in the

    real world • Created in 1996 at INRIA (France) • Used at Facebook, Bloomberg, Jane Street, etc. • An object-functional language. • Supports mutable state (as an “escape hatch”). • Compiles to bytecode, native code, good-looking JavaScript • Building JavaScript is fast 5
  5. Dr. Axel Rauschmayer, @rauschma Focus of ReasonML • Tooling (IDE

    support etc.) • Interoperability with JavaScript • React (built-in syntax etc.) • Better standard library 6
  6. Dr. Axel Rauschmayer, @rauschma Future Current weaknesses: • Better support

    for JS Promises • Better standard library (currently not always cross-platform) • Better support for Unicode (currently not cross-platform) • Better support for overloading (ad-hoc polymorphism) • No more + vs. +. • Similar to Haskell’s type classes • Truly native React Native • Long term: multicore 7
  7. Dr. Axel Rauschmayer, @rauschma ReasonReact • Batteries included: • Router

    • Redux • Typed support for GraphQL via graphql_ppx 8
  8. Dr. Axel Rauschmayer, @rauschma Tips for getting started • Try

    out quickly: • Interactive command line (offline): rtop • Online playground • Write sync Node.js-based shell scripts • Generate template projects. E.g.:
 bsb -init my-first-app -theme basic-reason • Visual Studio Code 9
  9. Dr. Axel Rauschmayer, @rauschma Documentation • Online docs. Well-written! •

    Material on OCaml • Convert OCaml ↔ ReasonML: refmt, playground • 2ality.com/2017/11/about-reasonml.html 10