Slides from 'ReasonReact - Functional Programming for React Developers' - presentation at Real World Functional Programming mini-conf, Linux Conf 2018, Sydney Australia
13. https://wiki.haskell.org/The_JavaScript_Problem
1. JavaScript, the language, has some issues that
make working with it inconvenient and make
developing software harder :
lack of module system (only pre-Ecmascript 2015),
weak-typing,
verbose function syntax (pre-Ecmascript 2015),
late binding,
finicky equality/automatic conversion,
‘this’ behaviour,
and lack of static types.
2. We need JavaScript
21. Syntax
JavaScript Reason OCaml
“Hello Linux Conf 2018!” Same as JS Same as JS
‘Hello Linux Conf 2018’ Must use double quotation marks Must use double quotation marks
“Hello” + “Linux Conf” “Hello” ++ “Linux Conf” “Hello” ^ “Linux Conf”
22. Syntax
JavaScript Reason OCaml
true, false Writes like JS, compiles differently Writes like JS, compiles differently
!true Writes like JS, compiles differently not true
||, &&, <=, >=, <, > Writes like JS, compiles differently Writes like JS, compiles differently
23. Syntax
JavaScript let greaterThan = (num1, num2) => num1 > num2;
Reason let greaterThan = (num1, num2) => num1 > num2;
Bucklescript var greaterThan = Caml_obj.caml_greaterthan;
35. Learning and chunking
• Miller, G.A. (1956) The magical number seven, plus or minus
two: some limits on our capacity for processing information.
Psychol. Rev. 63, 81–97
• Gobet, F., Lane, P. C. R., Croker, S., Cheng, P. C. H., Jones, G.,
Oliver, I., & Pine, J. M. (2001). Chunking mechanisms in human
learning. Trends in Cognitive Sciences, 5(6), 236-243.
• Guida, A., Gobet, F., Tardieu, H., & Nicolas, S. (2012). How
chunks, long-term working memory and templates offer a
cognitive explanation for neuroimaging data on expertise
acquisition: A two-stage framework. Brain and Cognition,
79(3), 221-244. doi: 10.1016/j.bandc.2012.01.010
38. NPM /
Yarn
NPM /
Yarn
Included
included in
Browser
Included in
toolchain
language
feature
Includedin syntax
Dependency
Dependency
Dependency
Dependency
Immutable
by default
Dependency
39.
npm install -g bs-platform
then
yarn create react-app my-app --scripts-version
reason-scripts
or
bsb -init my-react-app -theme react
77. “At the language level, it has features that we’ve previously had to
bolt on top of the JavaScript such as allocation-less named
arguments, prop types, and more. In short, it is the best way to
take React to the next level - unlocking far better user
experiences and fast-loading applications
Jordan Walke
(creator, React and Reason,
Reactiflux Discord Channel Q & A, 2017)
78. JavaScript and HTML - I can build things!
React - I can reuse my things!
ReasonReact - I can reuse my React things more safely!
All Functional Programming