Your SlideShare is downloading. ×

Functional node.js

7,870
views

Published on

Published in: Technology

0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,870
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
56
Comments
0
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Making things simple By Robert Roose
  • 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.  Advantages  Terse  Clarity  Easier maintainability  Encourages immutability  Forces better designs  Better testability  Less bugs
  • 4.  Disadvantages  Difficult to design  Difficult to visualize  Hard for the inexperienced unenlightened  Generally slower
  • 5.  Functional programming: it’s just for those academic types
  • 6.  Functional programming: it’s fun, but it doesn’t make money
  • 7.  It makes you a better programmer  It’s an alternative perspective of how to describe good software design
  • 8.  OOP is bad  Side effects are evil  Immutability is good  Less code means less bugs
  • 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.  Less code  Less buggy code  Happier customers  Cheaper code  Easier maintainability  Quicker development  Once developers know the ropes
  • 11. What is ?
  • 12. Evented I/O framework for theV8 JavaScript engine
  • 13. Huh?
  • 14. Takes JavaScript beyond the browser
  • 15.  Provides an easy way to build scalable network programs  Generally fast  Great at concurrency  Asynchronous everything  Almost never blocks
  • 16.  Web applications  Especially real-time web apps  Network applications  Distributed systems  General purpose applications
  • 17. In node, everything runs in parallel, except your code
  • 18. Single-threaded event loop
  • 19. Something isn’t right here…
  • 20. But there’s only one thread
  • 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.  Simple designs  Efficient applications  High concurrency  Blazingly fast for end users
  • 23.  Dynamic, weakly typed multi-paradigm scripting language  Prototype-based  Functional  Imperative  Lisp in C’s clothing
  • 24.  Lots of design errors  Lots of implementation errors  Lots of bad books  Lots of amateurs
  • 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.  It supports the concepts of functional programming  Certainly not pure  More functional than object-oriented  Again, it depends on your religion
  • 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.  Underscore.js  Utility-belt JavaScript library  wu.js  For laziness  node-utils  (plug)
  • 29. Underscore.js
  • 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. 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. 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.  Attempt to expose the good parts of JavaScript  It’s just JavaScript  Compiles one-to-one into the equivalent JavaScript  Makes JavaScript simpler
  • 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.  scale-example  comet-example
  • 36. Only just scratched the surface
  • 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.  Node.js  How to Node  Node Documentation  Understanding node.js  Combined benchmark  Ryan Dahl
  • 39.  CoffeeScript  CoffeeScript Site
  • 40.  Functional Programming  Functional Programming Doesn'tWork (and what to do about)  Why functional programming doesn't catch on
  • 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