1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
<!DOCTYPE html>
<html>
<head>
<title>
The Codex »
Entry Points
</title>
<link
rel='stylesheet'
type='text/css'
href='http://fonts.googleapis.com/css?family=Buenard:400,700&subset=latin,latin-ext'>
<link
rel="stylesheet"
type="text/css"
href="../media/css/reset.css">
<link
rel="stylesheet"
type="text/css"
href="../media/css/grimoire.css">
</head>
<body>
<div id="shell">
<ol id="breadcrumbs">
<li class="crumb-0 not-last">
<a href="../">index</a>
</li>
<li class="crumb-1 not-last">
<a href="./">dev</a>
</li>
<li class="crumb-2 last">
entry-points
</li>
</ol>
<div id="article">
<h1 id="entry-points">Entry Points</h1>
<p>The following captures a conversation from IRC:</p>
<blockquote>
<p><a href="https://twitter.com/derspiny">Owen J</a>: Have you run across the idea
of an "entry point" in a runtime yet? (You've definitely used it, just
possibly not known it had a name.)</p>
<p><a href="https://twitter.com/aeleitch">Alex L</a>: I have not!</p>
<p><a href="https://twitter.com/derspiny">Owen J</a>: It's the point where the
execution of the outside system -- the OS, the browser, the Node
runtime, whatever -- stops and the execution of your code starts. Some
platforms only give you one: C on Unix is classic, where there's only
two entry points: main and signal handlers (and a lot of apps only use
main). JS gives you <em>a shit fucking ton</em> of entry points.</p>
<p><a href="https://twitter.com/derspiny">Owen J</a>: In a browser, the pageload
process is an entry point: your code gets run when the browser
encounters a <code><script></code> tag. So is every event handler. There's none
of your code running when an event handler starts, only the browser
is running. So is every callback from an external service, like
<code>XmlHttpRequest</code> or <code>EventSource</code> or the <code>File</code> APIs. In Node, the top
level of your main script is an entry point, but so is every callback
from an external service.</p>
<p><a href="https://twitter.com/aeleitch">Alex L</a>: Ahahahahahahaha oh my
god. There is no way for me to contain them all. <em>everything the light
touches.</em></p>
<p><a href="https://twitter.com/derspiny">Owen J</a>: This is important for
reasoning about exception handling! <em>In JS</em>, exception handling only
propagates one direction: towards the entry point of this sequence of
function calls.</p>
<p><a href="https://twitter.com/aeleitch">Alex L</a>: Yes. This is what <em>I</em> call a
stack trace.</p>
<p><a href="https://twitter.com/derspiny">Owen J</a>: If an exception escapes from
an entry point, the JS runtime logs it, and then the outside runtime
takes over again. That's one of the ways callbacks from external
services fuck up the idea of a stack trace as a map of control flow.</p>
<p><a href="https://twitter.com/aeleitch">Alex L</a>: Huh. Yes. Yes I can see
that. I mean, in my world, control flow is a somewhat handwavey idea
right now. I'm starting to understand why so many people hate JS-land.</p>
<p><a href="https://twitter.com/derspiny">Owen J</a>: Sure. But, for example, a
promise chain is a tool for restructuring control flow. In principle,
error handling should provide <em>some</em> kind of map of that, to allow
programmers -- you -- to diagnose how a program reached a given error
state and maybe one day fix the problem. In THIS future, none of them
do that well, though.</p>
<p><a href="https://twitter.com/aeleitch">Alex L</a>: Yes. Truly the darkest
timeline, but this reviews why I am having these concerns.</p>
</blockquote>
</div>
<div id="comments">
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'grimoire'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="footer">
<p>
The Codex —
Powered by <a href="http://markdoc.org/">Markdoc</a>.
<a href="https://bitbucket.org/ojacobson/grimoire.ca/src/master/wiki/dev/entry-points.md">See this page on Bitbucket</a> (<a href="https://bitbucket.org/ojacobson/grimoire.ca/history-node/master/wiki/dev/entry-points.md">history</a>).
</p>
</div>
</div>
</body>
</html>
|