SlideShare a Scribd company logo
IMMUTABLE
DATA
STRUCTURE
DI FAN
FSA-1706-FLEX
WHY
WHAT
HOW
THE
CHALLENGE
import { projectMapper, projectFilter } from 'util/helper'
let projects = []
…
projects.push(graceshopper, stackathon, capstone)
projectMapper(projects)
projectFilter(projects)
console.log(projects)
import { projectMapper, projectFilter } from 'util/helper'
let projects = []
…
projects.push(graceshopper, stackathon, capstone)
projectMapper(projects)
projectFilter(projects)
console.log(projects)
STATE
MUTABLE
MUTABLE
STATE
State
| stāt | noun
Value of an identity at a time.
— Rich Hickey
UI = render(state)
const state = { foo: ‘foo’}
UI = render(state) // { foo: ‘foo’}
setState(‘bar’)
UI = render(state) // { bar: ‘bar’}
setState(‘baz’)
UI = render(state) // { baz: ‘baz’}
TIME
REDUX
“No Side Effect Please”
SIDEEFFECTS
MUTABILITY
const state = { foo: ‘foo’}
UI = render(state) // { foo: ‘foo’}
setState(‘bar’)
UI = render(state) // { bar: ‘bar’}
setState(‘baz’)
UI = render(state) // { baz: ‘baz’}
TIME
TIME
state
value 1
value 2
value 3
TIME
state
value 1
value 2
value 3
state 1
state 2
state 3
const state0 = { foo: ‘foo’}
UI = render(state0)
const state1 = setState(‘bar’)
UI = render(state1)
/* Identity */
state = state0 —> state = state1
TIME
SIDEEFFECTS
MUTABILITY
Oops…That’s
SLOW & BIG
RETRIEVAL
TREE 9
3
1
20
6
75
21
19
2014 39
50
65
TRIE 0 1
0 10 1
0 10 1
0 1
0 1
0 10 1
0 10 1
0 1
index = 5
index = ‘0b101’
0 1
0 10 1
0 10 1
0 1
index = 5
index = ‘0b101’
0 1
0 10 1
0 10 1
0 1
index = 5
index = ‘0b101’
0 1
0 10 1
0 10 1
0 1
index = 5
index = ‘0b101’
Oops…
Nothing Here
UPDATE
0 1
0 10 1
0 10 1
0 1
UPDATE
0 1
0 10 1
0 10 1
0 10 1
0 1
0 1
OldNew
UPDATE
0 1
0 1
0 10 1
0 1
0 1
0 1
0 1 0 1
OldNew
BITMAPPED
VECTORTRIE
WHAT
ABOUT
OBJECTS?
0 1
0 10 1
0 10 1
0 1
E D G R M
HASHKEYS
0 1
0 10 1
0 10 1
0 1
E D G R M
000 100011010001
hash(‘D’) = 1 // ‘0b001’
HASHARRAY
MAPPEDTRIE
STRUCTURAL
SHARING
PATHCOPYING
Worry native performance no more…
SMALL & FAST
HOW
TOUSE
…INJS
https://facebook.github.io/immutable-js/
https://swannodette.github.io/mori/
import { List } from 'immutable'
let list = List.of(1, 2, 3)
let list2 = list.push(4)
console.log(list.size) // 3
console.log(list2.get(3)) // 4
import mori from 'mori'
let v = mori.vector(1, 2, 3)
let v2 = mori.conj(v, 4)
console.log(mori.count(v)) // 3
console.log(mori.get(v2, 3)) // 4
RECONCILIATION
0 1
0 1
0 10 1
0 1
0 1
0 1
0 1 0 1
OldNew
NOMORE
MUTABILITY!!
Tech Talk - Immutable Data Structure
Persistent Data Structures and Managed References
- Rich Hickey
React.js Conf 2015 - Immutable Data and React -
Lee Byron, Facebook
Immutable data structures for functional JS | JSConf
EU 2017 - Anjana Vakil
REFERENCES

More Related Content

PDF
Dion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
PPTX
Data Types and Processing in ES6
PDF
Mozilla とブラウザゲーム
PPTX
99 líneas que lo simplifican todo( sin animar)
PPTX
กลุ่ม6
PPTX
Fixing Web Data in Production
PDF
Bindings: the zen of montage
PDF
Clojure testing with Midje
Dion Almaer & Ben Galbraith - Build Once, Deploy Everywhere
Data Types and Processing in ES6
Mozilla とブラウザゲーム
99 líneas que lo simplifican todo( sin animar)
กลุ่ม6
Fixing Web Data in Production
Bindings: the zen of montage
Clojure testing with Midje

