Slide 1

Slide 1 text

What is ReasonML? Munich, 2018-02-01

Slide 2

Slide 2 text

ReasonML • A new programming language by Facebook. • Supports several styles: • Functional programming • Imperative programming • Object-oriented programming In a nutshell: different syntax for OCaml

Slide 3

Slide 3 text

OCaml syntax (.ml, .mli) ReasonML syntax (.re, .rei) OCaml AST Bytecode Native code JavaScript BuckleScript ocamlopt ocamlc ReasonML inside the OCaml ecosystem

Slide 4

Slide 4 text

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)

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Dr. Axel Rauschmayer, @rauschma Focus of ReasonML • Tooling (IDE support etc.) • Interoperability with JavaScript • React (built-in syntax etc.) • Better standard library 6

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Dr. Axel Rauschmayer, @rauschma ReasonReact • Batteries included: • Router • Redux • Typed support for GraphQL via graphql_ppx 8

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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