-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
446 lines (337 loc) · 10.4 KB
/
index.html
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Droid+Serif);
@import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body {
font-family: 'Droid Serif';
}
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: 400;
margin-bottom: 0;
}
.remark-slide-content h1 { font-size: 3em; }
.remark-slide-content h2 { font-size: 2em; }
.remark-slide-content h3 { font-size: 1.6em; }
.footnote {
position: absolute;
bottom: 3em;
}
li p { line-height: 1.25em; }
.red { color: #fa0000; }
.large { font-size: 2em; }
a, a > code {
color: rgb(249, 38, 114);
text-decoration: none;
}
code {
-moz-border-radius: 5px;
-web-border-radius: 5px;
background: #e7e8e2;
border-radius: 5px;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
.remark-code-line-highlighted { background-color: #373832; }
.pull-left {
float: left;
width: 47%;
}
.pull-right {
float: right;
width: 47%;
}
.pull-right ~ p {
clear: both;
}
#slideshow .slide .content code {
font-size: 0.8em;
}
#slideshow .slide .content pre code {
font-size: 0.9em;
padding: 15px;
}
.inverse {
background: #272822;
color: #777872;
text-shadow: 0 0 20px #333;
}
.inverse h1, .inverse h2 {
color: #f3f3f3;
line-height: 0.8em;
}
/* Slide-specific styling */
#slide-inverse .footnote {
bottom: 12px;
left: 20px;
}
#slide-how .slides {
font-size: 0.9em;
position: absolute;
top: 151px;
right: 140px;
}
#slide-how .slides h3 {
margin-top: 0.2em;
}
#slide-how .slides .first, #slide-how .slides .second {
padding: 1px 20px;
height: 90px;
width: 120px;
-moz-box-shadow: 0 0 10px #777;
-webkit-box-shadow: 0 0 10px #777;
box-shadow: 0 0 10px #777;
}
#slide-how .slides .first {
background: #fff;
position: absolute;
top: 20%;
left: 20%;
z-index: 1;
}
#slide-how .slides .second {
position: relative;
background: #fff;
z-index: 0;
}
/* Two-column layout */
.left-column {
color: #777;
width: 20%;
height: 92%;
float: left;
}
.left-column h2:last-of-type, .left-column h3:last-child {
color: #000;
}
.right-column {
width: 75%;
float: right;
padding-top: 1em;
}
</style>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="/complexity/refreeze/js/springy.js"></script>
<script src="/complexity/refreeze/js/springyui.js"></script>
<script>
</script>
<textarea id="source">
name: inverse
layout: true
class: center, middle, inverse
---
# Complexity in software development
## Jonas Juselius <[email protected]>
HPC@UiT
---
layout: false
## The tar pit
* Over time software tends to become harder and harder to reason about
* The code bse easily becomes untidy ("I'll fix it later")
* Small changes become harder to implement
* Hacks and workarounds trump design
* Bugs start appearing where in unexpected places
* More time is spent debugging than developing
* Complexity strangles development
---
## Causes of complexity
* Our tools and languages
* Poor design or wrong design
* Not enough resources (e.g. time)
<img src="/complexity/img/joe-paradiso-modular-synth-front.png" style="width: 70%;"/>
---
## The dark side
<img src="/complexity/img/joe-paradiso-modular-synth-back.png" style="width: 70%;"/>
---
## The brain facing computer code
<img src="/complexity/img/Homer-simpson-brain.jpg" style="width: 100%;"/>
---
## Inherent vs. incidental complexity
We distinguish between two types of complexity:
* *Inherent* complexity of the problems space
* *Incidental* complexity in the solution space
* Complexity implies braiding and intertwining
* Simplicity implies "one foldedness", i.e. one braid, single entity
<img src="/complexity/img/tincan.png" style="width: 55%;"/>
---
## Stockholm telephone tower anno 1910
<img src="/complexity/img/stockholm-tower.jpg" style="width: 75%;"/>
---
## Simple vs. easy
* Simple is not the same as easy
* Simple means:
* One role or tasks
* One concept or dimension
* Easy means:
* Familiarity
* Near at hand
* Just because you know it does not make it simple
---
## Development speed
<img src="/complexity/img/develspeed.jpg" style="width: 75%;"/>
---
## Simplicity
* Simplicity is the prerequisite of reliability (E. Dijkstra)
* We can only consider a very limited number of things at once
* Complex things must be considered together, undermining understanding
* We can only hope to make reliable things we understand
<img src="/complexity/img/Lady-Juggler.png" style="width: 40%;"/>
---
## Benefits of simplicity
* Easy to understand
* Easy to change
* Easy to debug
* Simplicity is much harder than complexity!
_"Simplicity is the ultimate sophistication. L. da Vinci."_
---
## Enemy of the state
* The no. 1 cause of complexity is *state*, i.e. variables
* Every mutable variable is stateful
* For every bit of state in your program, there are two tests: A program with
100 integer variables has $2^{3200}$ distinct states.
<img src="/complexity/img/alfred_e_neuman_1.jpg" style="width: 30%;"/>
---
## Local variables are stateful too
$f(x) = (n+1)(n+2)$
```{Python}
def f(x):
x = x + 1
y = x + 1
return x * y
```
$f(x) = (n+1)^2$
```{Python}
def f(x):
y = x + 1
x = x + 1
return x * y
```
---
## Referential transparency
```{Python}
def f(x):
x1 = x + 1
y1 = x1 + 1
return x1 * y1
```
Haskell example:
```{Haskell}
f :: (Num a) => a -> a
f x = x' * y'
where
y' = x' + 1
x' = x + 1
```
---
## Me, preparing to mutate some state
<img src="/complexity/img/heavy_diver1.jpg" style="width: 50%;"/>
---
## State of affairs
* Information vs. place
* PLOP: New information replaces old
* Facts don't change because we ignore them
* PLOP grew out of tiny computer memories
* Information is simple, don't ruin it
* We use values on the wire, why not in our codes?
---
## The value of values
* Values are immutable
* Values can be shared
* Values are easy to fabricate
* Values are language agnostic
* Values aggregate. Objects don't (usually)
* Values are stable: reproducible results
* Values don't *need* methods
* Values have representation, *not* implementation
---
## Concurrency
* Concurrency in imperative code is very hard
* You are totally lost in the dark without a good thread checker
* In a pure, immutable world concurrency is nearly trivial!
<img src="/complexity/img/floor-loom-diagram.jpg" style="width: 55%;"/>
---
## Composition
* Composition enables us to build complex behavior from simple components
* We can reason about the components, and we can reason about the composite
* Composition is key to managing complexity
* Modularity does not imply simplicity, but is enabled by it
<img src="/complexity/img/knit_vs_lego.jpg" style="width: 100%;"/>
---
## The proof of the pudding
* Can you move sub-systems?
* To another language?
* To another machine?
* Without changing much?
<img src="/complexity/img/under_the_hood.png" style="width: 50%;"/>
---
## How about object-oriented programming?
* Encapsulation: Adding implementation to information?
* Complects both state and information
* OOP lures us to implement with little, moving machines
> 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
---
## A base class
```{Python}
class A(object):
def __init__(self):
self.a = 1
def addone(self, x):
self.a += 1
return x + self.a
def inc(self, x):
return x + self.a
```
---
## Hidden state, crouching dragon
```{Python}
class B(A):
def __init__(self):
super(B,self).__init__()
def np1np2(self, x):
a = self.addone(x)
b = self.inc(x)
return a * b
b = B()
print b.np1np2(5)
```
---
## It all started really simple
<img src="/complexity/img/complex-machine.jpg" style="width: 55%;"/>
---
## Code quality
Every bug has passed both the type checker and the test suite.
<img src="/complexity/img/wtfs_per_minute_thumb.jpg" style="width: 45%;"/>
</textarea>
<script src="/complexity/refreeze/js/remark-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
var hljs = remark.highlighter.engine;
</script>
<script src="/complexity/refreeze/js/high.js" type="text/javascript"></script>
<script type="text/javascript">
var slideshow = remark.create({
highlightStyle: 'sunburst',
highlightLanguage: 'remark'
}) ;
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-44561333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>