SlideShare a Scribd company logo
1 of 55
JavaScript
                            IN THE CLOUD




                                           Mostafa Eweda
                                      eSpace Technologies
                                          10 January, 2013
Saturday, February 2, 13
Program


                     •     Javascript, 1995 to 2013
                     •     Building Cloud9
                     •     Demo




Saturday, February 2, 13
Javascript

                     •     Livescript
                     •     Netscape 2.0
                     •     Not like Java
                     •     More like Scheme




Saturday, February 2, 13
JS had to "look like Java" only
                   less so, [it had to] be
                 Java's dumb kid brother.



Saturday, February 2, 13
XMLHttpRequest


Saturday, February 2, 13
Saturday, February 2, 13
Saturday, February 2, 13
DOM


                     •     Never meant to be scripted
                     •     Direct mapping of C structures
                     •     Incovenient API




Saturday, February 2, 13
Saturday, February 2, 13
Saturday, February 2, 13
Saturday, February 2, 13
Saturday, February 2, 13
Java vs. Javascript




     Let’s confess:
     JavaScript is already the language of the Web
Saturday, February 2, 13
People started to care

                     •     VMs got faster
                           •   And embeddable!
                     •     EcmaScript 5
                     •     JSConf

                  So, JavaScript is a very simple, but often
                  misunderstood language.
Saturday, February 2, 13
Node.js is a NOT another web
          framework. I promise !
Saturday, February 2, 13
Google’s V8 engine
                           as an executable!




Saturday, February 2, 13
LibUV

Saturday, February 2, 13
Asynchronous is cool!




Saturday, February 2, 13
I hate
                           asynchronous!




Saturday, February 2, 13
Normal C++ IO




Saturday, February 2, 13
LibUV C++ IO




Saturday, February 2, 13
Saturday, February 2, 13
Javascript                 LibUV




          Node.js is a platform for building fast,
          scalable network applications.
Saturday, February 2, 13
Javascript bindings to LibUV

                           Standard libraries in JS

                             JS executed in V8


Saturday, February 2, 13
LibUV
                           Not exclusive



Saturday, February 2, 13
Read File in Ruby
       file = File.new("readfile.rb", "r")
       while (line = file.gets)
         # Do something with line
       end
       file.close


                           Read File in Node
  fs.readFile('readfile.js', function (err, buffer){
    if (err) throw err;
    // File is read and we're done.
  });

Saturday, February 2, 13
browser.js


                             db.js


                            server.js

Saturday, February 2, 13
Normal C++ IO
    • Node.js is fast by design.
    • Never blocking on I/O means less
             threads.




Saturday, February 2, 13
Program

 Async.parallel([
   function loadData(next) {
      db.loadData(next);
   },
   function readFile(next) {
     fs.readFile(fName, next);
   ], function done(err, items) {
      if (err) throw err;
      // Do something with items
 });




                           https://github.com/caolan/async
Saturday, February 2, 13
Program
 var user;
 Async.series([
   function loadUser(next) {
      db.getUser(user_id, function(err, u){
          user = u;
          next(err);
      });
   },
   function findItems(next) {
     var sql = "SELECT * FROM store WHERE
 type=?";
      db.query(sql, user.type, next);
   ], function done(err, items) {
      if (err) throw err;
      // Do something with items
 });




Saturday, February 2, 13
Program
               Mix to do complex stuff like:




                           https://github.com/caolan/async
Saturday, February 2, 13
Program


                     •     Javascript, 1995 to 2013
                     •     Building Cloud9
                     •     Demo




Saturday, February 2, 13
Normal developers




Saturday, February 2, 13
JavaScript Developer




Saturday, February 2, 13
is to



           as              is to



Saturday, February 2, 13
You really need HELP



                                    Text




Saturday, February 2, 13
You really need HELP



                                    Text




Saturday, February 2, 13
You really need HELP



                                    Text

           undeclared variable




Saturday, February 2, 13
You really need HELP



                                      Text

           undeclared variable

                                  Iterating using undeclared variable
                                                                        Did you mean “length”?




Saturday, February 2, 13
You really need HELP



                                      Text

           undeclared variable

                                  Iterating using undeclared variable
                                                                        Did you mean “length”?




Saturday, February 2, 13
You really need HELP



                                                            Text

           undeclared variable

                                                        Iterating using undeclared variable
                                                                                                Did you mean “length”?
                                                                                              function created in loop
                            Warning: you are in an anonymous inner function with its own “this” pointer




Saturday, February 2, 13
Saturday, February 2, 13
Debugging




Saturday, February 2, 13
(Smart!) Code completion




Saturday, February 2, 13
Free Linux VM!
Saturday, February 2, 13
Real terminal
Saturday, February 2, 13
Collaboration




Saturday, February 2, 13
Create

                           Deploy
                                                  Run/Debug



                              Share            Test




Saturday, February 2, 13
Program


                     •     Javascript, 1995 to 2012
                     •     Building Cloud9
                     •     Demo




Saturday, February 2, 13
Node.js simple server

            var http = require('http');

      http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('Hello world');
      }).listen(3000);




