Why code in Node.js
often get rejected by
SoundCloud
Phil Calçado - SoundCloud
@pcalcado
http://philcalcado.com
Tuesday, O...
2011: Phil zieht nach Berlin
Tuesday, October 1, 13
Tuesday, October 1, 13
~ 200 million users / month
> 11 hours of audio
uploaded every minute
Tuesday, October 1, 13
Tuesday, October 1, 13
http://bit.ly/15DToNK
hiring @ SoundCloud
Tuesday, October 1, 13
Phone
Code Review
Interviews
Offer
Tuesday, October 1, 13
Phone
Code Review
Interviews
Offer
Tuesday, October 1, 13
challenge until late 2012
Tuesday, October 1, 13
you can choose any language.
0
10
20
30
40
Ruby Java JavaScript (Node.js) C Clojure Scala
% of submissions ~2011-2012
Tues...
you can choose any language.
0
10
20
30
40
Ruby Java JavaScript (Node.js) C Clojure Scala
rejected before interview invite...
new challenge
Tuesday, October 1, 13
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...
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...
you can choose any language.
0
7.5
15
22.5
30
Ruby Java JavaScript (Node.js) Go Clojure Scala
rejected before interview in...
you can choose any language.
0
7.5
15
22.5
30
Ruby Java JavaScript (Node.js) Go Clojure Scala
rejected before interview in...
http://bit.ly/J1aLNn
don’t get me wrong
we are all hipsters
Tuesday, October 1, 13
Tuesday, October 1, 13
Not OO, not Functional...
Just (bad) Procedural code.
Tuesday, October 1, 13
http://bit.ly/JiECRp
Tuesday, October 1, 13
we don’t need this complicated stuff.
this is not java, you know.
Tuesday, October 1, 13
http://bit.ly/JiFSnq
so how do we structure our app?
Tuesday, October 1, 13
what to use?
(decent)
procedures?
Tuesday, October 1, 13
Tuesday, October 1, 13
Tuesday, October 1, 13
what to use?
objects?
Tuesday, October 1, 13
Tuesday, October 1, 13
what to use?
...functions?
Tuesday, October 1, 13
http://bit.ly/JFbZt8
Tuesday, October 1, 13
http://bit.ly/JFbZt8
“SICP and some of the Sussman & Steele "Lambda
the ..." papers made a big impression on me years
befo...
http://bit.ly/JiEQYM
Tuesday, October 1, 13
Tuesday, October 1, 13
Tuesday, October 1, 13
Tuesday, October 1, 13
Tuesday, October 1, 13
Tuesday, October 1, 13
http://bit.ly/JiF7ef
going old school
Tuesday, October 1, 13
e.g. passing functions around
Tuesday, October 1, 13
we see a lot of this
Tuesday, October 1, 13
1st, we extract what is common
Tuesday, October 1, 13
then we refactor our functions
Tuesday, October 1, 13
and we send them as arguments
Tuesday, October 1, 13
e.g. closures not only for objects
Tuesday, October 1, 13
we see a lot of this
Tuesday, October 1, 13
we can keep writeComment as it is
Tuesday, October 1, 13
and we add a function with two closures
Tuesday, October 1, 13
and we add a function with two closures
immutable
Tuesday, October 1, 13
and we add a function with two closures
immutablemutable
Tuesday, October 1, 13
now we don’t need to pass in the kitchen sink
Tuesday, October 1, 13
e.g. functions all the way down
Tuesday, October 1, 13
we see a lot of this
Tuesday, October 1, 13
first we extract common protocol
Tuesday, October 1, 13
then we clean up our functions
Tuesday, October 1, 13
then we use them.
Tuesday, October 1, 13
then we use them. redundant?
Tuesday, October 1, 13
http://bit.ly/JiETnd
Tuesday, October 1, 13
our “framework”:
1 - Extract protocol in
“combinators”
2 - Keep mutable state in
closures
Tuesday, October 1, 13
no scary monads required
Tuesday, October 1, 13
there is plenty to learn from
Tuesday, October 1, 13
in the javascript community too
Tuesday, October 1, 13
phil calçado
http://philcalcado.com
@pcalcado
www.soundcloud.com
Tuesday, October 1, 13
How to Design Programs - http://bit.ly/K0BfrL
Structure and Interpretation of Computer
Programs - http://bit.ly/K0BjYm
The...
Upcoming SlideShare
Loading in...5
×

Why code in Node.js often get rejected by SoundCloud

5,175

Published on

From: http://gotocon.com/aarhus-2013/presentation/Why%20code%20in%20Node.js%20often%20gets%20rejected%20by%20SoundCloud

