SlideShare a Scribd company logo
1 of 29
Download to read offline
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
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 ?
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

What's hot

Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutesSimon Willison
 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuerySteve Krueger
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQueryAlan Hecht
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuerymanugoel2003
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery FundamentalsGil Fink
 
[PyConTW 2013] Write Sublime Text 2 Packages with Python
[PyConTW 2013] Write Sublime Text 2 Packages with Python[PyConTW 2013] Write Sublime Text 2 Packages with Python
[PyConTW 2013] Write Sublime Text 2 Packages with PythonJenny Liang
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin developmentFaruk Hossen
 
How to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrainHow to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrainCodemotion Tel Aviv
 
Javascript session june 2013 (iii) jquery json
Javascript session june 2013 (iii) jquery   jsonJavascript session june 2013 (iii) jquery   json
Javascript session june 2013 (iii) jquery jsonabksharma
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyBalázs Tatár
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPVineet Kumar Saini
 
Let's write secure drupal code!
Let's write secure drupal code!Let's write secure drupal code!
Let's write secure drupal code!Balázs Tatár
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQueryRemy Sharp
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHPVineet Kumar Saini
 

What's hot (20)

Jquery
JqueryJquery
Jquery
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Php
PhpPhp
Php
 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuery
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 
[PyConTW 2013] Write Sublime Text 2 Packages with Python
[PyConTW 2013] Write Sublime Text 2 Packages with Python[PyConTW 2013] Write Sublime Text 2 Packages with Python
[PyConTW 2013] Write Sublime Text 2 Packages with Python
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin development
 
How to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrainHow to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrain
 
Javascript session june 2013 (iii) jquery json
Javascript session june 2013 (iii) jquery   jsonJavascript session june 2013 (iii) jquery   json
Javascript session june 2013 (iii) jquery json
 
jQuery
jQueryjQuery
jQuery
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
 
Intro to jquery
Intro to jqueryIntro to jquery
Intro to jquery
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
Let's write secure drupal code!
Let's write secure drupal code!Let's write secure drupal code!
Let's write secure drupal code!
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHP
 

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

Introduction to ReasonML
Introduction to ReasonMLIntroduction to ReasonML
Introduction to ReasonMLRiza Fahmi
 
Perkenalan ReasonML
Perkenalan ReasonMLPerkenalan ReasonML
Perkenalan ReasonMLRiza Fahmi
 
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptxMYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptxArjayBalberan1
 
An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascripttonyh1
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005Tugdual Grall
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Jonathan Felch
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
Web Development Study Jam #2 _ Basic JavaScript.pptx
Web Development Study Jam #2 _ Basic JavaScript.pptxWeb Development Study Jam #2 _ Basic JavaScript.pptx
Web Development Study Jam #2 _ Basic JavaScript.pptxSekarMaduKusumawarda1
 
Intro to php
Intro to phpIntro to php
Intro to phpSp Singh
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformationLars Marius Garshol
 
An Introduction to JavaScript
An Introduction to JavaScriptAn Introduction to JavaScript
An Introduction to JavaScripttonyh1
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날Sukjoon Kim
 

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

Introduction to ReasonML
Introduction to ReasonMLIntroduction to ReasonML
Introduction to ReasonML
 
Perkenalan ReasonML
Perkenalan ReasonMLPerkenalan ReasonML
Perkenalan ReasonML
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptxMYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascript
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
How to React Native
How to React NativeHow to React Native
How to React Native
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
Web Development Study Jam #2 _ Basic JavaScript.pptx
Web Development Study Jam #2 _ Basic JavaScript.pptxWeb Development Study Jam #2 _ Basic JavaScript.pptx
Web Development Study Jam #2 _ Basic JavaScript.pptx
 
Intro to php
Intro to phpIntro to php
Intro to php
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
An Introduction to JavaScript
An Introduction to JavaScriptAn Introduction to JavaScript
An Introduction to JavaScript
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날
 
Fantom and Tales
Fantom and TalesFantom and Tales
Fantom and Tales
 

Recently uploaded

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 

Recently uploaded (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

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
  • 14.
  • 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 ?
  • 27.
  • 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