The document discusses Communicating Sequential Processes (CSP), a formal language for describing patterns of interaction in concurrent systems. CSP was initially developed to solve problems with asynchronous code leading to callback pyramids and unclear flow. The document advocates for using CSP and channels in JavaScript to make asynchronous code more readable and understandable through a synchronous-like programming style.
9. ‣ IBM1989: 50%of the effort inaccomplishing atask forthe
programmer istowards understanding the system
‣ BellLabs1992:60%-80%of their time understanding
code,20% as the developersgainexperience with current
codebase
‣ NationalResearchCouncil1997(Canada): over25% of
theirtimeeithersearchingfororlooking atcode
‣ Microsoft2006: 50%
‣ Peter Hallam2006:70%during personal experiment
‣ Microsoft2007:65%(survey)
30. import {go, chan, take, timeout, put} from "js-csp";
var ch = chan();
go(function*() {
log(1, "line 1");
log(1, " line 2");
log(1, " <- take");
log(1, " took: process 2: ", yield take(ch));
log(1, " line 5");
log(1, " <- take");
log(1, " took: process 2: ", yield take(ch));
log(1, " line 8");
});
go(function*() {
log(2, "line 1");
log(2, " -> put");
yield put(ch, 1);
log(2, " line 4");
log(2, " -> put");
yield put(ch, 2);
log(2, " line 7");
});
sync point
31. p( 1 ): line 1
p( 1 ): line 2
p( 1 ): <- take
p( 2 ): line 1
p( 2 ): -> put
p( 2 ): line 4
p( 2 ): -> put
p( 1 ): took: process 2: val: 1
p( 1 ): line 5
p( 1 ): <- take
p( 2 ): line 7
p( 1 ): took: process 2: val: 2
p( 1 ): line 8
32. p( 1 ): line 1
p( 1 ): line 2
p( 1 ): <- take
p( 2 ): line 1
p( 2 ): -> put
p( 2 ): line 4
p( 2 ): -> put
p( 1 ): took: process 2: val: 1
p( 1 ): line 5
p( 1 ): <- take
p( 2 ): line 7
p( 1 ): took: process 2: val: 2
p( 1 ): line 8
what the fuck?