SlideShare a Scribd company logo
ReasonML & Bucklescript, or how to do a functional NodeJS app
NodeJS The edge of Reason
What I do
Thomas Haessle
@Oteku
cutii.io
is amazing
Tooling
Fast (web point of view)
is a mess
fit functional
Object literals
Spread operators
Arrays map / reduce / filter
Functions as first class citizen
Currying
Closures
Arrow functions
…
JSX (composition)
React stateless components (composants fonctionnels)
React PropTypes (Typage sur propriétés des composants)
…
Redux pattern
…
RxJS
is unfunctional
Code Easy to Reason About :
- does not affect or mutate external state
- does not rely on external state
- always return the same corresponding output for a given input
- have up to date documentation
Give me a Reason(ML)
Reason lets you write simple, fast and quality type safe
code while leveraging both the JavaScript & OCaml ecosystems.
How a 21 years old language may Reasonably
help me ?
How a 21 years old language may Reasonably
help me ?
How a 21 years old language may Reasonably
help me ?
… and some love Reasons
(be patient)
« Déjà vu »
is designed for JS dev
const greeting = "Bonjour";
const greetList = [];
greetList.push(greeting); /*references are
immutables, not values !*/
const gList = ['Hello', 'Hallo'];
const greetings = [greeting, ...gList];
let who = "FP Lille#7";
who = "LilleFP#6";
function internationalGreet(gWords, name) {
return gWords.map(current => current + " " + name);
}
console.log(...internationalGreet(greetings, who));
dummy.js
let greeting = "Bonjour"; /* inference */
/* List type is immutable */
let greetList = [];
let prepended = [greeting, ...greetList];
let appended = greetList @ [greeting];
let greetArray = [||]; /* Array type is mutable */
greetArray.(0) = greeting;
let gList: list string = ["Hello", "Hallo"]; /* type may be
explicit */
let greetings = [greeting, ...gList]; /* (ノ^ヮ^)ノ*:・゚✧ spread
operator */
let who = ref "FP Lille#7"; /* explicit mutability */
who := "LilleFP#6";
let internationalGreet gWords name => gWords |> List.map (fun
current => current ^ " " ^ name);
internationalGreet greetings !who |> List.iter (fun current =>
Js.log current);
dummy.re
is designed for JS dev
let greeting = "Bonjour"; /* inference */
/* List type is immutable */
let greetList = [];
let prepended = [greeting, ...greetList];
let appended = greetList @ [greeting];
let greetArray = [||]; /* Array type is mutable */
greetArray.(0) = greeting;
let gList: list string = ["Hello", "Hallo"]; /* type may be
explicit */
let greetings = [greeting, ...gList]; /* (ノ^ヮ^)ノ*:・゚✧ spread
operator */
let who = ref "FP Lille#7"; /* explicit mutability */
who := "LilleFP#6";
let internationalGreet gWords name => gWords |> List.map (fun
current => current ^ " " ^ name);
internationalGreet greetings !who |> List.iter (fun current =>
Js.log current);
dummy.re
let greeting = "Bonjour"
let greetList = []
let prepended = greeting :: greetList
let appended = greetList @ [greeting]
let greetArray = [||]
let _ = greetArray.(0) <- greeting
let gList: string list = ["Hello"; "Hallo"]
let greetings = greeting :: gList
let who = ref "FP Lille#7"
let _ = who := "LilleFP#6"
let internationalGreet gWords name =
gWords |> (List.map (fun current -> current ^ (" " ^ name)))
let _ =
(internationalGreet greetings (!who)) |>
(List.iter (fun current -> Js.log current))
dummy.ml
NodeJS The edge of Reason - Lille fp#6
https://youtu.be/_0T5OSSzxms
Cheng Lou - Taming the Meta 
add1.re
add1.rei
demo.re
human readable output
dead code elimination 