What's hot (19)

PPTX
Testing with Midje
PPTX
The redux saga begins
PDF
Продвинутая отладка JavaScript с помощью Chrome Dev Tools
PPTX
Voldemort collections library
PDF
State managment in a world of hooks
PDF
[2019] Java에서 Fiber를 이용하여 동시성concurrency 프로그래밍 쉽게 하기
PDF
The evolution of redux action creators
PDF
如何「畫圖」寫測試 - RxJS Marble Test
DOC
vbscript-reference book
PDF
Universal JavaScript
PDF
Mutation Testing - Voxxed Days Bucharest 10.03.2017
PDF
An Introduction to JavaScript: Week 4
PDF
Node.js - Demnächst auf einem Server in Ihrer Nähe
PPTX
Guava - Elements of Functional Programming
PDF
20181020 advanced higher-order function
PPTX
Using Redux-Saga for Handling Side Effects
PDF
Introduction to cron queue
DOC
Program(Output)
Testing with Midje
The redux saga begins
Продвинутая отладка JavaScript с помощью Chrome Dev Tools
Voldemort collections library
State managment in a world of hooks
[2019] Java에서 Fiber를 이용하여 동시성concurrency 프로그래밍 쉽게 하기
The evolution of redux action creators
如何「畫圖」寫測試 - RxJS Marble Test
vbscript-reference book
Universal JavaScript
Mutation Testing - Voxxed Days Bucharest 10.03.2017
An Introduction to JavaScript: Week 4
Node.js - Demnächst auf einem Server in Ihrer Nähe
Guava - Elements of Functional Programming
20181020 advanced higher-order function
Using Redux-Saga for Handling Side Effects
Introduction to cron queue
Program(Output)
Ad

Similar to Tech Talk - Immutable Data Structure (20)

PDF
Immutability, and how to do it in JavaScripts
PPTX
Functional programming with Immutable .JS
PPTX
Immutability and Javascript - Nadia Miętkiewicz
PPTX
Immutable Libraries for React
PDF
Immutable js reactmeetup_local_ppt
PDF
.NET Fest 2018. Дмитрий Иванов. Иммутабельные структуры данных в .NET: зачем ...
PDF
Immutable, and More
PDF
Rubyslava slides-26.09.2013
PDF
Building Functional Islands
PPTX
Immutable data structures - A Primer
PDF
Types and Immutability: why you should care
PDF
(6) collections algorithms
PDF
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
PDF
Functional Web Development
PDF
Rust tutorial from Boston Meetup 2015-07-22
PDF
Efficient Immutable Data Structures (Okasaki for Dummies)
PDF
Data Structures Handling Trillions of Daily Streaming Events by Evan Chan
PDF
20 000 Leagues Under The Angular 4
PPTX
Briefly Rust
PDF
Purely functional data structures demystified
Immutability, and how to do it in JavaScripts
Functional programming with Immutable .JS
Immutability and Javascript - Nadia Miętkiewicz
Immutable Libraries for React
Immutable js reactmeetup_local_ppt
.NET Fest 2018. Дмитрий Иванов. Иммутабельные структуры данных в .NET: зачем ...
Immutable, and More
Rubyslava slides-26.09.2013
Building Functional Islands
Immutable data structures - A Primer
Types and Immutability: why you should care
(6) collections algorithms
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Functional Web Development
Rust tutorial from Boston Meetup 2015-07-22
Efficient Immutable Data Structures (Okasaki for Dummies)
Data Structures Handling Trillions of Daily Streaming Events by Evan Chan
20 000 Leagues Under The Angular 4
Briefly Rust
Purely functional data structures demystified
Ad

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
Teaching material agriculture food technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Teaching material agriculture food technology
Review of recent advances in non-invasive hemoglobin estimation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
Agricultural_Statistics_at_a_Glance_2022_0.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectroscopy.pptx food analysis technology
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Dropbox Q2 2025 Financial Results & Investor Presentation
A comparative analysis of optical character recognition models for extracting...
Mobile App Security Testing_ A Comprehensive Guide.pdf

Tech Talk - Immutable Data Structure