USE PROMISES,
FUTURES AND SOME
FUNCTIONAL
PROGRAMING STUFF
WITHOUT BEING A
MATH NERD.
@WAXZCE
TAKEOFF CONFERENCE
WHO AM I ?
CEO at www.clever-cloud.com
Polyglot developer

@waxzce on twitter
KEEP YOUR APPS ONLINE. MADE WITH
NODE.JS, SCALA, JAVA, RUBY, PHP,
PYTHON, GO…
And learn a lot of things about your code, a...
I’M NOT A MATH NERD
NODE.JS MAIN PROBLEM
SO, TRY TO KEEP IT ALIVE AND
MINIMIZE ERROR EXPOSURE
ON THE OTHER HAND:
THE CALLBACK SOUP
EXAMPLE :
DATABASE CONNECTION
REALLY ?
ALL DB INTERACTION IN ONE
CALLBACK ?
REALLY ?
UNCATCHED EXCEPTIONS BUBBLE TO
THE TOP AND KILL THE APP ?
REALLY ?
IF/ELSE/UNDEFINED ERROR
TREATMENT ?
DB DRIVER
SHOULDN’T
DRIVE YOUR
CODE
ARCHITECTURE,
THEORICALLY
SO, WE HAVE A PROBLEM : HOW TO USE
A VALUE WE DON’T HAVE YET, AND USE
IT IN THE FUTURE?
CHANGE YOUR MIND
HOW DO YOU INTERACT WITH
DATA NOW?

Get data
from DB
and/or
WS

• Wait for it
• Possibly
blocking
i/o

Da...
EXAMPLE
YOU WANT TO RETURN SOMETHING !
THE OTHER PROBLEM :

YOU MIX I/O
HANDLING WITH
YOUR BUSINESS
PROCESSES
SPLIT
Business
process and
valued
computing

I/O management
and other
“computing stuff”
CHANGE YOUR MIND
HOW CAN WE DO IT?

Get data
from DB
and/or
WS

• Give all the
“recipes” about
how to deal
with this data
...
WORK ON
FUTURE DATA
YOU HAVE
PROMISED TO
YOUR CODE
;-)
EXAMPLE
SIMPLE PROMISE MAP
EXAMPLE
SIMPLE PROMISE MAP
MORE IMPORTANT : YOU CAN
RETURN A DATA YOU DON’T
HAVE AT THE MOMENT
NO MORE DEALING WITH BLOCKING I/O
IN YOUR BUSINESS CODE
DEALING WITH
MULTIPLE FUTURE DATA
GET ALL YOU NEED TO WORK
And stop using boolean counter for event « ready »….
REAL WORLD EXAMPLE
BUILT IN ERROR
MANAGEMENT
SIMPLE WAY : YOU CAN
RETURN SOMETING :-)
PROMISES
WILL MANAGE
TEMPORALITY
PROBLEMS
AND I/O IN A
SIMPLE WAY
NOT TOO COMPLICATED ?
WE’VE JUST DEALT
WITH FUNCTORS,
MONADS,
SEMIGROUPS… ALL
OF THESE
ALGEBRAIC
STRUCTURES
MATH WORDS, NOT SO COMPLICATED,
JUST MADE TO SHARE CONCEPTS
BETWEEN PEOPLE :-)
FUNCTIONAL
PROGRAMING IS NOT
A LANGUAGE : IT’S
THE ABILITY TO USE
ALGEBRAIC
STRUCTURES AND
MATH TOOLS IN YOUR
CODE
SO YOU ...
FUNCTIONAL JAVASCRIPT : FANTASY
LAND SPECIFICATION
Made by the awesome Brian McKenna - @puffnfresh
DEMO MADE WITH PACTA
IMPLEMENTATION
Node.js + browser implementation, totally agnostic javascript,
Fantasy Land compatible...
TRY IT YOU WILL
BE A BADASS !
THANK YOU !
ANY QUESTIONS ?
I’m on twitter : @waxzce

I give you a www.clevercloud.com gift :
takeoff2014
Upcoming SlideShare
Loading in …5
×

Use Promises, Futures and some functional programing stuff without being a math nerd

3,655 views

Published on

talk given to the take off conference 2014 about promises and futures in javascript world https://www.youtube.com/watch?v=2OjHNe9Akaw

Published in: Technology, Education
3 Comments
3 Likes
Statistics
Notes
No Downloads
Views
Total views
3,655
On SlideShare
0
From Embeds
0
Number of Embeds
166
Actions
Shares
0
Downloads
11
Comments
3
Likes
3
Embeds 0
No embeds

No notes for slide

