Slide 1

Slide 1 text

Why code in Node.js often get rejected by SoundCloud Phil Calçado - SoundCloud @pcalcado http://philcalcado.com Tuesday, October 1, 13

Slide 2

Slide 2 text

2011: Phil zieht nach Berlin Tuesday, October 1, 13

Slide 3

Slide 3 text

Tuesday, October 1, 13

Slide 4

Slide 4 text

~ 200 million users / month > 11 hours of audio uploaded every minute Tuesday, October 1, 13

Slide 5

Slide 5 text

Tuesday, October 1, 13

Slide 6

Slide 6 text

http://bit.ly/15DToNK hiring @ SoundCloud Tuesday, October 1, 13

Slide 7

Slide 7 text

Phone Code Review Interviews Offer Tuesday, October 1, 13

Slide 8

Slide 8 text

Phone Code Review Interviews Offer Tuesday, October 1, 13

Slide 9

Slide 9 text

challenge until late 2012 Tuesday, October 1, 13

Slide 10

Slide 10 text

you can choose any language. 0 10 20 30 40 Ruby Java JavaScript (Node.js) C Clojure Scala % of submissions ~2011-2012 Tuesday, October 1, 13

Slide 11

Slide 11 text

you can choose any language. 0 10 20 30 40 Ruby Java JavaScript (Node.js) C Clojure Scala rejected before interview invited for inverview Tuesday, October 1, 13

Slide 12

Slide 12 text

new challenge Tuesday, October 1, 13

Slide 13

Slide 13 text

you can choose any language. 0 7.5 15 22.5 30 Ruby Java JavaScript (Node.js) Go Clojure Scala % of submissions on the past ~1 year Tuesday, October 1, 13

Slide 14

Slide 14 text

you can choose any language. 0 7.5 15 22.5 30 Ruby Java JavaScript (Node.js) Go Clojure Scala % of submissions on the past ~1 year Tuesday, October 1, 13

Slide 15

Slide 15 text

you can choose any language. 0 7.5 15 22.5 30 Ruby Java JavaScript (Node.js) Go Clojure Scala rejected before interview invited for inverview Tuesday, October 1, 13

Slide 16

Slide 16 text

you can choose any language. 0 7.5 15 22.5 30 Ruby Java JavaScript (Node.js) Go Clojure Scala rejected before interview invited for inverview WTF? Tuesday, October 1, 13

Slide 17

Slide 17 text

http://bit.ly/J1aLNn don’t get me wrong we are all hipsters Tuesday, October 1, 13

Slide 18

Slide 18 text

Tuesday, October 1, 13

Slide 19

Slide 19 text

Not OO, not Functional... Just (bad) Procedural code. Tuesday, October 1, 13

Slide 20

Slide 20 text

http://bit.ly/JiECRp Tuesday, October 1, 13

Slide 21

Slide 21 text

we don’t need this complicated stuff. this is not java, you know. Tuesday, October 1, 13

Slide 22

Slide 22 text

http://bit.ly/JiFSnq so how do we structure our app? Tuesday, October 1, 13

Slide 23

Slide 23 text

what to use? (decent) procedures? Tuesday, October 1, 13

Slide 24

Slide 24 text

Tuesday, October 1, 13

Slide 25

Slide 25 text

Tuesday, October 1, 13

Slide 26

Slide 26 text

what to use? objects? Tuesday, October 1, 13

Slide 27

Slide 27 text

Tuesday, October 1, 13

Slide 28

Slide 28 text

what to use? ...functions? Tuesday, October 1, 13

Slide 29

Slide 29 text

http://bit.ly/JFbZt8 Tuesday, October 1, 13

Slide 30

Slide 30 text

http://bit.ly/JFbZt8 “SICP and some of the Sussman & Steele "Lambda the ..." papers made a big impression on me years before, although I did not understand their full meaning then. Remember, I was recruited to "do Scheme" [...] My interest in languages such as Self informed a subversive agenda [...]. Likewise with first-class functions, which were inspired by Scheme [...]” Tuesday, October 1, 13

Slide 31

Slide 31 text

http://bit.ly/JiEQYM Tuesday, October 1, 13

Slide 32

Slide 32 text

Tuesday, October 1, 13

Slide 33

Slide 33 text

Tuesday, October 1, 13

Slide 34

Slide 34 text

Tuesday, October 1, 13

Slide 35

Slide 35 text

Tuesday, October 1, 13

Slide 36

Slide 36 text

Tuesday, October 1, 13

Slide 37

Slide 37 text

http://bit.ly/JiF7ef going old school Tuesday, October 1, 13

Slide 38

Slide 38 text

e.g. passing functions around Tuesday, October 1, 13

Slide 39

Slide 39 text

we see a lot of this Tuesday, October 1, 13

Slide 40

Slide 40 text

1st, we extract what is common Tuesday, October 1, 13

Slide 41

Slide 41 text

then we refactor our functions Tuesday, October 1, 13

Slide 42

Slide 42 text

and we send them as arguments Tuesday, October 1, 13

Slide 43

Slide 43 text

e.g. closures not only for objects Tuesday, October 1, 13

Slide 44

Slide 44 text

we see a lot of this Tuesday, October 1, 13

Slide 45

Slide 45 text

we can keep writeComment as it is Tuesday, October 1, 13

Slide 46

Slide 46 text

and we add a function with two closures Tuesday, October 1, 13

Slide 47

Slide 47 text

and we add a function with two closures immutable Tuesday, October 1, 13

Slide 48

Slide 48 text

and we add a function with two closures immutable mutable Tuesday, October 1, 13

Slide 49

Slide 49 text

now we don’t need to pass in the kitchen sink Tuesday, October 1, 13

Slide 50

Slide 50 text

e.g. functions all the way down Tuesday, October 1, 13

Slide 51

Slide 51 text

we see a lot of this Tuesday, October 1, 13

Slide 52

Slide 52 text

first we extract common protocol Tuesday, October 1, 13

Slide 53

Slide 53 text

then we clean up our functions Tuesday, October 1, 13

Slide 54

Slide 54 text

then we use them. Tuesday, October 1, 13

Slide 55

Slide 55 text

then we use them. redundant? Tuesday, October 1, 13

Slide 56

Slide 56 text

http://bit.ly/JiETnd Tuesday, October 1, 13

Slide 57

Slide 57 text

our “framework”: 1 - Extract protocol in “combinators” 2 - Keep mutable state in closures Tuesday, October 1, 13

Slide 58

Slide 58 text

no scary monads required Tuesday, October 1, 13

Slide 59

Slide 59 text

there is plenty to learn from Tuesday, October 1, 13

Slide 60

Slide 60 text

in the javascript community too Tuesday, October 1, 13

Slide 61

Slide 61 text

phil calçado http://philcalcado.com @pcalcado www.soundcloud.com Tuesday, October 1, 13

Slide 62

Slide 62 text

How to Design Programs - http://bit.ly/K0BfrL Structure and Interpretation of Computer Programs - http://bit.ly/K0BjYm The Art of the Metaobject Protocol http://amzn.to/K0BqU1 Purely Functional Data Structures http://amzn.to/JFn4KG Let Over Lambda - http://amzn.to/IMMkNO An Introduction to Lambda Calculi for Computer Scientists - http://amzn.to/IX8d1B All drawings are available as t-shirts from the awesome Diesel Sweeties - http://dieselsweeties.com/ Tuesday, October 1, 13