Your SlideShare is downloading. ×
0

Functional node.js

8,197

Published on

Published in: Technology
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,197
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
57
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide

Transcript of "Functional node.js"

  1. 1. Making things simple By Robert Roose
  2. 2.  religion  -noun. a set of beliefs concerning the cause, nature, and purpose of code, which guide programmers through the creation of software, usually involving devotional and ritual observations and/or gatherings, and often containing standards governing the style of development practices
  3. 3.  Advantages  Terse  Clarity  Easier maintainability  Encourages immutability  Forces better designs  Better testability  Less bugs
  4. 4.  Disadvantages  Difficult to design  Difficult to visualize  Hard for the inexperienced unenlightened  Generally slower
  5. 5.  Functional programming: it’s just for those academic types
  6. 6.  Functional programming: it’s fun, but it doesn’t make money
  7. 7.  It makes you a better programmer  It’s an alternative perspective of how to describe good software design
  8. 8.  OOP is bad  Side effects are evil  Immutability is good  Less code means less bugs
  9. 9.  Not everything can be side effect free  Limitations in languages, tools, OSs…  Bureaucracy keeps things complicated  Not everyone follows the same religion  Businesses aren’t about pretty math problems
  10. 10.  Less code  Less buggy code  Happier customers  Cheaper code  Easier maintainability  Quicker development  Once developers know the ropes
  11. 11. What is ?
  12. 12. Evented I/O framework for theV8 JavaScript engine
  13. 13. Huh?
  14. 14. Takes JavaScript beyond the browser
  15. 15.  Provides an easy way to build scalable network programs  Generally fast  Great at concurrency  Asynchronous everything  Almost never blocks
  16. 16.  Web applications  Especially real-time web apps  Network applications  Distributed systems  General purpose applications
  17. 17. In node, everything runs in parallel, except your code
  18. 18. Single-threaded event loop
  19. 19. Something isn’t right here…
  20. 20. But there’s only one thread
  21. 21.  Use processes!  Easily scale across distributed systems  Much safer than threads  No need to worry about states  Use load balancer to distribute work  HAProxy  nginx  multi-node
  22. 22.  Simple designs  Efficient applications  High concurrency  Blazingly fast for end users
  23. 23.  Dynamic, weakly typed multi-paradigm scripting language  Prototype-based  Functional  Imperative  Lisp in C’s clothing
  24. 24.  Lots of design errors  Lots of implementation errors  Lots of bad books  Lots of amateurs
  25. 25.  No, but it can be forced  It’s prototype-based  It has objects, but not classes  It doesn’t have class-oriented inheritance – it has prototype-oriented inheritance  There are lots of different ways to achieve the same thing  Really depends on your religion
  26. 26.  It supports the concepts of functional programming  Certainly not pure  More functional than object-oriented  Again, it depends on your religion
  27. 27.  Treat variables as constants  Think of everything as immutable  Don’t rely on side effects  Avoid confusion  Return a new object instead of modifying  Can be used as a (non-pure) functional language  Just use what works
  28. 28.  Underscore.js  Utility-belt JavaScript library  wu.js  For laziness  node-utils  (plug)
  29. 29. Underscore.js
  30. 30. starting reading file1.txt got file1.txt reading file2.txt got file2.txt reading file3.txt got file3.txt getting google got google ... File 1, File 2, File 3, 3bb0f168fbf8c9b0324cbf2fea1266ea
  31. 31. starting reading file1.txt reading file2.txt reading file3.txt getting google got file1.txt got file2.txt got file3.txt got google ... File 1, File 2, File 3, ba5eaf36ca6e688d33ff53a466de01e1
  32. 32. starting reading file1.txt reading file2.txt reading file3.txt getting google got file1.txt got file2.txt got file3.txt got google ... File 1, File 2, File 3, 065b003da0d66b14924086c8c8a1d7a6
  33. 33.  Attempt to expose the good parts of JavaScript  It’s just JavaScript  Compiles one-to-one into the equivalent JavaScript  Makes JavaScript simpler
  34. 34. starting reading file1.txt reading file2.txt reading file3.txt getting google got file1.txt got file2.txt got file3.txt got google ... File 1, File 2, File 3, 3290579989c493c338dcf52327442c10
  35. 35.  scale-example  comet-example
  36. 36. Only just scratched the surface
  37. 37.  JavaScript  JavaScript:TheWorld’s Most Misunderstood Programming Language  The Little JavaScripter  JavaScript as a Functional Language  Higher-Order JavaScript  Functional Programming – Eloquent JavaScript  Douglas Crockford
  38. 38.  Node.js  How to Node  Node Documentation  Understanding node.js  Combined benchmark  Ryan Dahl
  39. 39.  CoffeeScript  CoffeeScript Site
  40. 40.  Functional Programming  Functional Programming Doesn'tWork (and what to do about)  Why functional programming doesn't catch on
  41. 41.  http://twitter.com/summatix  http://www.robertroose.info/  http://bitbucket.org/summatix  https://github.com/summatix  http://bitbucket.org/shivercube  https://github.com/shivercube
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×