(similaire prepack.io)
code optimizations
amazingly fast
safer JS runtime execution
( param = 2 + undefined 

… mais param = 2 + « 3 » )
demo.js
add1.js
bsb --make-world
||
• Compile high-level rawlambda  to js
• Focuses more on npm
• Readable js output
• Compile low-level bytecode to js
• Focuses more on opam
• Uglify js output
• Amazingly fast
• Improving quickly
• Stimulate each other
• License LGPL
Types System
Types System Inference
Types System Inference
https://github.com/reasonml/reason-tools
page.re
root.re
root.js
page.js
type action =
| Click
| Toggle;
type state = {count: int, show: bool};
let component = ReasonReact.reducerComponent "MyDialog";
let make _children => {
...component,
initialState: fun () => {count: 0, show: false},
reducer: fun action state =>
switch action {
| Click => ReasonReact.Update {...state, count: state.count + 1}
| Toggle => ReasonReact.Update {...state, show: not state.show}
},
render: fun self => {
let message = "Clicked " ^ string_of_int self.state.count ^ " times(s)";
<div>
<MyDialog
onClick=(self.reduce (fun _event => Click))
onSubmit=(self.reduce (fun _event => Toggle)) />
(ReasonReact.stringToElement message)
</div>
}
};
Reducer component
will (would) be amazing
Tooling
ality
CONS :
Still young
Little community (but growing)

A functional language learning curve for JS devs
No native packages management (hot topic)

Poor documentation
Bucklescript targets ES5 while node.js is ES8 VS babel-preset-env
Breaking change version is coming next month
PROS :
Battle tested type system with inference : OCaml under the hood

Kind community
Really good samples
Production ready (used for messenger.com)

Reason-react with reducer components