Saturday, February 2, 13
Node.js real web app
                            express / connect
          $ npm install -g express
    $     express --sessions --css stylus --ejs jade
    $     cd myapp
    $     npm install
    $     node app.js

    app.get('/hello.txt', function(req, res){
      res.send('Hello World');
    });
    app.listen(3000);
    console.log('Listening on port 3000');


    $ node app

                           http://expressjs.com/
Saturday, February 2, 13
Node.js real web app
                                    Socket.IO 100% JS
          Realtime apps made possible blurring the
          differences between browser transport mechanisms.

    $ npm install socket.io

                           Server                                    Client
   var io = require('socket.io');                    <script src="/socket.io/socket.io.js"></script>
   // attached to the express app                    <script>
   // or runs standalone on port 80                    var socket = io.connect('http://localhost');
   io = io.listen(app || 80);
                                                       socket.on('message', function (msg) {
   io.sockets.on('connection', function (socket) {       console.log(msg);
     socket.on('message', function (msg) {               socket.send({ info: 'trash' });
       console.log(msg);                               });
     });                                             </script>
   });


                                      http://socket.io
Saturday, February 2, 13
Future (Architect)
          • A simple yet powerful plugin system for
                  large-scale Node.js applications
            •       Dependency Injection for JavaScript
                    Managing > ~100K LOC of JS
                    JS: Dynamically typed - Singly threaded



                                http://github.com/c9/architect
Saturday, February 2, 13
Wrap-Up

               • Node.js is brilliant for modern web apps
               • If you do realtime app that is meant to be scalable,
                      you should probably consider Node.js & Socket.io

               • Scale your code base: http://github.com/c9/architect
                      for your application.

               • Check out c9.io for a serious online IDE.

Saturday, February 2, 13
Text

                           http://c9.io


                                                Mostafa Eweda
                                      github.com/mostafaeweda
                                               @mostafaeweda

Saturday, February 2, 13

More Related Content

Similar to Javascript in the cloud

Testing Drupal with Ghosts and Gherkin
Testing Drupal  with Ghosts and GherkinTesting Drupal  with Ghosts and Gherkin
Testing Drupal with Ghosts and GherkinPhase2
 
Invokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesInvokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesCharles Nutter
 
Invokedynamic in 45 Minutes
Invokedynamic in 45 MinutesInvokedynamic in 45 Minutes
Invokedynamic in 45 MinutesCharles Nutter
 
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]Jason Rhodes
 
The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]
The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]
The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]Jason Rhodes
 
Puppet @ Nedap
Puppet @ NedapPuppet @ Nedap
Puppet @ NedapPuppet
 
GitHub Notable OSS Project
GitHub  Notable OSS ProjectGitHub  Notable OSS Project
GitHub Notable OSS Projectroumia
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternPuppet
 
Welcome to the Symfony2 World - FOSDEM 2013
 Welcome to the Symfony2 World - FOSDEM 2013 Welcome to the Symfony2 World - FOSDEM 2013
Welcome to the Symfony2 World - FOSDEM 2013Lukas Smith
 
RailsConf 2013: RubyMotion
RailsConf 2013: RubyMotionRailsConf 2013: RubyMotion
RailsConf 2013: RubyMotionBrian Sam-Bodden
 
