23
N J S O D E . revolution with a dynamic scopE Dmytrii Shchadei @ Metrofun

How to achive dynamic scoping in Node.js

Embed Size (px)

Citation preview

N

JS

O DE

.

revolutionwith a dynamic scopE

Dmytrii Shchadei @Metrofun

Story BeginsBACK in …

“In theory there is no difference between theory and practice.

In practice there is”.

NODE.JS RE:LOADED

“this” is a keyword, not a variableJavascript has a lexical scoping

Javascript SCOPEgotchas

DYNAMIC SCOPE

DYNAMIC SCOPE

DYNAMIC SCOPE

DYNAMIC SCOPE

DYNAMIC SCOPEIntentionally simplE

embedding is not implemented!!

do it yourself and have fun :)

DYNAMIC SCOPE

HOMEWORKhttp://nodejs.org/api/domain.htmlhttp://www.slideshare.net/domenicdenicola/domains-20010482

PROFIT *

Better isomorphic frameworks

Loose coupling

Per-request caching

CAVEATS

** Domains have performance hit ( only ~5% rps reduce )

* Some libraries doesn’t support domains ( use domain.bind )

THANK you!

Dmytrii Shchadei @Metrofun