gwt introduction and overview - sv code camp 09

54
1 Google Web Toolkit Introduction & Overview Fred Sauer Developer Advocate [email protected] SV Code Camp Oct 4, 2009

Upload: fred-sauer

Post on 21-Jan-2015

4.382 views

Category:

Sports


2 download

DESCRIPTION

Google Web Toolkit - Introduction and OverviewSilicon Valley Code Camp 2009

TRANSCRIPT

Page 1: GWT Introduction and Overview - SV Code Camp 09

1

Google Web ToolkitIntroduction & Overview

Fred SauerDeveloper [email protected] 

SV Code CampOct 4, 2009

Page 2: GWT Introduction and Overview - SV Code Camp 09

2

Agenda

Introduction

Selecting a language

Feature tour

Developer productivity

Need for speed

Compiler magic

Q&A

Page 3: GWT Introduction and Overview - SV Code Camp 09

3

Google Web Toolkit

Write

Core Java APIs

Widgets

Libraries

Java IDEs

Debug

JVM Debugging

Development Mode

A real browser

Developer Productivity

Optimize

GWT Compiler

Image Bundle (Sprites)

CSS Magic

End User Performance

Run

Desktop

Mobile

Online/Offline

Gadgets

Page 4: GWT Introduction and Overview - SV Code Camp 09

4

May 2006 GWT 1.0 Launch at JavaOne

Aug 2008 GWT 1.5 Java 5 language support

Apr 2009 GWT 1.7 Dedicated IE8 support

Fall 2009 GWT 2.0 LOTS of interesting stuff

3+ years in review

Page 5: GWT Introduction and Overview - SV Code Camp 09

5

Mission statement

"GWT's mission is to radically improve

the web experience for users by

enabling developers to use existing

Java tools to build no-compromise

AJAX for any modern browser."

Page 6: GWT Introduction and Overview - SV Code Camp 09

6

Focus

Productivity for developers

Language, IDEs, tools, libraries

People, ecosystem

Performance for your users

'Perfect' caching

Whole program optimization

Better than practical hand written code

Page 7: GWT Introduction and Overview - SV Code Camp 09

7

No plugins required

VML Flash

Silverlight

Page 8: GWT Introduction and Overview - SV Code Camp 09

8

What we don't want

Page 9: GWT Introduction and Overview - SV Code Camp 09

9

GWT Browser-Proofs Your JavaScript Code...

IE

Firefox

Safari

Chrome

Opera

Page 10: GWT Introduction and Overview - SV Code Camp 09

10

Deferred Binding

14800 ms4836 ms1997 ms7148 msDOM manipulation

2469 ms1520 ms918 ms2477 msinnerText=...

-1386 ms908 ms-textContent=...

4078 ms2053 ms1276 ms2876 msTypical portable setInnerText()

IEOperaWebkit (Safari)

Firefox

Improvement 39%32%29%14%

Page 11: GWT Introduction and Overview - SV Code Camp 09

11

A More Powerful Web, Made Easier

Page 12: GWT Introduction and Overview - SV Code Camp 09

12

Eating our own dogfood

12

Page 13: GWT Introduction and Overview - SV Code Camp 09

13

Selecting a language

Page 14: GWT Introduction and Overview - SV Code Camp 09

14

Rich ecosystem of tools and libraries

+ + =

Page 15: GWT Introduction and Overview - SV Code Camp 09

15

Code completion and javadoc

Page 16: GWT Introduction and Overview - SV Code Camp 09

16

Can you find the bug?

Hint: JavaScript is a dynamic language

Page 17: GWT Introduction and Overview - SV Code Camp 09

17

Java is a static language

Catch errors at compile time

Page 18: GWT Introduction and Overview - SV Code Camp 09

18

Feature tour

Page 19: GWT Introduction and Overview - SV Code Camp 09

19

Pluggable Architecture

Page 20: GWT Introduction and Overview - SV Code Camp 09

20

More than just a compiler