First Reason React Native app published in stores last month (https://github.com/FormidableLabs/seattlejsconf-app)

Facebook baked
May be adopt baby-step (one node module, one react component, …)
ason to be confident
Why ? Reason’s design fit our problems
Do we have a great community ? Almost … we have a discord
Yes and great toolingDo we have a great language ?
NodeJS The edge of Reason - Lille fp#6
ad More
ReTwit
@reasonml
@jordwalke (react & reason creator)
@_chenglou (react team / reason evangelist)
@sgrove (reason evangelist)
@bobzhang1988 (bucklescript creator)
@ken_wheeler (Director of Open Source @FormidableLabs)
ReSpond

https://discordapp.com/invite/reasonml
https://www.reddit.com/r/reasonml/
ReSources
https://reasonml.github.io/
https://github.com/vramana/awesome-reasonml
https://github.com/bucklescript
gards on Youtube
Sean Grove - Everything appends with a Reason : https://youtu.be/tB705w4w6H0
Jake Trent - TDD a ReasonML Function : https://youtu.be/nivVNJPj2z8
Cheng Lou - Imperfection : https://youtu.be/tCVXp6gFD8o

More Related Content

PDF
JQuery plugin development fundamentals
PDF
How to work with legacy code
PDF
How to work with legacy code PHPers Rzeszow #2
PDF
Jquery plugin development
ODP
Jquery Plugin
KEY
BDT on PHP
PPT
PPTX
Introduction to jQuery
JQuery plugin development fundamentals
How to work with legacy code
How to work with legacy code PHPers Rzeszow #2
Jquery plugin development
Jquery Plugin
BDT on PHP
Introduction to jQuery

What's hot (20)

PPTX
PDF
Learning jQuery in 30 minutes
PPT
Designers Guide To jQuery
PPT
Intro to jQuery
ODP
Introduction to jQuery
PPTX
jQuery Fundamentals
PDF
[PyConTW 2013] Write Sublime Text 2 Packages with Python
PPT
JQuery introduction
PPTX
Jquery plugin development
PDF
How to actually use promises - Jakob Mattsson, FishBrain
PDF
Javascript session june 2013 (iii) jquery json
PPTX
PPTX
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
PDF
Intro to jquery
PDF
Pagination in PHP
PDF
Add edit delete in Codeigniter in PHP
PPTX
Let's write secure drupal code!
PDF
Prototype & jQuery
PDF
Country State City Dropdown in PHP
Learning jQuery in 30 minutes
Designers Guide To jQuery
Intro to jQuery
Introduction to jQuery
jQuery Fundamentals
[PyConTW 2013] Write Sublime Text 2 Packages with Python
JQuery introduction
Jquery plugin development
How to actually use promises - Jakob Mattsson, FishBrain
Javascript session june 2013 (iii) jquery json
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Intro to jquery
Pagination in PHP
Add edit delete in Codeigniter in PHP
Let's write secure drupal code!
Prototype & jQuery
Country State City Dropdown in PHP
Ad

Similar to NodeJS The edge of Reason - Lille fp#6 (20)

PDF
Introduction to ReasonML
PDF
Perkenalan ReasonML
PDF
Wt unit 2 ppts client side technology
PDF
Wt unit 2 ppts client sied technology
PPTX
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
PPTX
An introduction to javascript
PPT
Introduction To Groovy 2005
PDF
Groovy On Trading Desk (2010)
PDF
Android L01 - Warm Up
PPTX
Javascript first-class citizenery
PDF
How to React Native
PPTX
Web Development Study Jam #2 _ Basic JavaScript.pptx
PPT
Intro to php
PPTX
Art of Javascript
PDF
JSLT: JSON querying and transformation
PPTX
An Introduction to JavaScript
PPT
루비가 얼랭에 빠진 날
PPTX
JavascriptCOmpleteGuideCourseFromZero.pptx
PPT
Fantom and Tales
Introduction to ReasonML
Perkenalan ReasonML
Wt unit 2 ppts client side technology
Wt unit 2 ppts client sied technology
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
An introduction to javascript
Introduction To Groovy 2005
Groovy On Trading Desk (2010)
Android L01 - Warm Up
Javascript first-class citizenery
How to React Native
Web Development Study Jam #2 _ Basic JavaScript.pptx
Intro to php
Art of Javascript
JSLT: JSON querying and transformation
An Introduction to JavaScript
루비가 얼랭에 빠진 날
JavascriptCOmpleteGuideCourseFromZero.pptx
Fantom and Tales
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
System and Network Administration Chapter 2
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
medical staffing services at VALiNTRY
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
AI in Product Development-omnex systems
PPTX
Transform Your Business with a Software ERP System
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
ai tools demonstartion for schools and inter college
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Nekopoi APK 2025 free lastest update
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Understanding Forklifts - TECH EHS Solution
PPT
Introduction Database Management System for Course Database
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
System and Network Administration Chapter 2
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Softaken Excel to vCard Converter Software.pdf
medical staffing services at VALiNTRY
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
AI in Product Development-omnex systems
Transform Your Business with a Software ERP System
Odoo POS Development Services by CandidRoot Solutions
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
ai tools demonstartion for schools and inter college
Navsoft: AI-Powered Business Solutions & Custom Software Development
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Nekopoi APK 2025 free lastest update
Wondershare Filmora 15 Crack With Activation Key [2025
ManageIQ - Sprint 268 Review - Slide Deck
Understanding Forklifts - TECH EHS Solution
Introduction Database Management System for Course Database
PTS Company Brochure 2025 (1).pdf.......
Upgrade and Innovation Strategies for SAP ERP Customers

NodeJS The edge of Reason - Lille fp#6

  • 1. ReasonML & Bucklescript, or how to do a functional NodeJS app NodeJS The edge of Reason
  • 2. What I do Thomas Haessle @Oteku cutii.io
  • 5. fit functional Object literals Spread operators Arrays map / reduce / filter Functions as first class citizen Currying Closures Arrow functions … JSX (composition) React stateless components (composants fonctionnels) React PropTypes (Typage sur propriétés des composants) … Redux pattern … RxJS
  • 6. is unfunctional Code Easy to Reason About : - does not affect or mutate external state - does not rely on external state - always return the same corresponding output for a given input - have up to date documentation
  • 7. Give me a Reason(ML) Reason lets you write simple, fast and quality type safe code while leveraging both the JavaScript & OCaml ecosystems.
  • 8. How a 21 years old language may Reasonably help me ?
  • 9. How a 21 years old language may Reasonably help me ?
  • 10. How a 21 years old language may Reasonably help me ? … and some love Reasons (be patient)
  • 12. is designed for JS dev const greeting = "Bonjour"; const greetList = []; greetList.push(greeting); /*references are immutables, not values !*/ const gList = ['Hello', 'Hallo']; const greetings = [greeting, ...gList]; let who = "FP Lille#7"; who = "LilleFP#6"; function internationalGreet(gWords, name) { return gWords.map(current => current + " " + name); } console.log(...internationalGreet(greetings, who)); dummy.js let greeting = "Bonjour"; /* inference */ /* List type is immutable */ let greetList = []; let prepended = [greeting, ...greetList]; let appended = greetList @ [greeting]; let greetArray = [||]; /* Array type is mutable */ greetArray.(0) = greeting; let gList: list string = ["Hello", "Hallo"]; /* type may be explicit */ let greetings = [greeting, ...gList]; /* (ノ^ヮ^)ノ*:・゚✧ spread operator */ let who = ref "FP Lille#7"; /* explicit mutability */ who := "LilleFP#6"; let internationalGreet gWords name => gWords |> List.map (fun current => current ^ " " ^ name); internationalGreet greetings !who |> List.iter (fun current => Js.log current); dummy.re
  • 13. is designed for JS dev let greeting = "Bonjour"; /* inference */ /* List type is immutable */ let greetList = []; let prepended = [greeting, ...greetList]; let appended = greetList @ [greeting]; let greetArray = [||]; /* Array type is mutable */ greetArray.(0) = greeting; let gList: list string = ["Hello", "Hallo"]; /* type may be explicit */ let greetings = [greeting, ...gList]; /* (ノ^ヮ^)ノ*:・゚✧ spread operator */ let who = ref "FP Lille#7"; /* explicit mutability */ who := "LilleFP#6"; let internationalGreet gWords name => gWords |> List.map (fun current => current ^ " " ^ name); internationalGreet greetings !who |> List.iter (fun current => Js.log current); dummy.re let greeting = "Bonjour" let greetList = [] let prepended = greeting :: greetList let appended = greetList @ [greeting] let greetArray = [||] let _ = greetArray.(0) <- greeting let gList: string list = ["Hello"; "Hallo"] let greetings = greeting :: gList let who = ref "FP Lille#7" let _ = who := "LilleFP#6" let internationalGreet gWords name = gWords |> (List.map (fun current -> current ^ (" " ^ name))) let _ = (internationalGreet greetings (!who)) |> (List.iter (fun current -> Js.log current)) dummy.ml
  • 16. add1.re add1.rei demo.re human readable output dead code elimination 
 (similaire prepack.io) code optimizations amazingly fast safer JS runtime execution ( param = 2 + undefined 
 … mais param = 2 + « 3 » ) demo.js add1.js bsb --make-world
  • 17. || • Compile high-level rawlambda  to js • Focuses more on npm • Readable js output • Compile low-level bytecode to js • Focuses more on opam • Uglify js output • Amazingly fast • Improving quickly • Stimulate each other • License LGPL
  • 23. type action = | Click | Toggle; type state = {count: int, show: bool}; let component = ReasonReact.reducerComponent "MyDialog"; let make _children => { ...component, initialState: fun () => {count: 0, show: false}, reducer: fun action state => switch action { | Click => ReasonReact.Update {...state, count: state.count + 1} | Toggle => ReasonReact.Update {...state, show: not state.show} }, render: fun self => { let message = "Clicked " ^ string_of_int self.state.count ^ " times(s)"; <div> <MyDialog onClick=(self.reduce (fun _event => Click)) onSubmit=(self.reduce (fun _event => Toggle)) /> (ReasonReact.stringToElement message) </div> } }; Reducer component
  • 24. will (would) be amazing Tooling
  • 25. ality CONS : Still young Little community (but growing) A functional language learning curve for JS devs No native packages management (hot topic) Poor documentation Bucklescript targets ES5 while node.js is ES8 VS babel-preset-env Breaking change version is coming next month PROS : Battle tested type system with inference : OCaml under the hood
 Kind community Really good samples Production ready (used for messenger.com)
 Reason-react with reducer components First Reason React Native app published in stores last month (https://github.com/FormidableLabs/seattlejsconf-app) Facebook baked May be adopt baby-step (one node module, one react component, …)
  • 26. ason to be confident Why ? Reason’s design fit our problems Do we have a great community ? Almost … we have a discord Yes and great toolingDo we have a great language ?
  • 28. ad More ReTwit @reasonml @jordwalke (react & reason creator) @_chenglou (react team / reason evangelist) @sgrove (reason evangelist) @bobzhang1988 (bucklescript creator) @ken_wheeler (Director of Open Source @FormidableLabs) ReSpond
 https://discordapp.com/invite/reasonml https://www.reddit.com/r/reasonml/ ReSources https://reasonml.github.io/ https://github.com/vramana/awesome-reasonml https://github.com/bucklescript
  • 29. gards on Youtube Sean Grove - Everything appends with a Reason : https://youtu.be/tB705w4w6H0 Jake Trent - TDD a ReasonML Function : https://youtu.be/nivVNJPj2z8 Cheng Lou - Imperfection : https://youtu.be/tCVXp6gFD8o