State of Puppet
State of PuppetState of Puppet
State of PuppetPuppet
 
Game Changing Dependency Management
Game Changing Dependency ManagementGame Changing Dependency Management
Game Changing Dependency ManagementJeremy Kendall
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
Writing Reusable Web Components with jQuery and jQuery UI
Writing Reusable Web Components with jQuery and jQuery UIWriting Reusable Web Components with jQuery and jQuery UI
Writing Reusable Web Components with jQuery and jQuery UIYnon Perek
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming IntroductionAnthony Brown
 
MongoDB For C++ Developers
MongoDB For C++ DevelopersMongoDB For C++ Developers
MongoDB For C++ DevelopersYnon Perek
 

Similar to Javascript in the cloud (20)

Play 2 pip
Play 2 pipPlay 2 pip
Play 2 pip
 
Testing Drupal with Ghosts and Gherkin
Testing Drupal  with Ghosts and GherkinTesting Drupal  with Ghosts and Gherkin
Testing Drupal with Ghosts and Gherkin
 
Invokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesInvokedynamic: Tales from the Trenches
Invokedynamic: Tales from the Trenches
 
Invokedynamic in 45 Minutes
Invokedynamic in 45 MinutesInvokedynamic in 45 Minutes
Invokedynamic in 45 Minutes
 
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
 
The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]
The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]
The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]
 
Wphackergalaxy
WphackergalaxyWphackergalaxy
Wphackergalaxy
 
Puppet @ Nedap
Puppet @ NedapPuppet @ Nedap
Puppet @ Nedap
 
GitHub Notable OSS Project
GitHub  Notable OSS ProjectGitHub  Notable OSS Project
GitHub Notable OSS Project
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles Pattern
 
Welcome to the Symfony2 World - FOSDEM 2013
 Welcome to the Symfony2 World - FOSDEM 2013 Welcome to the Symfony2 World - FOSDEM 2013
Welcome to the Symfony2 World - FOSDEM 2013
 
RailsConf 2013: RubyMotion
RailsConf 2013: RubyMotionRailsConf 2013: RubyMotion
RailsConf 2013: RubyMotion
 
State of Puppet
State of PuppetState of Puppet
State of Puppet
 
With your bare hands
With your bare handsWith your bare hands
With your bare hands
 
Game Changing Dependency Management
Game Changing Dependency ManagementGame Changing Dependency Management
Game Changing Dependency Management
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Writing Reusable Web Components with jQuery and jQuery UI
Writing Reusable Web Components with jQuery and jQuery UIWriting Reusable Web Components with jQuery and jQuery UI
Writing Reusable Web Components with jQuery and jQuery UI
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming Introduction
 
MongoDB For C++ Developers
MongoDB For C++ DevelopersMongoDB For C++ Developers
MongoDB For C++ Developers
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