At SoundCloud we ask candidates to send us some code before inviting them in for interviews. Candidates can use whatever language they want, and over the past years we saw a massive rise on the number of submissions using server-side JavaScript. Unfortunately, too many submissions are asynchronous blobs of procedural code.

JavaScript is a fairly functional language, and over the past decades Functional Programming developed interesting solutions for many of the problems we face when writing Node.js and regular JavaScript. Let's talk about how to leverage good old Functional Programming techniques to make code less coupled and more readable!

Published in: Technology

Why code in Node.js often get rejected by SoundCloud

  1. 1. Why code in Node.js often get rejected by SoundCloud Phil Calçado - SoundCloud @pcalcado http://philcalcado.com Tuesday, October 1, 13
  2. 2. 2011: Phil zieht nach Berlin Tuesday, October 1, 13
  3. 3. Tuesday, October 1, 13
  4. 4. ~ 200 million users / month > 11 hours of audio uploaded every minute Tuesday, October 1, 13
  5. 5. Tuesday, October 1, 13
  6. 6. http://bit.ly/15DToNK hiring @ SoundCloud Tuesday, October 1, 13
  7. 7. Phone Code Review Interviews Offer Tuesday, October 1, 13
  8. 8. Phone Code Review Interviews Offer Tuesday, October 1, 13
  9. 9. challenge until late 2012 Tuesday, October 1, 13
  10. 10. 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
  11. 11. 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
  12. 12. new challenge Tuesday, October 1, 13
  13. 13. 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
  14. 14. 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
  15. 15. 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
  16. 16. 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
  17. 17. http://bit.ly/J1aLNn don’t get me wrong we are all hipsters Tuesday, October 1, 13
  18. 18. Tuesday, October 1, 13
  19. 19. Not OO, not Functional... Just (bad) Procedural code. Tuesday, October 1, 13
  20. 20. http://bit.ly/JiECRp Tuesday, October 1, 13
  21. 21. we don’t need this complicated stuff. this is not java, you know. Tuesday, October 1, 13
  22. 22. http://bit.ly/JiFSnq so how do we structure our app? Tuesday, October 1, 13
  23. 23. what to use? (decent) procedures? Tuesday, October 1, 13
  24. 24. Tuesday, October 1, 13
  25. 25. Tuesday, October 1, 13
  26. 26. what to use? objects? Tuesday, October 1, 13
  27. 27. Tuesday, October 1, 13
  28. 28. what to use? ...functions? Tuesday, October 1, 13
  29. 29. http://bit.ly/JFbZt8 Tuesday, October 1, 13
  30. 30. 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
  31. 31. http://bit.ly/JiEQYM Tuesday, October 1, 13
  32. 32. Tuesday, October 1, 13
  33. 33. Tuesday, October 1, 13
  34. 34. Tuesday, October 1, 13
  35. 35. Tuesday, October 1, 13
  36. 36. Tuesday, October 1, 13
  37. 37. http://bit.ly/JiF7ef going old school Tuesday, October 1, 13
  38. 38. e.g. passing functions around Tuesday, October 1, 13
  39. 39. we see a lot of this Tuesday, October 1, 13
  40. 40. 1st, we extract what is common Tuesday, October 1, 13
  41. 41. then we refactor our functions Tuesday, October 1, 13
  42. 42. and we send them as arguments Tuesday, October 1, 13
  43. 43. e.g. closures not only for objects Tuesday, October 1, 13
  44. 44. we see a lot of this Tuesday, October 1, 13
  45. 45. we can keep writeComment as it is Tuesday, October 1, 13
  46. 46. and we add a function with two closures Tuesday, October 1, 13
  47. 47. and we add a function with two closures immutable Tuesday, October 1, 13
  48. 48. and we add a function with two closures immutablemutable Tuesday, October 1, 13
  49. 49. now we don’t need to pass in the kitchen sink Tuesday, October 1, 13
  50. 50. e.g. functions all the way down Tuesday, October 1, 13
  51. 51. we see a lot of this Tuesday, October 1, 13
  52. 52. first we extract common protocol Tuesday, October 1, 13
  53. 53. then we clean up our functions Tuesday, October 1, 13
  54. 54. then we use them. Tuesday, October 1, 13
  55. 55. then we use them. redundant? Tuesday, October 1, 13
  56. 56. http://bit.ly/JiETnd Tuesday, October 1, 13
  57. 57. our “framework”: 1 - Extract protocol in “combinators” 2 - Keep mutable state in closures Tuesday, October 1, 13
  58. 58. no scary monads required Tuesday, October 1, 13
  59. 59. there is plenty to learn from Tuesday, October 1, 13
  60. 60. in the javascript community too Tuesday, October 1, 13
  61. 61. phil calçado http://philcalcado.com @pcalcado www.soundcloud.com Tuesday, October 1, 13
  62. 62. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×