Your SlideShare is downloading. ×
Next generation web development with node.js and meteor
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Next generation web development with node.js and meteor

1,535
views

Published on

Published in: Technology, Design

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,535
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
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. Node.js and meteor Next generation web development for the realtime web Martin Naumann - Software Engineer Centralway Factory AG Submission #386
  • 2. AGENDA ● ● ● ● ● ● ● ● What is node.js? Why do you want it? Comparison Quick: express.js Even quicker: meteor.js Meteor.js example To node or not to node Alternatives JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 3. What is node.js? ● ● ● ● ● ● Javascript on the server event-driven architecture asynchronous I/O scalable based on V8 modular "Yeah. Nice buzzwords. What's the point?" JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 4. Why you want node.js? ● One instance can handle lots of clients ○ reduced memory footprint ○ get more performance from existing resources ○ Benchmark: up to 1.600.000 concurrent requests ● Use your frontend technology on the backend ○ you have Javascript in your application anyway ○ "Oh look, this looks familiar!" ○ You know your stuff: Callbacks, Closures, Asynchronity ● It's modular ○ easy to connect pieces of code ○ easy to write network code ○ rapidly build complex applications Level Two JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 5. Comparison: "Elders of web dev" vs. node.js ● ● ● ● ● ● HTTP is the base of all web applications HTTP was synchronous. Most of the web languages still are. HTTP evolved: ○ AJAX ○ Websockets ○ Push real-time web Need for asynchronous technologies ○ all of which are a bit weird in PHP, Java, ASP, etc. ○ node.js is asynchronous and has ever been. JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 6. Quick! To the web app - with express var express = require("express"); var app = express.createServer(); app.get('/:msg', function(req, res) { res.send(req.params.msg); }); JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 7. What boilerplate code is left? ● ● ● ● ● ● ● Setup the server Route requests Take care of HTTP Data sychronisation Persist data Write an Interface (API) Setup server-side and client-side code JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 8. Why not have... ● ● ● ● ● the code separated by conventions the server automatically deliver it automatic persistance automatic synchronisation automatically compensate latency JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 9. Quicker: meteor.js - A real-time app example "So I heard you wanted to implement a chat app" ● Write a server and a client ● transmitting messages in nearly real-time ● with multiple chatrooms ● users can pick a nickname ● users can create rooms ● What do you think how many lines of code this requires? 54. Server and client together. 7 are blank. JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 10. Meteor.js example: The server var Rooms = new Meteor.Collection("rooms"); var Messages = new Meteor.Collection("messages"); Yup. That's it. JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 11. Meteor.js example: The client I / II Template.main.currentRoom = function (){ return Session.get("room") || false; }; Template.rooms.availableRooms = function (){ return Rooms.find({}); }; JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 12. Meteor.js example: The client II / II Template.room.events = { "click #leave": function() { if(!window.confirm("Leave this room", "Really leave?")) return; Session.set("room", undefined); }, "submit": function() { Messages.insert({ "room": Session.get("room"), "author": Session.get("name"), "text": $("#msg").val() }); $("#msg").val(""); } }; JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 13. To node or not to node - that shall be the question ● Where node does make sense ○ real-time applications ○ processing long-running or I/O intensive tasks ● Where it doesn't make sense ○ static web pages ○ small web applications for standard CRUD JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 14. Alternatives ● ● ● ● ● Ruby: EventMachine Python: Twisted PHP: Photon Java: javaeventing Perl: Mojo JAZOON’12: Rookie Award, Next generation web development, Martin Naumann
  • 15. Thanks for listening! Questions? Martin Naumann - www.geekonaut.de Centralway Factory AG - www.centralway.com martin.naumann@centralway.com @AVGP - github.com/AVGP