Page 21: GWT Introduction and Overview - SV Code Camp 09

21

Sprites for free

20,558 bytes

6,824 bytes

11 separate images

1 bundled image

Page 22: GWT Introduction and Overview - SV Code Camp 09

22

Without ClientBundle

Page 23: GWT Introduction and Overview - SV Code Camp 09

23

Roundtrips are deadly

1 round trip for TCP connection setup

(1 round trip for HTTP redirect?)

1 round trip for each HTTP request

$ ping ohare.comPING ohare.com (70.142.247.22): 56 data bytes64 bytes from 70.142.247.22: icmp_seq=0 ttl=113 time=54.689 ms64 bytes from 70.142.247.22: icmp_seq=1 ttl=113 time=55.500 ms64 bytes from 70.142.247.22: icmp_seq=2 ttl=113 time=54.728 ms

$ ping ohare.comPING ohare.com (70.142.247.22): 56 data bytes64 bytes from 70.142.247.22: icmp_seq=0 ttl=113 time=54.689 ms64 bytes from 70.142.247.22: icmp_seq=1 ttl=113 time=55.500 ms64 bytes from 70.142.247.22: icmp_seq=2 ttl=113 time=54.728 ms

Page 24: GWT Introduction and Overview - SV Code Camp 09

24

Reducing round trip time

Use HTTP Expires and Cache-Control headers

Use GWT 'Perfect Caching'

Cache 'forever' - your entire app and all its resources

Bundle, bundle, bundle

Enable HTTP Pipelining

Use multiple hostnames

Defeat browser's two connection limit

Watch out for DNS lookup overhead though

Page 25: GWT Introduction and Overview - SV Code Camp 09

25

Know your HTTP Headers

<!-- See RFC 2616. Here's an example: Expires: Thu, 02 Sep 2010 03:21:55 GMT Cache-Control: public, max-age=31536000--><Files *.cache.*> ExpiresDefault "now plus 1 year"</Files>

<Files *.nocache.*> ExpiresDefault "access"</Files>

Page 26: GWT Introduction and Overview - SV Code Camp 09

26

History just works

Page 27: GWT Introduction and Overview - SV Code Camp 09

27

Rich Text Area

Page 28: GWT Introduction and Overview - SV Code Camp 09

28

RTL, I18N, L10N, A11Y

Page 29: GWT Introduction and Overview - SV Code Camp 09

29

Widget Libraries

