git ssb

0+

dinoworm 🐛 / campjs-viii-ludditejs



Commit 7035a2f6072240b57a7c704b6a70b352a7fb8a19

checkpoint

Michael Williams committed on 7/30/2017, 12:47:12 PM
Parent: 95314a493f6e65e9f5a541b3d9e7d2d1e4fecfb3

Files changed

NOTES.mdchanged
README.mdchanged
NOTES.mdView
@@ -44,4 +44,238 @@
4444 - catstack
4545 - patchwork / bay
4646
4747
48 +---
49 +
50 +---
51 +
52 +### modules
53 +
54 +```js
55 +// randomCat.js
56 +const { random: randomCat } = require('cat-names')
57 +
58 +module.exports = randomCat
59 +```
60 +
61 +???
62 +
63 +we first create a `const` variable from a sync `require` function.
64 +
65 +we assign the result of this to a global variable `module.exports`
66 +
67 +not the hundred million special syntaxes to import and export es modules
68 +
69 +
70 +## functions
71 +
72 +```js
73 +// randomCatAsync.js
74 +const randomCat = require('./randomCat')
75 +
76 +module.exports = function randomCatAsync (cb) {
77 + try {
78 + cb(null, randomCat())
79 + } catch (err) {
80 + cb(err)
81 + }
82 +}
83 +---
84 +
85 +## sync functions
86 +
87 +
88 +```
89 +function fn () {
90 + try {
91 + return value()
92 + } catch (err) {}
93 +}
94 +```
95 +
96 +## async functions
97 +
98 +### `cb(err, value())
99 +
100 +## aids
101 +
102 +- [eating your own dog food](https://en.wikipedia.org/wiki/Eating_your_own_dog_food)
103 +- [mad science method](https://github.com/ahdinosaur/mad-science-handbook/blob/master/collaboration.md#the-mad-science-cycle)
104 +- [do-ocracy](https://communitywiki.org/wiki/DoOcracy)
105 +- marathon: keep a slow & steady pace one step at a time
106 +- if you see a job that needs doing, it's your job to do (do-ocrarcy)
107 +- too much sugar is bad for your health (simple interfaces)
108 +
109 +## blocks
110 +
111 +- cave method: try to design or implement the _perfect_ system before sharing it
112 +- [design by committee](https://en.wikipedia.org/wiki/Design_by_committee)
113 +- sprint: hype, mania, and burn-out
114 +- [waterfall design](https://en.wikipedia.org/wiki/Waterfall_model)
115 +
116 +---
117 +
118 +# 2009
119 +
120 +## nobody cares about JavaScript
121 +
122 +> it's a toy language
123 +
124 +---
125 +
126 +## Ryan Dahl (@ry) creates Node.js
127 +
128 +[watch the original presentation](https://www.youtube.com/watch?v=ztspvPYybIY)
129 +
130 +> To provide a *purely evented*, *non-blocking* infrastructure to script *highly concurrent* programs.
131 +
132 +(original website [here](https://web.archive.org/web/20091003131634/http://nodejs.org/))
133 +
134 +
135 +???
136 +
137 +// core-less node? https://github.com/nodejs/node/issues/7098
138 +// https://github.com/nucleus-js/design
139 +
140 +---
141 +
142 +
143 +## function
144 +
145 +```js
146 +function (...args) {
147 + return value
148 +}
149 +```
150 +
151 +---
152 +## module
153 +
154 +here's the CommonJS module system, as used and popularized by Node.js
155 +
156 +```js
157 +// cat.js
158 +require('cat-names').random
159 +```
160 +```js
161 +// cat-loop.js
162 +const cat = require('./cat')
163 +
164 +setInterval(() => {
165 + console.log(cat())
166 +})
167 +```
168 +
169 +---
170 +
171 +# [the module wrapper](https://nodejs.org/api/modules.html#modules_the_module_wrapper)
172 +
173 +every module is actually wrapped in a closure
174 +
175 +```js
176 +(function (exports, require, module, __filename, __dirname) {
177 + // your module code actually lives in here
178 +})
179 +```
180 +
181 +---
182 +
183 +# [how require works](https://github.com/maxogden/art-of-node#how-require-works)
184 +
185 +> When you call `require('some_module')` in node here is what happens:
186 +>
187 +> 1. if a file called `some_module.js` exists in the current folder node will load that, otherwise:
188 +> 2. node looks in the current folder for a `node_modules` folder with a `some_module` folder in it
189 +> 3. if it doesn't find it, it will go up one folder and repeat step 2
190 +>
191 +> This cycle repeats until node reaches the root folder of the filesystem, at which point it will then check any global module folders (e.g. `/usr/local/node_modules` on Mac OS) and if it still doesn't find `some_module` it will throw an exception.
192 +
193 +---
194 +
195 +# [the Node aesthetic](http://substack.net/node_aesthetic)
196 +
197 +> - Callback austerity: Simplicity, asyncronous nature and nice additions that are included like the event system.
198 +> - Limited surface area: Using modules instead of extending them, NPM, re-usable interfaces and simple, consistent function calls.
199 +> - Batteries not included: Only few modules in the core distribution – reduces clutter, version dependencies and bureaucracy.
200 +> - Radical reusability: Breaking up a problem in small pieces, NPM module locations, great versioning approach
201 +
202 +
203 +---
204 +
205 +# factory
206 +
207 +> “The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” ~ Joe Armstrong
208 +
209 +- [The Two Pillars of JavaScript Part 1: How to Escape the 7th Circle of Hell](https://medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3)
210 +- [`stampit`](https://github.com/stampit-org/stampit)
211 +
212 +???
213 +
214 +TODO two ways of handling errors: throw err and cb(err)
215 +how it's important to throw 'programmer errors'
216 +
217 +---
218 +
219 +# callback
220 +
221 +- [`run-series`](https://github.com/feross/run-series)
222 +- [`run-parallel`](https://github.com/feross/run-parallel)
223 +- [`run-auto`](https://github.com/feross/run-auto)
224 +- [`run-waterfall`](https://github.com/feross/run-waterfall)
225 +
226 +---
227 +
228 +# continuable
229 +
230 +a "continuable" is a function that takes a single argument, a node-style (error-1st) callback.
231 +
232 +```js
233 +const continuable = (cb) => {
234 + // do stuff...
235 + cb(err, data)
236 +}
237 +```
238 +
239 +- [`continuable`](https://github.com/Raynos/continuable)
240 +- [`cont`](https://github.com/dominictarr/cont)
241 +
242 +---
243 +
244 +# observable
245 +
246 +> - `thing()` gets the value
247 +> - `thing.set(...)` sets the value
248 +> - `thing(function (value) { ... })` listens to the value.
249 +
250 +- [`observ`](https://github.com/Raynos/observ)
251 +- [`observable`](https://github.com/dominictarr/observable)
252 +- [`push-stream`](https://github.com/ahdinosaur/push-stream)
253 +- [`mutant`](https://github.com/mmckegg/mutant)
254 +
255 +---
256 +
257 +# stream
258 +
259 +- [`pull-stream`](https://pull-stream.github.io)
260 +- [pull streams](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
261 +- [pull-stream-examples](https://github.com/dominictarr/pull-stream-examples)
262 +
263 +---
264 +
265 +# references
266 +
267 +- [es2040](https://github.com/ahdinosaur/es2040)
268 +- [Art of Node](https://github.com/maxogden/art-of-node)
269 +- [Art of I/O](http://ioschool.is/art-of-io/sessions/0/?notes=true)
270 +- [Tiny Guide to Non Fancy Node](https://github.com/yoshuawuyts/tiny-guide-to-non-fancy-node)
271 +
272 +???
273 +
274 +TODO luddite.js apps:
275 +
276 +- https://webtorrent.io/
277 +- http://standardjs.com/
278 +- https://peermaps.github.io/
279 +- http://loopjs.com/
280 +- https://scuttlebot.io/
281 +- https://choo.io/
README.mdView
@@ -20,279 +20,364 @@
2020 ???
2121
2222 second time presenting at a conference.
2323
24 +i'm going to attack some JavaScript patterns, but i use those patterns too.
25 +
26 +everyone in the JavaScript community is doing a wonderful job.
27 +
2428 apologies in advance if i disguise any opinions as facts.
2529
2630 ---
2731
28-# what?
32 +## what?
2933
30-luddite.js is a JavaScript framework to make building apps fun again
34 +**luddite.js** is _simple decentralized JavaScript_.
3135
32----
36 +???
3337
34-## who are the Luddites?
38 +a study of JavaScript evolution
3539
36-[Luddites](https://en.wikipedia.org/wiki/Luddite) are people against _centralized technology_ which decreases quality of life.
40 +also totally made up
3741
42 +JavaScript was good
43 +
44 +now it's popular
45 +
46 +here's the beef
47 +
3848 ---
3949
50 +## Luddite?
4051
41-## what is luddite.js?
52 +the [Luddites](https://en.wikipedia.org/wiki/Luddite) was a political movement against _automated centralized technology_.
4253
43-a movement against _centralized standards_ which decreases developer experience
54 +<img src="./luddite.jpeg" />
4455
45----
56 +???
4657
47-## what centralized standards?
58 +- many Luddites were skilled machine operators in the textile industry
59 +- they attacked centralized factories who used automated machines operated by unskilled labor
60 +- they wanted machines to make high-quality goods, run by workers who had gone through an apprenticeship and got paid decent wages
4861
4962 ---
5063
51-### tc39
64 +## but JavaScript?
5265
53-a great team advancing the state of the art in JavaScript,
66 +at the
5467
55-but is one of _many_ possible opinions about JavaScript.
68 +- simple primitives
69 +- decentralized userland
5670
57----
71 +???
5872
59-### what other opinions?
73 +- top-down standards process
74 + - vs emergent (mad science) bottom-up module ecosystems
75 + - izs pants post
6076
61----
77 +## simple primitives
6278
6379 what if i told you...
6480
6581 that you only needed plain functions and objects?
6682
83 +???
84 +
85 +- no fancy syntax
86 +- less language clutter
87 +
88 +----
89 +
90 +## sync function
91 +
92 +```js
93 +function fn (...args) { return value }
94 +```
95 +
96 +```js
97 +const fn = (...args) => { return value }
98 +```
99 +
100 +```js
101 +const fn = (...args) => value
102 +```
103 +
104 +
105 +```js
106 +const fn = (...args) => ({ value })
107 +```
108 +
67109 ---
68110
69-### modules
111 +## sync function error
70112
71113 ```js
72-// randomCat.js
73-const { random: randomCat } = require('cat-names')
114 +function fn (...args) { throw error }
115 +```
74116
75-module.exports = randomCat
117 +```js
118 +try {
119 + fn(...args)
120 +} catch (const err) {
121 + // handle error
122 +}
76123 ```
77124
78-???
125 +---
79126
80-we first create a `const` variable from a sync `require` function.
127 +## require / module.exports =
81128
82-we assign the result of this to a global variable `module.exports`
129 +```js
130 +const thing = require('module')
131 +module.exports = thing
132 +```
83133
84-not the hundred million special syntaxes to import and export es modules
134 +```js
135 +const { thing: thingy } = require('module')
136 +module.exports = { thing: thingy }
137 +```
85138
139 +---
86140
87-## functions
141 +## vs: import / export
88142
89143 ```js
90-// randomCatAsync.js
91-const randomCat = require('./randomCat')
144 +import thing from 'module'
145 +import { thing as thingy } from 'module'
146 +```
92147
93-module.exports = function randomCatAsync (cb) {
94- try {
95- cb(null, randomCat())
96- } catch (err) {
97- cb(err)
98- }
148 +---
149 +
150 +## hyperscript
151 +
152 +```js
153 +const h = require('react-hyperscript')
154 +
155 +module.exports = Table
156 +
157 +function Table ({ rows ) {
158 + return h('table.table', rows.map(row => {
159 + h('tr.row', row.map(item => {
160 + h('td.item', item)
161 + })
162 + })
99163 }
164 +```
165 +
100166 ---
101167
102-## sync functions
168 +## vs: jsx
103169
170 +```js
171 +const React = require('react')
104172
105-```
106-function fn () {
107- try {
108- return value()
109- } catch (err) {}
173 +export default function Table ({ rows ) {
174 + return <table className='table'>
175 + {rows.map(row => {
176 + <tr className='row'>
177 + {row.map(item => {
178 + <td className='item'>{item}</td>
179 + })}
180 + </tr>
181 + })
182 + </table>
110183 }
111184 ```
112185
113-## async functions
186 +---
114187
115-### `cb(err, value())
188 +async function
116189
117-## aids
190 +---
118191
119-- [eating your own dog food](https://en.wikipedia.org/wiki/Eating_your_own_dog_food)
120-- [mad science method](https://github.com/ahdinosaur/mad-science-handbook/blob/master/collaboration.md#the-mad-science-cycle)
121-- [do-ocracy](https://communitywiki.org/wiki/DoOcracy)
122-- marathon: keep a slow & steady pace one step at a time
123-- if you see a job that needs doing, it's your job to do (do-ocrarcy)
124-- too much sugar is bad for your health (simple interfaces)
192 +continable
125193
126-## blocks
194 +---
127195
128-- cave method: try to design or implement the _perfect_ system before sharing it
129-- [design by committee](https://en.wikipedia.org/wiki/Design_by_committee)
130-- sprint: hype, mania, and burn-out
131-- [waterfall design](https://en.wikipedia.org/wiki/Waterfall_model)
196 +vs: promise
132197
133198 ---
134199
135-# 2009
200 +callback errors
136201
137-## nobody cares about JavaScript
202 +---
138203
139-> it's a toy language
204 +promise errors
140205
141206 ---
142207
143-## Ryan Dahl (@ry) creates Node.js
208 +observ-able
144209
145-[watch the original presentation](https://www.youtube.com/watch?v=ztspvPYybIY)
210 +---
146211
147-> To provide a *purely evented*, *non-blocking* infrastructure to script *highly concurrent* programs.
212 +vs: es observable
148213
149-(original website [here](https://web.archive.org/web/20091003131634/http://nodejs.org/))
214 +---
150215
216 +pull stream
151217
152-???
218 +---
153219
154-// core-less node? https://github.com/nodejs/node/issues/7098
155-// https://github.com/nucleus-js/design
220 +vs: wg-streams
156221
157222 ---
158223
159-## function
224 +why am i picking on tc39?
160225
161-```js
162-function (...args) {
163- return value
164-}
165-```
226 +---
166227
228 +top-down decision-making
229 +
167230 ---
168231
169-## module
232 +bloat
170233
171-here's the CommonJS module system, as used and popularized by Node.js
234 +- show code size of chrome
235 +- fast software is less about building muscle and more about losing weight
236 + - refactor in less code, not more fancy code
172237
173-```js
174-// cat.js
175-require('cat-names').random
176-```
177-```js
178-// cat-loop.js
179-const cat = require('./cat')
238 +---
180239
181-setInterval(() => {
182- console.log(cat())
183-})
184-```
240 +snippet-driven development
185241
242 +- short snippets supposedly easier for beginners
243 + - i work at a developer bootcamp, i'm not so sure
244 + - too many ways to do something is confusing
245 + - not being able to understand the primitive is confusing
246 +
186247 ---
187248
188-# [the module wrapper](https://nodejs.org/api/modules.html#modules_the_module_wrapper)
249 +what is a standard?
189250
190-every module is actually wrapped in a closure
251 +- anything that enough people use is a "standard"
191252
192-```js
193-(function (exports, require, module, __filename, __dirname) {
194- // your module code actually lives in here
195-})
196-```
253 +example: `feross/standard`
197254
198255 ---
199256
200-# [how require works](https://github.com/maxogden/art-of-node#how-require-works)
257 +how to we do better standards?
201258
202-> When you call `require('some_module')` in node here is what happens:
203->
204-> 1. if a file called `some_module.js` exists in the current folder node will load that, otherwise:
205-> 2. node looks in the current folder for a `node_modules` folder with a `some_module` folder in it
206-> 3. if it doesn't find it, it will go up one folder and repeat step 2
207->
208-> This cycle repeats until node reaches the root folder of the filesystem, at which point it will then check any global module folders (e.g. `/usr/local/node_modules` on Mac OS) and if it still doesn't find `some_module` it will throw an exception.
259 +less coupling to trendy libraries, more function signature conventions: https://twitter.com/jekrb/status/859242655011745793
209260
210261 ---
211262
212-# [the Node aesthetic](http://substack.net/node_aesthetic)
263 +### redux
213264
214-> - Callback austerity: Simplicity, asyncronous nature and nice additions that are included like the event system.
215-> - Limited surface area: Using modules instead of extending them, NPM, re-usable interfaces and simple, consistent function calls.
216-> - Batteries not included: Only few modules in the core distribution – reduces clutter, version dependencies and bureaucracy.
217-> - Radical reusability: Breaking up a problem in small pieces, NPM module locations, great versioning approach
265 +---
218266
267 +### tc39
219268
269 +a great team advancing the state of the art in JavaScript,
270 +
271 +but is one of _many_ possible JavaScript standards.
272 +
220273 ---
221274
222-# factory
275 +### what other standards?
223276
224-> “The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” ~ Joe Armstrong
277 +---
225278
226-- [The Two Pillars of JavaScript Part 1: How to Escape the 7th Circle of Hell](https://medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3)
227-- [`stampit`](https://github.com/stampit-org/stampit)
279 +what if i told you...
228280
229-???
281 +that anyone can make a JavaScript _standard_?
230282
231-TODO two ways of handling errors: throw err and cb(err)
232-how it's important to throw 'programmer errors'
283 +---
233284
285 +## standards in the wild
286 +
234287 ---
235288
236-# callback
289 +### Node.js core
237290
238-- [`run-series`](https://github.com/feross/run-series)
239-- [`run-parallel`](https://github.com/feross/run-parallel)
240-- [`run-auto`](https://github.com/feross/run-auto)
241-- [`run-waterfall`](https://github.com/feross/run-waterfall)
291 +---
242292
293 +#### `require`
294 +
243295 ---
244296
245-# continuable
297 +#### `callback(error, result)`
246298
247-a "continuable" is a function that takes a single argument, a node-style (error-1st) callback.
299 +???
248300
249-```js
250-const continuable = (cb) => {
251- // do stuff...
252- cb(err, data)
253-}
254-```
301 +- simple, less edge cases
302 + - for example, promise edge cases: https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html
303 +- callback hell vs promise hell
255304
256-- [`continuable`](https://github.com/Raynos/continuable)
257-- [`cont`](https://github.com/dominictarr/cont)
305 +---
258306
307 +##### `async` ecosystem
308 +
309 +to make callbacks sane
310 +
259311 ---
260312
261-# observable
313 +#### programmer errors
262314
263-> - `thing()` gets the value
264-> - `thing.set(...)` sets the value
265-> - `thing(function (value) { ... })` listens to the value.
315 +???
266316
267-- [`observ`](https://github.com/Raynos/observ)
268-- [`observable`](https://github.com/dominictarr/observable)
269-- [`push-stream`](https://github.com/ahdinosaur/push-stream)
270-- [`mutant`](https://github.com/mmckegg/mutant)
317 +- promises deliberately break this paradigm: https://blog.domenic.me/youre-missing-the-point-of-promises/
318 +- i blame promises because they capture any thrown errors, which means thrown programmer errors (syntax, bad args, ...) are now swallowed. - https://twitter.com/ahdinosaur/status/864782131666370560
319 +- i'm curious how others deal with this. should i give up on simple intuition and embrace the new JS complexity with more complex dev tools? - https://twitter.com/ahdinosaur/status/864785376644218880
320 +- complexity is cruise control for cool. look at how many things i can do! the technical singularity will save us from our debt, all good bro.
271321
272322 ---
273323
274-# stream
324 +### Node.js userland
275325
276-- [`pull-stream`](https://pull-stream.github.io)
277-- [pull streams](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
278-- [pull-stream-examples](https://github.com/dominictarr/pull-stream-examples)
279326
327 +???
328 +
329 +
280330 ---
281331
282-# references
332 +#### hyperscript
283333
284-- [es2040](https://github.com/ahdinosaur/es2040)
285-- [Art of Node](https://github.com/maxogden/art-of-node)
286-- [Art of I/O](http://ioschool.is/art-of-io/sessions/0/?notes=true)
287-- [Tiny Guide to Non Fancy Node](https://github.com/yoshuawuyts/tiny-guide-to-non-fancy-node)
334 +---
288335
336 +#### continuables
337 +
338 +---
339 +
340 +#### observ-ables
341 +
342 +---
343 +
344 +#### pull streams
345 +
346 +
289347 ???
290348
291-TODO luddite.js apps:
349 +- [history of streams](http://dominictarr.com/post/145135293917/history-of-streams)
350 +- [pull stream examples](https://github.com/dominictarr/pull-stream-examples)
351 +- [pull streams intro](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
352 +- [pull stream](https://pull-stream.github.io/)
353 +- [pull stream workshop](https://github.com/pull-stream/pull-stream-workshop)
292354
293-- https://webtorrent.io/
294-- http://standardjs.com/
295-- https://peermaps.github.io/
296-- http://loopjs.com/
297-- https://scuttlebot.io/
298-- https://choo.io/
355 +differences with node streams:
356 +
357 +- something you can't do using node streams (and probably wg-streams too), return a partial stream pipeline: https://twitter.com/ahdinosaur/status/860057158934712320
358 +- pull streams have pipeline error propagation by default, which is what `pump` does to get around node stream errors being per `.pipe()`.
359 +- pull streams don't buffer by default, which is what `syncthrough` does to get around node stream buffers.
360 +
361 +
362 +#### redux
363 +
364 +#### http middleware
365 +
366 +#### depject
367 +
368 +## stories
369 +
370 +### why
371 +
372 +> When engineering is about “solving interesting problems” and never about why these are problems, you get stuff like Uber.
373 +
374 +https://twitter.com/sanspoint/status/856185837582790655
375 +
376 +### Node.js core
377 +
378 +- https://developer.ibm.com/node/2017/04/20/keeping-node-js-core-small/
379 +
380 +
381 +## references
382 +
383 +- [The Post JavaScript Apocalypse - Douglas Crockford](https://www.youtube.com/watch?v=NPB34lDZj3E)

Built with git-ssb-web