Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How to achive dynamic scoping in Node.js

1,493 views

Published on

How to achive dynamic scoping in javascript on server side and start handling requests in the same manner, as we did in PHP. Even further, using dynamic scoping you can have a reference to the actual HTTP request instance you currently handling, without any tedious passing of params, the same way we do on client side – we simply have our page in global context. You can even have per-request caching, by simply creating a variable in a dynamic scope of a HTTP request.

And there plenty of different applications of dynamic scoping in Node.js, like more robust isomorphic frameworks like Meteor, but without any performance hit and Node.js on server side!

Published in: Technology
  • Be the first to comment

How to achive dynamic scoping in Node.js

  1. 1. N JS E. O D revolution with a dynamic scopE Dmytrii Shchadei @Metrofun
  2. 2. Story Begins BACK in …
  3. 3. KUQOQTRJKUOKUDKLGEVKXGOQTRJKUO # $ % : ;
  4. 4. KUQOQTRJKUOKUDKLGEVKXGOQTRJKUO FQEWOGPVEQQMKG NQECVKQPRCVJPCOG UGV+OOGFKCVG PGZV6KEM TGSWGUVJGCFGTUEQQMKG TGSWGUVWTN DTQYUGT PQFGLU
  5. 5. “In theory there is no difference between theory and practice. In practice there is”.
  6. 6. KUQOQTRJKUOKUDKLGEVKXGOQTRJKUO FQEWOGPVEQQMKG NQECVKQPRCVJPCOG UGV+OOGFKCVG PGZV6KEM TGSWGUVJGCFGTUEQQMKG TGSWGUVWTN DTQYUGT PQFGLU
  7. 7. KUQOQTRJKUOKUDKLGEVKXGOQTRJKUO FQEWOGPVEQQMKG NQECVKQPRCVJPCOG UGV+OOGFKCVG PGZV6KEM TGSWGUVJGCFGTUEQQMKG TGSWGUVJGCFGTUEQQMKG TGSWGUVJGCFGTUEQQMKG TGSWGUVWTN TGSWGUVWTN TGSWGUVWTN DTQYUGT PQFGLU
  8. 8. KUQOQTRJKUOKUDKLGEVKXGOQTRJKUO FQEWOGPVEQQMKG NQECVKQPRCVJPCOG UGV+OOGFKCVG PGZV6KEM TGSWGUVJGCFGTUEQQMKG TGSWGUVJGCFGTUEQQMKG TGSWGUVJGCFGTUEQQMKG TGSWGUVWTN TGSWGUVWTN TGSWGUVWTN DTQYUGT PQFGLU
  9. 9. +P0QFGLU ł 0QRCIGKPCNGZKECNUEQRG 0GGFVQOCPWCNN[INWG CNN[QWTEQFGYKVJTGHGTGPEGUVQTGSTGU ECNNDCEMUOKFFNGYCTGGVE ł -G[FKHHGTGPEGU
  10. 10. NODE.JS RE:LOADED
  11. 11. Javascript SCOPE gotchas Javascript has a lexical scoping “this” is a keyword, not a variable
  12. 12. DYNAMIC SCOPE
  13. 13. DYNAMIC SCOPE
  14. 14. DYNAMIC SCOPE
  15. 15. DYNAMIC SCOPE
  16. 16. DYNAMIC SCOPE Intentionally simplE embedding is not implemented!! do it yourself and have fun :)
  17. 17. DYNAMIC SCOPE
  18. 18. HOMEWORK http://nodejs.org/api/domain.html http://www.slideshare.net/domenicdenicola/domains-20010482 0QFGLUQOCKPU
  19. 19. PROFIT * Loose coupling Better isomorphic frameworks Per-request caching
  20. 20. C AVE AT S * Some libraries doesn’t suppor t domains ( use domain.bind ) ** Domains have per formance hit ( only ~5% rps reduce )
  21. 21. THANK you! Dmytrii Shchadei @Metrofun

×