Use Promises, Futures and some functional programing stuff without being a math nerd

  1. 1. USE PROMISES, FUTURES AND SOME FUNCTIONAL PROGRAMING STUFF WITHOUT BEING A MATH NERD. @WAXZCE TAKEOFF CONFERENCE
  2. 2. WHO AM I ? CEO at www.clever-cloud.com Polyglot developer @waxzce on twitter
  3. 3. KEEP YOUR APPS ONLINE. MADE WITH NODE.JS, SCALA, JAVA, RUBY, PHP, PYTHON, GO… And learn a lot of things about your code, apps, and good/bad design…
  4. 4. I’M NOT A MATH NERD
  5. 5. NODE.JS MAIN PROBLEM
  6. 6. SO, TRY TO KEEP IT ALIVE AND MINIMIZE ERROR EXPOSURE
  7. 7. ON THE OTHER HAND: THE CALLBACK SOUP
  8. 8. EXAMPLE : DATABASE CONNECTION
  9. 9. REALLY ? ALL DB INTERACTION IN ONE CALLBACK ?
  10. 10. REALLY ? UNCATCHED EXCEPTIONS BUBBLE TO THE TOP AND KILL THE APP ?
  11. 11. REALLY ? IF/ELSE/UNDEFINED ERROR TREATMENT ?
  12. 12. DB DRIVER SHOULDN’T DRIVE YOUR CODE ARCHITECTURE, THEORICALLY
  13. 13. SO, WE HAVE A PROBLEM : HOW TO USE A VALUE WE DON’T HAVE YET, AND USE IT IN THE FUTURE?
  14. 14. CHANGE YOUR MIND HOW DO YOU INTERACT WITH DATA NOW? Get data from DB and/or WS • Wait for it • Possibly blocking i/o Data is here • Act on it • Data treatment
  15. 15. EXAMPLE
  16. 16. YOU WANT TO RETURN SOMETHING !
  17. 17. THE OTHER PROBLEM : YOU MIX I/O HANDLING WITH YOUR BUSINESS PROCESSES
  18. 18. SPLIT Business process and valued computing I/O management and other “computing stuff”
  19. 19. CHANGE YOUR MIND HOW CAN WE DO IT? Get data from DB and/or WS • Give all the “recipes” about how to deal with this data • You only describe how to manage data you get That’s all
  20. 20. WORK ON FUTURE DATA YOU HAVE PROMISED TO YOUR CODE ;-)
  21. 21. EXAMPLE SIMPLE PROMISE MAP
  22. 22. EXAMPLE SIMPLE PROMISE MAP
  23. 23. MORE IMPORTANT : YOU CAN RETURN A DATA YOU DON’T HAVE AT THE MOMENT
  24. 24. NO MORE DEALING WITH BLOCKING I/O IN YOUR BUSINESS CODE
  25. 25. DEALING WITH MULTIPLE FUTURE DATA
  26. 26. GET ALL YOU NEED TO WORK And stop using boolean counter for event « ready »….
  27. 27. REAL WORLD EXAMPLE
  28. 28. BUILT IN ERROR MANAGEMENT
  29. 29. SIMPLE WAY : YOU CAN RETURN SOMETING :-)
  30. 30. PROMISES WILL MANAGE TEMPORALITY PROBLEMS AND I/O IN A SIMPLE WAY
  31. 31. NOT TOO COMPLICATED ?
  32. 32. WE’VE JUST DEALT WITH FUNCTORS, MONADS, SEMIGROUPS… ALL OF THESE ALGEBRAIC STRUCTURES
  33. 33. MATH WORDS, NOT SO COMPLICATED, JUST MADE TO SHARE CONCEPTS BETWEEN PEOPLE :-)
  34. 34. FUNCTIONAL PROGRAMING IS NOT A LANGUAGE : IT’S THE ABILITY TO USE ALGEBRAIC STRUCTURES AND MATH TOOLS IN YOUR CODE SO YOU CAN REUSE IT WHERE YOU WANT…
  35. 35. FUNCTIONAL JAVASCRIPT : FANTASY LAND SPECIFICATION Made by the awesome Brian McKenna - @puffnfresh
  36. 36. DEMO MADE WITH PACTA IMPLEMENTATION Node.js + browser implementation, totally agnostic javascript, Fantasy Land compatible + Promises/A+ compatible made by Paul Mucur with help from Rodolphe Belouin
  37. 37. TRY IT YOU WILL
  38. 38. BE A BADASS !
  39. 39. THANK YOU ! ANY QUESTIONS ? I’m on twitter : @waxzce I give you a www.clevercloud.com gift : takeoff2014

×