• GWT (http://code.google.com/webtoolkit/)  

• Incubator  (http://code.google.com/p/google-web-toolkit-incubator/)

• Smart GWT (http://code.google.com/p/smartgwt/)

• GWT-Ext (http://code.google.com/p/gwt-ext/)

• Vaadin (IT Mill Toolkit) (http://vaadin.com/)

• GWT mosaic (http://code.google.com/p/gwt-mosaic/)

• Ext GWT (http://extjs.com/products/gxt/)

• Advanced GWT Components    (http://advanced-gwt.sourceforge.net/) 

Page 30: GWT Introduction and Overview - SV Code Camp 09

30

GUI Editing

Page 31: GWT Introduction and Overview - SV Code Camp 09

31

Simple, Powerful RPCs

interface SpellService extends RemoteService { /**  * Checks spelling and suggests  * alternatives.  * @param the word to check  * @return the list of alternatives  */ String[] suggest(String word);}

Page 32: GWT Introduction and Overview - SV Code Camp 09

32

Shameless plugs (gwt-dnd, gwt-log, gwt-voices)

Page 33: GWT Introduction and Overview - SV Code Camp 09

33

Developer productivity

Page 34: GWT Introduction and Overview - SV Code Camp 09

34

GWT 2.0 operating modes

Development Mode (Hosted Mode)

All about productivity

Java + JavaScript

Now in any supported browser

Production Mode (Web Mode)

All about performance

Compiled, Pure JavaScript

Page 35: GWT Introduction and Overview - SV Code Camp 09

35

Development Mode (Hosted Mode)

JVM debugging

Server & Client code in the same IDE

Step in / over / out

Introspect & modify variables

Hot swap code (ignore the IDE warning!)

NOT TRUE

Page 36: GWT Introduction and Overview - SV Code Camp 09

36

Java Virtual Machine

Development Mode

Code Server

Web Server

Duke, the Java mascotCopyright © Sun Microsystems Inc., all rights reserved.

Page 37: GWT Introduction and Overview - SV Code Camp 09

37

Google Plugin for Eclipse

Page 38: GWT Introduction and Overview - SV Code Camp 09

38

Eclipse plugin highlights

Extensive JSNI support

RPC sync/async quick fixes

Launch configurations

GWT JUnit tests

Contributor SDKs (gwt-user, gwt-dev-<platform>)

Development Mode (GWT 2.0)

Hosted Mode (GWT 1.7)

Constantly improving; check back often

Page 39: GWT Introduction and Overview - SV Code Camp 09

39

GWT Debugging in the browser

Page 40: GWT Introduction and Overview - SV Code Camp 09

40

Need for speed

Page 41: GWT Introduction and Overview - SV Code Camp 09

41

Speed matters

perceived as instantaneous.

maintains the feeling that a single task is being carried out.

limit for keeping user’s attention.

0.1 seconds

1 second

10 seconds

Page 42: GWT Introduction and Overview - SV Code Camp 09

42

Another reason speed matters

2. UIChanges

3. UserLearns

1. UserAction

Performance for your users

Page 43: GWT Introduction and Overview - SV Code Camp 09

43

GWT Helps Apps Startup More Quickly

26-Nov 29-Apr 18-Jun 28-Jul 12-Sep 27-Oct 24-Dec 16-Mar

Siz

e of

Initi

al J

avaS

crip

t Dow

nloa

d (K

B)

375

750

1125

1500

0

7x Decrease InInitial Download Sizewith runAsync()

1400 KB

200 KB

Page 44: GWT Introduction and Overview - SV Code Camp 09

44

Developer guided code splitting

Page 45: GWT Introduction and Overview - SV Code Camp 09

45

Developer guided code splitting

Page 46: GWT Introduction and Overview - SV Code Camp 09

46

Manual code splitting - Don't try this at home

46

Page 47: GWT Introduction and Overview - SV Code Camp 09

47

Developer guided code splitting

GWT.runAsync(new RunAsyncCallback() {

  public void onSuccess() {    …  }

  public void onFailure(Throwable caught) {    …  }

});

Page 48: GWT Introduction and Overview - SV Code Camp 09

48

Story of Your Compile (SOYC)

-C

Page 49: GWT Introduction and Overview - SV Code Camp 09

51

Compiler magic

Page 50: GWT Introduction and Overview - SV Code Camp 09

52

GWT quote to remember

“The fastest code is thatwhich does not run.”

Joel WebberGWT co-creator

Page 51: GWT Introduction and Overview - SV Code Camp 09

53

Conventional and non-conventional

Java transformations

Dead-code elimination

Method inlining

Constant folding & propagation

JavaScript transformations (gzip motivated)

Method reordering

Argument renaming

Page 52: GWT Introduction and Overview - SV Code Camp 09

54

EXPERIMENTAL arguments you should know// Don't care what Class#getName() returns?-XdisableClassMetadata

5% - 10% script reduction

Showcase metadata before

Showcase metadata after

Page 53: GWT Introduction and Overview - SV Code Camp 09

55

EXPERIMENTAL arguments you should know// In a real-world (very large) Google app...// 1% script size reduction// 10% faster in performance-sensitive code-XdisableCastChecking

try { ((Quacker) animal).quack();} catch (ClassCastException c) { Window.alert("Found a non-quacker");}

Page 54: GWT Introduction and Overview - SV Code Camp 09

83

Thank you

Read morehttp://code.google.com/webtoolkit/

Contact infoFred Sauer

Developer Advocate

[email protected]

Questions?