Professional Documents
Culture Documents
Bruce Johnson
Google, Inc.
Topics
2
The Slippery Slope of Ajax
5
Hello? Software Engineering?
Code reuse?
IDEs?!?!
Debugging?!?!
How can we restore some sanity?
6
Requirements Laundry List
8
What is Google Web Toolkit (GWT)?
What is GWT?
A set of tools for building AJAX apps in the Java language
GWT is a compiler?
GWT’s Java-to-JavaScript compiler is a big part of it, but there’s
really a lot more to the story than that…
9
Code Sample – Hello, AJAX
RootPanel.get().add(b);
}
10
Demo
Hello, Ajax
Wow, That’s So Much Easier
12
Topics
13
Have Your Cake XOR Eat It?
"Powerful" Languages "Weaker" Languages
with Dynamic Typing with Static Typing
JavaScript Java
Static languages
Tools and static analysis
Dynamic languages
Flexibility and (arguably) less typing in a plain text editor
14
Stop Bugs Before They Start
15
Interactive Source Browsing
16
Code Completion
<Ctrl>+<Space>
is the other new pink
17
Great Debugging
18
Automated Refactoring
19
Demo
21
Demo
23
Demo
KitchenSink
25
Demo
DynaTable
27
Unit Testing
JUnit integration
Direct IDE support
Demo
Testing the ListBox and Tree widgets
28
Topics
29
Not All-or-Nothing
JavaScript Java
31
Don't Hold Your Breath For Code Completion
Imagine you want to write a JavaScript IDE…
// JavaScript
function enhanceString() {
String.prototype.usefulMethod = myUsefulMethod;
}
33
Also Don't Hold Your Breath For…
Refactoring
Inability to analyze → inability to refactor
Machine-checkable RPC
34
To Be Crystal Clear
JSNI
38
Stateful Client → Scalability
Traditional 01100110
01111001
HTML 01101011
User action
Stateless
HTML View Stateful
Server
Browser
New HTML page
011001101101
111110010100
011010111101
110011010110
GWT/Ajax 0110
0111
39
Optimize Like Crazy
Tough decision not to support reflection and class loading
Worth it! Three words: Whole program optimization
For example, type tightening to eliminate polymorphism
Shape s = new Circle(2); // radius of 2
double a = s.getArea();
becomes
Circle s = new Circle(2); // radius of 2
double a = (s.radius * s.radius * Math.PI);
Absolutely crucial
Should be measured in milliseconds
If startup time isn't acceptable, nothing else matters
41
Script Size (bytes)
W
in
0
10000
20000
30000
40000
50000
60000
do Em
w pt
.a y
le
rt(
"h
el
Ve lo
")
rti
ca
lP
an
el
Bu
tto
n
C
he
ck
Tr Bo
ee x
(3
ite
m
s)
La
be
l
Te
xt
Bo
G x
rid
(4
x
4)
H
TM
L
Ta Im
bP ag
a ne e
l(
Li 3
st ta
Bo bs
x )
)
H
yp
H er
or lin
iz
on k
ta
lP
an
el
Fl
ow
Pa
Ab ne
so l
lu
te
Pa
ne
l
42
Compilation: Optimized Per Client
en_US en_UK
… …
1D04ADDA.cache.html
Single Java 15F361BB.cache.html
Code Base
Your Code Your Code
7EFE4D24.cache.html D415D917.cache.html
43
Less Bandwidth: Lower Costs and Faster Apps
90000
80000
70000
60000
Bytes Transferred
50000
40000
30000
20000
10000
0
Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7
44
Topics
45
Why Do Users Love Web Apps?
No installation
Every application is just a URL away
No such thing as "DLL Hell" – it just works
Capable of super-fast startup time
Simple usability
Pages have a simple, friendly look and feel
Not much to learn: back, forward, bookmarks, links, URLs
46
Don't Throw the Baby Out With the Bathwater
No installation…sort of
In a sense, it’s also always-reinstall (had better be small)
Don't penalize users for your engineering convenience
Never be willing to sacrifice fast startup
Secure…sort of
Hard enough just to make AJAX work at all!
Lots of handwritten JS = lots of attack surface
47
To Be Crystal Clear
It is very tempting to
build frameworks that
make life easier for developers
48
Not Enough Time to Demo Everything
Internationalization support
Highly optimized
Externalized string ids are checked during compilation
Automatic, dynamic dependency inclusion
Slurp in external CSS
Slurp in external JS
Everything is cross-browser
IE6+, FF 1.0.x, FF 1.5.x, Safari 2.0.x, Opera 9.x
User
User Interface
Interface
Usability
Usability and
and I18N
I18N XML
XML
51
Growing GWT Community
52
Did I Mention Tools?
53
Did I Mention Tools?
54
Summary
We will share our best work and ideas with you, and we
hope you will return the favor