| title | Persistent data structures thanks to recursive type aliases |
|---|
the talk
How
with a kickass 15 minute presentation, entirely in VSCode.
Why
It's well known that mutability is evil and often troublesome, but you can stop shallow copying arrays (or god-forbid deep copying) every time you want to change them. Let me show you how.
Immutable data structures are the tool for the job when immutability is required.
Time to add them to our toolset.
Persistent data structures are good to know when your product needs time-travel capabilities (like text inputs -- they are pretty bad if CTRL+Z doesn't work).
TODO: Make "Why" shorter?
What
- What does the
persistent data structuremean? - Meet Cons List
- How it looks in TypeScript 3.7
- How it looked before TS3.7
- Functions operating on ConsList
- (big reveal) Instances of fp-ts typeclasses
- Benchmarks of Cons List vs Array operations
Benchmarks
Mutable operations vs cons
| Opeation | ops/s |
|---|---|
| array.unshift(50) | 99953.939 |
| array.push(50) | 70675.276 |
| cons(50, list) | 5822999.798 |
Immutable operation vs cons
| Operation | ops/s |
|---|---|
| [50, ...array] | 12680.588 |
| cons(50, list) | 5485947.933 |
Array.prototype.map vs map
| Operation | ops/s |
|---|---|
| array.map(x => x * 2) | 4389.837 |
| map(list, x => x * 2) | 662.805 |
quick reminders
Controls
{
"key": "cmd+alt+left",
"command": "workbench.action.previousEditor"
},
{
"key": "cmd+alt+right",
"command": "workbench.action.nextEditor"
},
{
"key": "cmd+shift+q",
"command": "quokka.toggle",
"when": "editorTextFocus"
},Move quickly through the slides with
Cmd + Alt + LeftArrow→ View: Open Previous EditorCmd + Alt + RightArrow→ View: Open Next Editor
Run TypeScript slides with
Cmd + Shift + Q→ Quokka.js: Toggle (Start/Stop) on Current File
Minimize distractions and maximize screen space
Cmd + B→ (built-in) View: Toggle Side Bar Visibility
Use regions to hide imports and code pasted from previous slides
