why code in node.js often get rejected by soundcloud

Post on 08-Sep-2014

4.030 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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!

TRANSCRIPT

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

Tuesday, October 1, 13

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

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 ~1 year

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 ~1 year

Tuesday, October 1, 13

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

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

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/JiECRpTuesday, 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/JFbZt8Tuesday, October 1, 13

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

http://bit.ly/JiEQYMTuesday, 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/JiETndTuesday, 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 fromTuesday, October 1, 13

in the javascript community tooTuesday, October 1, 13

phil calçado

http://philcalcado.com@pcalcado

www.soundcloud.com

Tuesday, October 1, 13

How to Design Programs - http://bit.ly/K0BfrLStructure 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

top related