Functional Web Development – An Introduction to React.js
with Bertrand Karerangabo
Presented at FITC's Web Unleashed 2014 conference
on September 18 2014
More info at www.fitc.ca
React.js is a UI framework created by Facebook and Instagram. Its primary design goal is to help build large applications with data that changes over time. To do so at scale, conventional wisdom and some long-held assumptions about software development had to be challenged. Gone are the “M” and the “C” in MVC. Gone are templates and special HTML directives. Gone also are traditional data-bindings. The results are applications that are extremely fast and reliable, out of the box.
Bertrand Karerangabo will dive into those concepts that make React.js unique and along the way, also learn how to build web applications from simple, composable and reusable components.
OBJECTIVE
Rethink web development best practices and explore how you can build ambitious and performant application using functional programming with a virtual DOM representation.
TARGET AUDIENCE
Javascript developers working on medium to large dynamic applications.
ASSUMED AUDIENCE KNOWLEDGE
A solid understanding of Javascript and the DOM is strongly recommended.
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
What React.js is and why it was built.
How to deal with the “evil” of mutable state in non-trivial applications.
A strategy for working around notoriously slow and expensive DOM operations.
The way to truly separate concerns, instead of just technologies, in an application.
The SEO, performance and usability benefits that come from using a client-side framework that plays nice with the server.
7. Most software today is very
much like an Egyptian
pyramid with millions of
bricks piled on top of each
other, with no structural
integrity, but just done by
brute force and thousands
of slaves.
— Alan Kay
8. THE PROBLEM HOW CAN WE BUILD LARGE APPLICATIONS
WITH DATA THAT CHANGES OVER TIME?
9.
10. ▸ A (very) short history of web development
▸ OOP in the wild
▸ Functional design
▸ React.js
▸ Immutable (data stuctures)
▸ The server (SEO & performance)
▸ The end
11. 1979 · MODEL-VIEW-CONTROLLER IS BORN
It was fist articulated by Trygve Reenskaug, Adele Goldberg and others
at Xeroc PARC.
MVC was conceived as a general solution to the problem of users
controlling a large and complex data set.
12. MVC AND IT'S LATER VARIANTS HAVE ALL
INHERITED FROM THE INITIAL OOP-BASED
IMPLEMENTATION.
13. 1990 · THE FIRST WEB
BROWSER
It was invented by Tim Berners-Lee and was
initially called WorldWideWeb.
▸ It was written in Objective-C.
▸ It introduced an Internet-based document
system called HyperText Markup Language.
▸ The layout engine was a subclass of
NeXTSTEP's Text class.
▸ The document is static – if data changes, you
must refresh!
14. 1995 · THE FIRST DOM
The Level 0 DOM was created by Netscape for Netscape Navigator 2.0.
The idea was to give web developers a means by which to allow users to
interact with a site.
Given that an HTML document can be represented as a tree, the DOM API
allows for developers to interact and manipulate the tree's nodes.
16. ▸ A (very) short history of web development
▸ OOP in the wild
▸ Functional design
▸ React.js
▸ Immutable (data stuctures)
▸ The server (SEO & performance)
▸ The end
24. ▸ A (very) short history of web development
▸ OOP in the wild
▸ Functional design
▸ React.js
▸ Immutable (data stuctures)
▸ The server (SEO & performance)
▸ The end
28. ▸ A (very) short history of web development
▸ OOP in the wild
▸ Functional design
▸ React.js
▸ Immutable (data stuctures)
▸ The server (SEO & performance)
▸ The end
30. REACT.JS VIRTUAL DOM
The full DOM API in JavaScript.
When rendering, it uses a diff implementation for ultra-high
performance.
f(newDOM, oldDOM) = Δ
40. ▸ A (very) short history of web development
▸ OOP in the wild
▸ Functional design
▸ React.js
▸ Immutable (data stuctures)
▸ The server (SEO & performance)
▸ The end
48. ▸ A (very) short history of web development
▸ OOP in the wild
▸ Functional design
▸ React.js
▸ Immutable (data stuctures)
▸ The server (SEO & performance)
▸ The end
49. SERVER-SIDE RENDERING
var url = require('url')
function(req, res, next) {
// get the application path/stage
var path = url.parse(req.url).pathname;
// get a React.js component
var app = App({path: path});
// render component into string instead of DOM
var markup = React.renderComponentToString(app);
// return full html and let client-side takeover
res.send(markup);
}
50. ▸ A (very) short history of web development
▸ OOP in the wild
▸ Functional design
▸ React.js
▸ Immutable (data stuctures)
▸ The server (SEO & performance)
▸ The end
51. WE NOW HAVE SOLID MODEL
FOR DATA THAT CHANGES
OVER TIME.
52. MIND THE PUNCHLINE
It's not important that the chicken crossed the road or even how it did
it.
What's important is why it crossed the road.