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.
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge
Digital Marketing Analytics with a Competitive Edge
Set...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge2
 if you use Node, you’d be nuts not to evaluate Strea...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge3
 Why do you love Node?
Ask Yourselves
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge4
 Why do you love Node?
 What don’t you like about No...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge5
 Key decision point for me is productivity
 Node’s s...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge6
 Control flow with callbacks is clunky
 Error handli...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge7
My Path to Enlightenment
Node Rocks!
Control flow, ouc...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge8
Imagine If…
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge9
 Streamline lets you use standard control flow primit...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge10
 Example 1: user login
 [over to the IDE]
Code exam...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge11
 Simple control flow
 Unified error handling
 No n...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge12
 Example 2: processing data
 [over to the IDE]
Code...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge13
 Streamline is its own language, extremely similar t...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge14
 Be sure to name your files *._js
 You’ll have to u...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge15
 Some runtime overhead (very small slowdown, a bit m...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge16
 Give Streamline a try!
Conclusion
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge17
Questions
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge18
 Streamline repo: https://github.com/Sage/streamline...
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge
Digital Marketing Analytics with a Competitive Edge
Tha...
Upcoming SlideShare
Loading in …5
×

Streamline.js and Node

1,324 views

Published on

Asynchronous Programming in Node with Streamline.js: how to make control flow and error handling in Node much more sane

Published in: Software
  • Be the first to comment

Streamline.js and Node

  1. 1. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge Digital Marketing Analytics with a Competitive Edge Seth Pollack Async Node Programming with Streamline.js February 17, 2015
  2. 2. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge2  if you use Node, you’d be nuts not to evaluate Streamline  codebase ~1/3 smaller  significant overall productivity gain (1.5x?)  more fun! My Pitch: Node + Streamline
  3. 3. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge3  Why do you love Node? Ask Yourselves
  4. 4. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge4  Why do you love Node?  What don’t you like about Node? Ask Yourselves
  5. 5. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge5  Key decision point for me is productivity  Node’s simple concurrency model is a win  JavaScript (expressiveness; one language everywhere) is a win My “Why Node?”
  6. 6. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge6  Control flow with callbacks is clunky  Error handling is complex  Correct callback behavior is easy to get wrong Node-body’s Perfect
  7. 7. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge7 My Path to Enlightenment Node Rocks! Control flow, ouch Async lib! Still painful… Streamline! Great Success!!! Sadness….
  8. 8. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge8 Imagine If…
  9. 9. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge9  Streamline lets you use standard control flow primitives for async work  You write your control flow as if async functions were sync, and pass a special token (“_”) as the callback parameter  Success results are presented as the return value of the function; error response or exceptions are presented as a thrown exception What is Streamline?
  10. 10. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge10  Example 1: user login  [over to the IDE] Code example 1
  11. 11. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge11  Simple control flow  Unified error handling  No need for manual callback invocation  PLUS…  JS tools work great  Better debugging  Logical stack trace  No wrappers  Transparent inter-op Streamline FTW
  12. 12. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge12  Example 2: processing data  [over to the IDE] Code example 2
  13. 13. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge13  Streamline is its own language, extremely similar to JavaScript  Streamline source JIT-ed into native JavaScript  Can target various back-ends (callbacks, fibers, generators)  Streamline yields and resumes on your behalf  Under the covers, the Node event loop continues to run; no blocking or busy-waiting occurs Under the Hood
  14. 14. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge14  Be sure to name your files *._js  You’ll have to use a different variable name than “_” for the underscore library  The magic underscore token isn’t a function, it’s a keyword  It’s important to understand that the underscore means yield, and when execution hits it, the event loop may run  Fibers backend to Streamline has best combo of performance and developer experience  Many more goodies exist in Streamline that I haven’t covered here Tips & Tricks
  15. 15. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge15  Some runtime overhead (very small slowdown, a bit more memory usage) • Extra work is only on async calls, we haven’t found it to be material  Since Streamline needs to keep up to date with JavaScript language enhancements (current thinking is that new ES6 language features to be handled by integrating 6to5)  With ES7 async/await, we may not need Streamline anymore. I can’t wait ;-) Streamline Drawbacks
  16. 16. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge16  Give Streamline a try! Conclusion
  17. 17. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge17 Questions
  18. 18. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge18  Streamline repo: https://github.com/Sage/streamlinejs  Streamline FAQ: https://github.com/Sage/streamlinejs/blob/master/FAQ.md  Streamline mailing list: https://groups.google.com/forum/#!forum/streamlinejs  My blog post on Streamline: http://blog.rivaliq.com/develop-double- time-node-plus-streamline/  Streamline perf tests: https://gist.github.com/bjouhier/5554200  Bruno Jouhier’s blog: https://bjouhier.wordpress.com/ References
  19. 19. www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge Digital Marketing Analytics with a Competitive Edge Thank You

×