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
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
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 Node?
Ask Yourselves
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?”
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
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….
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 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?
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge10
 Example 1: user login
 [over to the IDE]
Code example 1
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
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge12
 Example 2: processing data
 [over to the IDE]
Code example 2
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
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
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
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/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
www.RivalIQ.comDigital Marketing Analytics with a Competitive Edge
Digital Marketing Analytics with a Competitive Edge
Thank You

Streamline.js and Node

  • 1.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge Digital Marketing Analytics with a Competitive Edge Seth Pollack Async Node Programming with Streamline.js February 17, 2015
  • 2.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge3  Why do you love Node? Ask Yourselves
  • 4.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge4  Why do you love Node?  What don’t you like about Node? Ask Yourselves
  • 5.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge7 My Path to Enlightenment Node Rocks! Control flow, ouch Async lib! Still painful… Streamline! Great Success!!! Sadness….
  • 8.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge8 Imagine If…
  • 9.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge10  Example 1: user login  [over to the IDE] Code example 1
  • 11.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge12  Example 2: processing data  [over to the IDE] Code example 2
  • 13.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge16  Give Streamline a try! Conclusion
  • 17.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge17 Questions
  • 18.
    www.RivalIQ.comDigital Marketing Analyticswith 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.
    www.RivalIQ.comDigital Marketing Analyticswith a Competitive Edge Digital Marketing Analytics with a Competitive Edge Thank You