Wait that is possible on the web?

Description
Description

mgwt & gwt-phonegap

Description
Description
Description
Description
Description
Description
Description
Description
Description

agenda

  • history of the web
  • quiz on web platform features
  • bigger picture or why you should build on the web
  • Q&A

history of the web

Description

history of the web

  • web started out as a place for documents
    • HTTP protocol: resources
    • HTTP verbs: GET, PUT, DELETE
    • mostly static
  • sharing information digitally was great
Description
Description

the era of server side html generation

  • documents no longer were static
  • many different frameworks & languages spawned around this
  • proved incredibly useful
  • broader information sharing
Description

2005

  • People were doing real work on the web
  • But: still a roundtrip for every interaction
  • Desktop had better UIs
  • Let's bring the desktop to the web
  • Browser plugins
    • Flash
    • Silverlight
    • others
Description
Description

Gmail & Google Maps

  • real computation in the fronted
  • no plugins
  • no tools
    • no debugger
    • no jquery

The rise of javascript

  • sophisticated client side apps need a fast runtime
  • google introduced chrome in 2008
    • helped to start a race for javascript performance
    • browser got way faster in a short time
  • browsers accelerated releases from 1.5 years to 6 weeks

The web evolves faster and faster

Description

The web evolves so fast that it's hard to keep up

Description

Let's do a quiz

Can a website change the page without a reload?

Can a website change the page without a reload?

Description

Yes

Does a web app still work if you are offline?

Does a web app still work if you are offline?

Description

Yes

Offline web apps

App cache

  • makes your resources available offline
  • manifest file

Storage

  • sandbox for every web app
  • LocalStorage: stores key value pairs
  • synchronous API
  • indexedDB: large amounts of data
  • asynchronous API

navigator online check

  • indicated wether online or offline

Online / Offline Flag

<script type='text/javascript'>

var statusElem = document.getElementById('status')

setInterval(function () {
  	statusElem.className = navigator.onLine ? 'online' : 'offline';
  	statusElem.innerHTML = navigator.onLine ? 'online' : 'offline';  
}, 250);

</script>

Online / Offline Demo

Do I need offline?

  • Tablets / Phones
  • Tethering
  • VPN
  • Train / Airplane
  • Performance

Can a web app access the file system?

Can a web app access the file system?

Description

Yes

Access the filesystem

<script type='text/javascript'>

window.requestFileSystem(
  TEMPORARY,        // persistent vs. temporary storage
  1024 * 1024,      // size (bytes) of needed space
  initFs,           // success callback
  opt_errorHandler  // opt. error callback, denial of access
);

</script>

Example: Caching Remote Files

var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/image.png', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {


};

xhr.send();

Example: Caching Remote Files

var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/image.png', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
  window.requestFileSystem(TEMPORARY, 1024 * 1024, function(fs) {









  }, onError);
};

xhr.send();

Example: Caching Remote Files

var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/image.png', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
  window.requestFileSystem(TEMPORARY, 1024 * 1024, function(fs) {
    fs.root.getFile('image.png', {create: true}, function(fileEntry) {







    }, onError);
  }, onError);
};

xhr.send();

Example: Caching Remote Files

var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/image.png', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
  window.requestFileSystem(TEMPORARY, 1024 * 1024, function(fs) {
    fs.root.getFile('image.png', {create: true}, function(fileEntry) {

      fileEntry.createWriter(function(writer) {
        writer.onwriteend = function(e) { ... };
        writer.onerror = function(e) { ... };
        writer.write(new Blob([xhr.response], {type: 'image/png'}));
      }, onError);

    }, onError);
  }, onError);
};

xhr.send();

Eric Bidelman on the HTML File system API

Using the HTML5 Filesystem API

File system

  • sandboxed per origin
  • amount of storage varies
  • filer.js unix command line api

Can we do cool animations the web?

Can we do cool animations the web?

Description

Yes

Animations

Can we play audio in the web?

Can we play audio in the web?

Description

Yes

Audio example

<script type='text/javascript'>

var ctx = new window.AudioContext();

function playSound(arrBuff) { // Obtain arrBuffer from XHR
  var src = ctx.createBufferSource();
  src.buffer = ctx.createBuffer(arrBuff, false /*mix2Mono*/);
  src.looping = true;

  src.connect(ctx.destination);
  src.noteOn(0); // Play immediately.
}
</script>

Play audio demo

Can we access the mic?

Can we access the mic?

Description

Yes

Guitar amp!

Can we start a thread?

Can we start a thread?

Description

Yes

Webworker

  • enables heavy computation in the browser
  • no blocking of the UI
  • runs javascript in the background
  • uses postMessage to exchange data

web worker demo

Web worker code example part 1

<script type='text/javascript' id="worker1" type="javascript/worker">
  
    // This script won't be parsed by JS engines
    // because its type is javascript/worker.
    self.onmessage = function(e) {
      self.postMessage('msg from worker');
    };
    // Rest of your worker code goes here.
 
</script>

Web worker code example part 2

<script type='text/javascript'>

    var blob = new Blob([document.querySelector('#worker1').textContent]);

    var worker = new Worker(window.URL.createObjectURL(blob));
    worker.onmessage = function(e) {
      log("Received: " + e.data);
    }
  
  function sayHI() {
    worker.postMessage({'cmd': 'start', 'msg': 'Hi'});
  }
</script>

Access your video camera?

Access your video camera?

Description

Yes

Photo booth in the web?

Photo booth in the web!

Play real video games?

Play real video games?

Description

Yes

Quake II built with GWT

  • Java port of Quake II C source code
    • Jake2
    • showed that Quake runs fine in Java
  • Could you compile that with GWT and run it inside a browser?
  • no plugins!
  • Built by Joel Webber, Ray Cromwell & Stefan Hausstein at google

Demo: Quake II built with GWT

Quake II built with GWT

  • WebGL is based on openGL ES 2.0
  • essentially canvas 3d
  • web sockets for multiplayer
  • done in 2010
  • good performance
  • open source: quake2-gwt-port

Visualize business data?

Visualize business data?

Description

Yes

Slicedrop

  • quick visualization of medical imaging data
  • directly on the web without any plugins
  • own WebGL library called XTK
  • open source, see github

Slicedrop demo

Do cool presentation on the web?

Do cool presentation on the web?

Description

Yes

About this presentation

  • pure done inside a browser
  • Google IO 2012 slide deck
  • slides are open source: google code io 2012 slides
  • simple markup
  • styling in CSS
  • animations are done with CSS transforms

caniuse.com

  • see which browser supports which features
  • very accurate
  • well maintained

The web evolves fast

Description

the bigger picture

  • web platform is getting better at a rapid pace
  • building on the web means building on open standards
  • a new age of the web just started
    • new applications are not about documents anymore
    • applications are deployed via HTTP
  • What does that mean for server side HTML generation?

Learn about this new platform

  • Do not assume that your beloved framework is still the best
  • delivering great software means using the platform really well
  • Learn how the browser works

GWT

  • enables you to write Java while using all those features
  • GWT applications are first class citizens
  • fast, very well optimized
  • but still all the java tools
  • GWT is not about not learning how to use the web platform
  • it is about tooling

Thank You!

Daniel Kurka