Javascript in the cloud

  • 1. JavaScript IN THE CLOUD Mostafa Eweda eSpace Technologies 10 January, 2013 Saturday, February 2, 13
  • 2. Program • Javascript, 1995 to 2013 • Building Cloud9 • Demo Saturday, February 2, 13
  • 3. Javascript • Livescript • Netscape 2.0 • Not like Java • More like Scheme Saturday, February 2, 13
  • 4. JS had to "look like Java" only less so, [it had to] be Java's dumb kid brother. Saturday, February 2, 13
  • 8. DOM • Never meant to be scripted • Direct mapping of C structures • Incovenient API Saturday, February 2, 13
  • 13. Java vs. Javascript Let’s confess: JavaScript is already the language of the Web Saturday, February 2, 13
  • 14. People started to care • VMs got faster • And embeddable! • EcmaScript 5 • JSConf So, JavaScript is a very simple, but often misunderstood language. Saturday, February 2, 13
  • 15. Node.js is a NOT another web framework. I promise ! Saturday, February 2, 13
  • 16. Google’s V8 engine as an executable! Saturday, February 2, 13
  • 19. I hate asynchronous! Saturday, February 2, 13
  • 20. Normal C++ IO Saturday, February 2, 13
  • 21. LibUV C++ IO Saturday, February 2, 13
  • 23. Javascript LibUV Node.js is a platform for building fast, scalable network applications. Saturday, February 2, 13
  • 24. Javascript bindings to LibUV Standard libraries in JS JS executed in V8 Saturday, February 2, 13
  • 25. LibUV Not exclusive Saturday, February 2, 13
  • 26. Read File in Ruby file = File.new("readfile.rb", "r") while (line = file.gets) # Do something with line end file.close Read File in Node fs.readFile('readfile.js', function (err, buffer){ if (err) throw err; // File is read and we're done. }); Saturday, February 2, 13
  • 27. browser.js db.js server.js Saturday, February 2, 13
  • 28. Normal C++ IO • Node.js is fast by design. • Never blocking on I/O means less threads. Saturday, February 2, 13
  • 29. Program Async.parallel([ function loadData(next) { db.loadData(next); }, function readFile(next) { fs.readFile(fName, next); ], function done(err, items) { if (err) throw err; // Do something with items }); https://github.com/caolan/async Saturday, February 2, 13
  • 30. Program var user; Async.series([ function loadUser(next) { db.getUser(user_id, function(err, u){ user = u; next(err); }); }, function findItems(next) { var sql = "SELECT * FROM store WHERE type=?"; db.query(sql, user.type, next); ], function done(err, items) { if (err) throw err; // Do something with items }); Saturday, February 2, 13
  • 31. Program Mix to do complex stuff like: https://github.com/caolan/async Saturday, February 2, 13
  • 32. Program • Javascript, 1995 to 2013 • Building Cloud9 • Demo Saturday, February 2, 13
  • 35. is to as is to Saturday, February 2, 13
  • 36. You really need HELP Text Saturday, February 2, 13
  • 37. You really need HELP Text Saturday, February 2, 13
  • 38. You really need HELP Text undeclared variable Saturday, February 2, 13
  • 39. You really need HELP Text undeclared variable Iterating using undeclared variable Did you mean “length”? Saturday, February 2, 13
  • 40. You really need HELP Text undeclared variable Iterating using undeclared variable Did you mean “length”? Saturday, February 2, 13
  • 41. You really need HELP Text undeclared variable Iterating using undeclared variable Did you mean “length”? function created in loop Warning: you are in an anonymous inner function with its own “this” pointer Saturday, February 2, 13
  • 45. Free Linux VM! Saturday, February 2, 13
  • 48. Create Deploy Run/Debug Share Test Saturday, February 2, 13
  • 49. Program • Javascript, 1995 to 2012 • Building Cloud9 • Demo Saturday, February 2, 13
  • 50. Node.js simple server var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello world'); }).listen(3000); Saturday, February 2, 13
  • 51. Node.js real web app express / connect $ npm install -g express $ express --sessions --css stylus --ejs jade $ cd myapp $ npm install $ node app.js app.get('/hello.txt', function(req, res){ res.send('Hello World'); }); app.listen(3000); console.log('Listening on port 3000'); $ node app http://expressjs.com/ Saturday, February 2, 13
  • 52. Node.js real web app Socket.IO 100% JS Realtime apps made possible blurring the differences between browser transport mechanisms. $ npm install socket.io Server Client var io = require('socket.io'); <script src="/socket.io/socket.io.js"></script> // attached to the express app <script> // or runs standalone on port 80 var socket = io.connect('http://localhost'); io = io.listen(app || 80); socket.on('message', function (msg) { io.sockets.on('connection', function (socket) { console.log(msg); socket.on('message', function (msg) { socket.send({ info: 'trash' }); console.log(msg); }); }); </script> }); http://socket.io Saturday, February 2, 13
  • 53. Future (Architect) • A simple yet powerful plugin system for large-scale Node.js applications • Dependency Injection for JavaScript Managing > ~100K LOC of JS JS: Dynamically typed - Singly threaded http://github.com/c9/architect Saturday, February 2, 13
  • 54. Wrap-Up • Node.js is brilliant for modern web apps • If you do realtime app that is meant to be scalable, you should probably consider Node.js & Socket.io • Scale your code base: http://github.com/c9/architect for your application. • Check out c9.io for a serious online IDE. Saturday, February 2, 13
  • 55. Text http://c9.io Mostafa Eweda github.com/mostafaeweda @mostafaeweda Saturday, February 2, 13