In defense of GWT-RPC By Colin Alworth

GWTcon
GWTcon Firenze, Italy
In Defense of GWT-RPC
Presenter:
Colin Alworth
Co-Founder
colin@vertispan.com
RPC is horrible and you
should stop using it.
Presenter:
Colin Alworth
Co-Founder
colin@vertispan.com
3
GWT-RPC’s Problems
• Funny Interfaces
• No lambda support
• Reachable type explosion
• Not human readable
• Doesn’t use $FAVORITE_TECHNOLOGY
• Versioning incompatibility
• Huge code size
4
GWT Serialization Alternatives
• RequestFactory
• …plain AutoBeans?
• JSOs JsInterop beans
• Gwt-Jackson
• Wrap protobuf.js
• Reimplement Protobuf/g-rpc
RPC RequestFactory AutoBeans JsInterop
Gwt-
Jackson
Protobuf
Funny
Interfaces
X OK ? ? ? ?
No
Lambdas
X X ? ? ? ?
Reachable
Type
Explosion
X OK OK OK X OK
Uses
Generators
X X X OK X OK
Not
readable
X X OK OK OK ?
Doesn’t
use X
X X OK OK OK OK
Versioning X X X X X OK
Huge Code
Size
X X X OK X ?
6
RPC is crap.
• …might not be a fair assessment
• Some of this is a bit subjective
• Criteria are picked out against RPC
7
Points we skipped
• Supports polymorphism (beats all but gwt-jackson)
• "Feels" like Java (beats all) for easier adoption
• Supports useful types:
• Date
• long
• enum
8
Generators revisited
• APT didn’t exist when Generators came about
• Even RequestFactory was written after APT
• Uses APT for validation on server
• APT can’t see the whole world
• Usually we don’t need to
9
The "whole world"
• How much of an app is serializable?
• "shared" module
• shared dependencies
10
J2CL suggestions
• Keep modules smallish, keep client/server separate
• Facilitates incremental (faster) recompilation
• Requires a distinct shared module
11
Whole APT world
• In APT, largest "world" is files changed in last
compile
• Clean build - all files
• Incremental build - only changed files
• Our shared module may be most of the world we
need…
12
Whole APT world
• All this leaves is…
13
(back to this in a minute)
14
Lambda Support
• Why not support Java 8?
• Generators.
• Adding this will require a new, APT-based
implementation
15
Lambda Support: point awarded?
16
Supporting all subtypes
• Except gwt-jackson, these others support no
polymorphism
• For JsInterop/JSO, this includes collections!
17
Supporting all subtypes
• "Collections": why we need more than just a single
shared module
• JRE code
• Useful libraries
• Or, we need to expressly forbid this - for some
teams, more appropriate
18
Options to find all types
• Classpath scanning
• Somewhat expensive
• Assumes (in J2CL) that all are gwt-compatible
• Assumes you want all compiled in (size
concerns)
• Whitelist/Blacklist
• Limit certain types?
• Compiler warnings on large sets of types?
19
"All" vs "Too Many" types
• Becomes a problem of configuration
• Offer multiple options, pluggable tools?
• Or do we assume that all applications are the
same?
• Everyone should just write proto files!
• Or, no one ever needs enums, just use JsInterop!
20
Options to find "all" types
• Somehow limit reach of processor
• By dependency
• By package
• By rules
• Limit or warn on "too general" of types
• GWT-RPC already does this for Object
21
Configured subtypes: +1?
22
Not human readable
• JSON is pretty readable after beautifying it
• Rewriting with APT gives us the exact same server
and client code
• However we’d still need a tool compiled with the
same rules to make this work
• (I haven’t written this yet, but can explain it…)
23
Not human readable: half credit?
24
Doesn’t use X
• We can’t play flavor of the month and rewrite to
support everything
• No Protobuf for GWT impl exists…
• …that is generally available and more than an
experiment
25
Doesn’t use X
ALL OPTIONS
FAIL THIS TEST
26
Changing versions = incompatibility
• "NoSQL" means "NoSchema", just never change
your app, then you won’t need columns!
27
Changing versions = incompatibility
• This is a feature of RPC that JSON is lacking
• Protobufs solves it differently… with more
compiled output
• JSON doesn’t solve it at all, code may just fail
• Today, RPC gives an error, just requires latest
version
28
Changing versions = incompatibility
• If you need one server to support many client
versions, avoid changing types, or use something
which expressly supports this
• Don’t remove fields when sending to client
• Don’t add fields when sending to server
29
Versioning - one right answer for all?
30
Code Size
• What makes code size big?
• Too many types? Too many unused types?
• Too many unused properties server still sends?
• Multiple services supporting the same super-
interface used in all beans?
31
Code Size
• What makes code size big?
• I don’t believe this argument applies to RPC.
32
Huge app from type explosion
• List vs ArrayList
• Map vs HashMap
• One FieldSerializer per supported class
33
Contrast "huge"
• AutoBeans must have code to copy each property
• Protobuf must have code per property (and support
all versions!)
• Plain JSON has no copy…
• …but has full property names all over app
• And either no type safety or…
• Per-property checks!
34
Huge app from type explosion
• How big is big for an app?
• How huge is huge for an explosion?
• I’ve never seen concrete numbers, just a lot of "RPC
is terrible!", so I decided to run some experiments…
35
Place your bets
Simple test:
• control (simple app)
• RequestBuilder, one call
• AutoBeans, one RequestBuilder call
• RequestFactory, one empty bean, one call
• GWT-Jackson, one RequestBuilder call
• RPC tests (cont’d)
36
Place your bets, cont’d
RPC tests:
• void method with no params
• String method, String param
• List Method, List param
• Map Method, Map param
• Collection method, Collection param
Repeat above with Guava in project, unused
Repeat above with "final" serialization turned on
37
RequestBuilder, one call
RF, one empty bean, one call
AutoBeans, one RequestBuilder call
GWT-Jackson, one RequestBuilder call
0 25000 50000 75000 100000
39,424 bytes
9,725 bytes
93,547 bytes
6,705 bytes
38
Results (not in recording)
• RequestBuilder is a baseline, everything else uses
it anyway
• Jackson is pretty big for a simple app, but
RequestFactory is huge!
• AutoBeans are fairly minimal (for a single simple
bean) - low overhead compared to the other two
39
RequestBuilder, one call
RF, one empty bean, one call
AutoBeans, one RequestBuilder call
GWT-Jackson, one RequestBuilder call
RPC, void method, no params
RPC, String method, String param
0 25000 50000 75000 100000
7,281 bytes
7,231 bytes
39,424 bytes
9,725 bytes
93,547 bytes
6,705 bytes
40
Results (slide not in recording)
• RPC is only bigger than plain RequestBuilder (since
it uses RequestBuilder
• Let’s add every reachable collection in a few
experiments…
41
void method, no params
String method, String param
List method, List param
Set method, Set param
Map method, Map param
Collection method, Collection param
List method, List param + Guava
Set method, Set param + Guava
Map method, Map param + Guava
Collection method, Collection param + Guava
Collection method, Collection param + Guava + Final
Map method, Map param + Guava + Final
0 27500 55000 82500 110000
102,298 bytes
99,015 bytes
77,814 bytes
73,378 bytes
58,380 bytes
22,953 bytes
23,678 bytes
19,489 bytes
19,190 bytes
16,044 bytes
7,281 bytes
7,231 bytes
42
Results (slide not in recording)
• Without adding Guava, the biggest possible
explosion of List/Set/Map type is still smaller than
RequestFactory (or even gwt-jackson) with no
collections at all!
• The base application at least used a
LinkedHashMap, LinkedHashSet and ArrayList - but
never used Guava
43
Results (slide not in recording)
• This means that the Guava numbers are the worst
possible case: telling RPC that all Guava types are
allowed, but never using them
• If you use Guava, you would likely already have
included some of those types, so the worst case
scenario of 102KB is actually the worst possible
case, not a baseline!
44
Results (slide not in recording)
• None of these figured account for gzip
45
Type Explosion: Not so bad?
• (bullets not in recording)
• Unless you are deliberately making types or adding
libraries that aren’t used in your app, yet are eligible
to be serialized, you shouldn’t be worried
• Even if you are worried about 20kb in your app, a
future RPC tool will have features to tune this better
46
RPC for a new GWT
• Annotation processor
• Support two JVMs, support version check
• Shared module, not package
• Already a good idea, new suggestion to use
J2CL
• Controls to pick packages/dependencies to scan,
or be specific
• Seems like more work? Reasonable defaults?
• How often is customizing RPC requested?
47
RPC for a new GWT
• Drop ancient browsers
• No more IE6-specific hacks, IE9 memory leak
• TypedArrays?
• Better packing of data, esp with GZIP
• Pass between workers (or MessagePort) for
free
• Still compatible with GWT2
• Existing projects can switch for future-proofing
1 of 47

Recommended

GWT and PWA by
GWT and PWAGWT and PWA
GWT and PWAManuel Carrasco Moñino
2.5K views39 slides
GWT Contributor Workshop by
GWT Contributor WorkshopGWT Contributor Workshop
GWT Contributor WorkshopManuel Carrasco Moñino
1.1K views29 slides
Present and Future of GWT from a developer perspective by
Present and Future of GWT from a developer perspectivePresent and Future of GWT from a developer perspective
Present and Future of GWT from a developer perspectiveManuel Carrasco Moñino
7.1K views58 slides
Devoxx Belgium 2017 - easy microservices with JHipster by
Devoxx Belgium 2017 - easy microservices with JHipsterDevoxx Belgium 2017 - easy microservices with JHipster
Devoxx Belgium 2017 - easy microservices with JHipsterJulien Dubois
4.7K views75 slides
The Java alternative to Javascript by
The Java alternative to JavascriptThe Java alternative to Javascript
The Java alternative to JavascriptManuel Carrasco Moñino
2.7K views81 slides
The future of GWT 2.x - By Colin Alworth by
The future of GWT 2.x - By Colin AlworthThe future of GWT 2.x - By Colin Alworth
The future of GWT 2.x - By Colin AlworthGWTcon
3.1K views20 slides

More Related Content

What's hot

Easy Microservices with JHipster - Devoxx BE 2017 by
Easy Microservices with JHipster - Devoxx BE 2017Easy Microservices with JHipster - Devoxx BE 2017
Easy Microservices with JHipster - Devoxx BE 2017Deepu K Sasidharan
2.9K views75 slides
ng4 webpack and yarn in JHipster by
ng4 webpack and yarn in JHipsterng4 webpack and yarn in JHipster
ng4 webpack and yarn in JHipsterSendil Kumar
1.1K views44 slides
Introduction to Google Web Toolkit by
Introduction to Google Web ToolkitIntroduction to Google Web Toolkit
Introduction to Google Web ToolkitDidier Girard
1.9K views61 slides
GitBucket: Open source self-hosting Git server built by Scala by
GitBucket: Open source self-hosting Git server built by ScalaGitBucket: Open source self-hosting Git server built by Scala
GitBucket: Open source self-hosting Git server built by Scalatakezoe
4.4K views39 slides
Front-end for Java developers Devoxx France 2018 by
Front-end for Java developers Devoxx France 2018Front-end for Java developers Devoxx France 2018
Front-end for Java developers Devoxx France 2018Deepu K Sasidharan
1.1K views54 slides
JHipster Beyond CRUD - JHipster Conf' 2019 by
JHipster Beyond CRUD - JHipster Conf' 2019JHipster Beyond CRUD - JHipster Conf' 2019
JHipster Beyond CRUD - JHipster Conf' 2019Intesys
1.3K views46 slides

What's hot(20)

Easy Microservices with JHipster - Devoxx BE 2017 by Deepu K Sasidharan
Easy Microservices with JHipster - Devoxx BE 2017Easy Microservices with JHipster - Devoxx BE 2017
Easy Microservices with JHipster - Devoxx BE 2017
Deepu K Sasidharan2.9K views
ng4 webpack and yarn in JHipster by Sendil Kumar
ng4 webpack and yarn in JHipsterng4 webpack and yarn in JHipster
ng4 webpack and yarn in JHipster
Sendil Kumar1.1K views
Introduction to Google Web Toolkit by Didier Girard
Introduction to Google Web ToolkitIntroduction to Google Web Toolkit
Introduction to Google Web Toolkit
Didier Girard1.9K views
GitBucket: Open source self-hosting Git server built by Scala by takezoe
GitBucket: Open source self-hosting Git server built by ScalaGitBucket: Open source self-hosting Git server built by Scala
GitBucket: Open source self-hosting Git server built by Scala
takezoe4.4K views
Front-end for Java developers Devoxx France 2018 by Deepu K Sasidharan
Front-end for Java developers Devoxx France 2018Front-end for Java developers Devoxx France 2018
Front-end for Java developers Devoxx France 2018
Deepu K Sasidharan1.1K views
JHipster Beyond CRUD - JHipster Conf' 2019 by Intesys
JHipster Beyond CRUD - JHipster Conf' 2019JHipster Beyond CRUD - JHipster Conf' 2019
JHipster Beyond CRUD - JHipster Conf' 2019
Intesys1.3K views
Testing Java Microservices: From Development to Production by Daniel Bryant
Testing Java Microservices: From Development to ProductionTesting Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Daniel Bryant1.6K views
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020) by Igalia
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)
What's new with JavaScript in GNOME: The 2020 edition (GUADEC 2020)
Igalia64 views
Angry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLal by Raj Lal
Angry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLalAngry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLal
Angry Developer: Creating a Game in QML and JavaScript for MeeGo N9 @iRajLal
Raj Lal6.6K views
Building Rich Internet Applications Using Google Web Toolkit by rajivmordani
Building Rich Internet Applications Using  Google Web ToolkitBuilding Rich Internet Applications Using  Google Web Toolkit
Building Rich Internet Applications Using Google Web Toolkit
rajivmordani3.1K views
JHipster Code 2020 keynote by Julien Dubois
JHipster Code 2020 keynoteJHipster Code 2020 keynote
JHipster Code 2020 keynote
Julien Dubois357 views
JHipster Conf 2019 English keynote by Julien Dubois
JHipster Conf 2019 English keynoteJHipster Conf 2019 English keynote
JHipster Conf 2019 English keynote
Julien Dubois1.7K views
GWT + Gears : The browser is the platform by Didier Girard
GWT + Gears : The browser is the platformGWT + Gears : The browser is the platform
GWT + Gears : The browser is the platform
Didier Girard12.8K views
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021) by Igalia
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
Igalia193 views

Similar to In defense of GWT-RPC By Colin Alworth

SSJS, NoSQL, GAE and AppengineJS by
SSJS, NoSQL, GAE and AppengineJSSSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSEugene Lazutkin
733 views45 slides
Ruby codebases in an entropic universe by
Ruby codebases in an entropic universeRuby codebases in an entropic universe
Ruby codebases in an entropic universeNiranjan Paranjape
709 views96 slides
Messaging, interoperability and log aggregation - a new framework by
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkTomas Doran
3K views67 slides
PHP, the GraphQL ecosystem and GraphQLite by
PHP, the GraphQL ecosystem and GraphQLitePHP, the GraphQL ecosystem and GraphQLite
PHP, the GraphQL ecosystem and GraphQLiteJEAN-GUILLAUME DUJARDIN
1.5K views101 slides
Real time system_performance_mon by
Real time system_performance_monReal time system_performance_mon
Real time system_performance_monTomas Doran
3.4K views43 slides
Scaling with Symfony - PHP UK by
Scaling with Symfony - PHP UKScaling with Symfony - PHP UK
Scaling with Symfony - PHP UKRicard Clau
13K views49 slides

Similar to In defense of GWT-RPC By Colin Alworth(20)

SSJS, NoSQL, GAE and AppengineJS by Eugene Lazutkin
SSJS, NoSQL, GAE and AppengineJSSSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJS
Eugene Lazutkin733 views
Messaging, interoperability and log aggregation - a new framework by Tomas Doran
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
Tomas Doran3K views
Real time system_performance_mon by Tomas Doran
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
Tomas Doran3.4K views
Scaling with Symfony - PHP UK by Ricard Clau
Scaling with Symfony - PHP UKScaling with Symfony - PHP UK
Scaling with Symfony - PHP UK
Ricard Clau13K views
Distributed app development with nodejs and zeromq by Ruben Tan
Distributed app development with nodejs and zeromqDistributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromq
Ruben Tan14.5K views
Applying Testing Techniques for Big Data and Hadoop by Mark Johnson
Applying Testing Techniques for Big Data and HadoopApplying Testing Techniques for Big Data and Hadoop
Applying Testing Techniques for Big Data and Hadoop
Mark Johnson3.2K views
Adding GraphQL to your existing architecture by Sashko Stubailo
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
Sashko Stubailo3K views
SFO15-110: Toolchain Collaboration by Linaro
SFO15-110: Toolchain CollaborationSFO15-110: Toolchain Collaboration
SFO15-110: Toolchain Collaboration
Linaro608 views
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023 by Vadym Kazulkin
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Vadym Kazulkin417 views
An Introduction to the Laravel Framework (AFUP Forum PHP 2014) by daylerees
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
daylerees4.2K views
London devops logging by Tomas Doran
London devops loggingLondon devops logging
London devops logging
Tomas Doran17.3K views
Creating PostgreSQL-as-a-Service at Scale by Sean Chittenden
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at Scale
Sean Chittenden1.2K views
Putting Kafka Into Overdrive by Todd Palino
Putting Kafka Into OverdrivePutting Kafka Into Overdrive
Putting Kafka Into Overdrive
Todd Palino8.5K views
Ruby Performance - The Last Mile - RubyConf India 2016 by Charles Nutter
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
Charles Nutter2.4K views

More from GWTcon

"Jclays, A global solution for application design and automatic GWT code gene... by
"Jclays, A global solution for application design and automatic GWT code gene..."Jclays, A global solution for application design and automatic GWT code gene...
"Jclays, A global solution for application design and automatic GWT code gene...GWTcon
1.2K views19 slides
"Xapi-lang For declarative code generation" By James Nelson by
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James NelsonGWTcon
833 views23 slides
DIY: Split GWT Applications using TURDUCKEN approach By Alberto Mancini by
DIY: Split GWT Applications using TURDUCKEN approach By Alberto ManciniDIY: Split GWT Applications using TURDUCKEN approach By Alberto Mancini
DIY: Split GWT Applications using TURDUCKEN approach By Alberto ManciniGWTcon
2K views29 slides
Unirex Lean tools By Dario Carotenuto by
Unirex Lean tools By Dario CarotenutoUnirex Lean tools By Dario Carotenuto
Unirex Lean tools By Dario CarotenutoGWTcon
868 views27 slides
Web components with java by Haijian Wang by
Web components with java by Haijian WangWeb components with java by Haijian Wang
Web components with java by Haijian WangGWTcon
1.6K views49 slides
UI Framework Development using GWT and HTML Canvas - By Iarosla Kobyliukh by
UI Framework Development using GWT and HTML Canvas - By Iarosla KobyliukhUI Framework Development using GWT and HTML Canvas - By Iarosla Kobyliukh
UI Framework Development using GWT and HTML Canvas - By Iarosla KobyliukhGWTcon
1.6K views22 slides

More from GWTcon (13)

"Jclays, A global solution for application design and automatic GWT code gene... by GWTcon
"Jclays, A global solution for application design and automatic GWT code gene..."Jclays, A global solution for application design and automatic GWT code gene...
"Jclays, A global solution for application design and automatic GWT code gene...
GWTcon 1.2K views
"Xapi-lang For declarative code generation" By James Nelson by GWTcon
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
GWTcon 833 views
DIY: Split GWT Applications using TURDUCKEN approach By Alberto Mancini by GWTcon
DIY: Split GWT Applications using TURDUCKEN approach By Alberto ManciniDIY: Split GWT Applications using TURDUCKEN approach By Alberto Mancini
DIY: Split GWT Applications using TURDUCKEN approach By Alberto Mancini
GWTcon 2K views
Unirex Lean tools By Dario Carotenuto by GWTcon
Unirex Lean tools By Dario CarotenutoUnirex Lean tools By Dario Carotenuto
Unirex Lean tools By Dario Carotenuto
GWTcon 868 views
Web components with java by Haijian Wang by GWTcon
Web components with java by Haijian WangWeb components with java by Haijian Wang
Web components with java by Haijian Wang
GWTcon 1.6K views
UI Framework Development using GWT and HTML Canvas - By Iarosla Kobyliukh by GWTcon
UI Framework Development using GWT and HTML Canvas - By Iarosla KobyliukhUI Framework Development using GWT and HTML Canvas - By Iarosla Kobyliukh
UI Framework Development using GWT and HTML Canvas - By Iarosla Kobyliukh
GWTcon 1.6K views
"Migrate large gwt applications - Lessons Learned" By Harald Pehl by GWTcon
"Migrate large gwt applications - Lessons Learned" By Harald Pehl"Migrate large gwt applications - Lessons Learned" By Harald Pehl
"Migrate large gwt applications - Lessons Learned" By Harald Pehl
GWTcon 1.9K views
GWT Development for Handheld Devices by GWTcon
GWT Development for Handheld DevicesGWT Development for Handheld Devices
GWT Development for Handheld Devices
GWTcon 674 views
GWT vs CSS3 by GWTcon
GWT vs CSS3GWT vs CSS3
GWT vs CSS3
GWTcon 1.2K views
WebTram: una WebApp GWT per l'editing di dati cartografici e topologici di un... by GWTcon
WebTram: una WebApp GWT per l'editing di dati cartografici e topologici di un...WebTram: una WebApp GWT per l'editing di dati cartografici e topologici di un...
WebTram: una WebApp GWT per l'editing di dati cartografici e topologici di un...
GWTcon 987 views
GWT Web Socket and data serialization by GWTcon
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
GWTcon 6.5K views
GWTcon 2014 - Apertura by GWTcon
GWTcon 2014 - AperturaGWTcon 2014 - Apertura
GWTcon 2014 - Apertura
GWTcon 699 views
GWT videocall: power-up your mobile & web app with WebRTC by GWTcon
GWT videocall:  power-up your mobile & web app with WebRTCGWT videocall:  power-up your mobile & web app with WebRTC
GWT videocall: power-up your mobile & web app with WebRTC
GWTcon 1.9K views

Recently uploaded

ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...Jasper Oosterveld
27 views49 slides
virtual reality.pptx by
virtual reality.pptxvirtual reality.pptx
virtual reality.pptxG036GaikwadSnehal
18 views15 slides
GDSC CTU First Meeting Party by
GDSC CTU First Meeting PartyGDSC CTU First Meeting Party
GDSC CTU First Meeting PartyNational Yang Ming Chiao Tung University
11 views25 slides
Five Things You SHOULD Know About Postman by
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
38 views43 slides
Vertical User Stories by
Vertical User StoriesVertical User Stories
Vertical User StoriesMoisés Armani Ramírez
17 views16 slides
SUPPLIER SOURCING.pptx by
SUPPLIER SOURCING.pptxSUPPLIER SOURCING.pptx
SUPPLIER SOURCING.pptxangelicacueva6
20 views1 slide

Recently uploaded(20)

ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman38 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec15 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker48 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty22 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10345 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
"Running students' code in isolation. The hard way", Yurii Holiuk by Fwdays
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk
Fwdays24 views

In defense of GWT-RPC By Colin Alworth

  • 1. In Defense of GWT-RPC Presenter: Colin Alworth Co-Founder colin@vertispan.com
  • 2. RPC is horrible and you should stop using it. Presenter: Colin Alworth Co-Founder colin@vertispan.com
  • 3. 3 GWT-RPC’s Problems • Funny Interfaces • No lambda support • Reachable type explosion • Not human readable • Doesn’t use $FAVORITE_TECHNOLOGY • Versioning incompatibility • Huge code size
  • 4. 4 GWT Serialization Alternatives • RequestFactory • …plain AutoBeans? • JSOs JsInterop beans • Gwt-Jackson • Wrap protobuf.js • Reimplement Protobuf/g-rpc
  • 5. RPC RequestFactory AutoBeans JsInterop Gwt- Jackson Protobuf Funny Interfaces X OK ? ? ? ? No Lambdas X X ? ? ? ? Reachable Type Explosion X OK OK OK X OK Uses Generators X X X OK X OK Not readable X X OK OK OK ? Doesn’t use X X X OK OK OK OK Versioning X X X X X OK Huge Code Size X X X OK X ?
  • 6. 6 RPC is crap. • …might not be a fair assessment • Some of this is a bit subjective • Criteria are picked out against RPC
  • 7. 7 Points we skipped • Supports polymorphism (beats all but gwt-jackson) • "Feels" like Java (beats all) for easier adoption • Supports useful types: • Date • long • enum
  • 8. 8 Generators revisited • APT didn’t exist when Generators came about • Even RequestFactory was written after APT • Uses APT for validation on server • APT can’t see the whole world • Usually we don’t need to
  • 9. 9 The "whole world" • How much of an app is serializable? • "shared" module • shared dependencies
  • 10. 10 J2CL suggestions • Keep modules smallish, keep client/server separate • Facilitates incremental (faster) recompilation • Requires a distinct shared module
  • 11. 11 Whole APT world • In APT, largest "world" is files changed in last compile • Clean build - all files • Incremental build - only changed files • Our shared module may be most of the world we need…
  • 12. 12 Whole APT world • All this leaves is…
  • 13. 13 (back to this in a minute)
  • 14. 14 Lambda Support • Why not support Java 8? • Generators. • Adding this will require a new, APT-based implementation
  • 16. 16 Supporting all subtypes • Except gwt-jackson, these others support no polymorphism • For JsInterop/JSO, this includes collections!
  • 17. 17 Supporting all subtypes • "Collections": why we need more than just a single shared module • JRE code • Useful libraries • Or, we need to expressly forbid this - for some teams, more appropriate
  • 18. 18 Options to find all types • Classpath scanning • Somewhat expensive • Assumes (in J2CL) that all are gwt-compatible • Assumes you want all compiled in (size concerns) • Whitelist/Blacklist • Limit certain types? • Compiler warnings on large sets of types?
  • 19. 19 "All" vs "Too Many" types • Becomes a problem of configuration • Offer multiple options, pluggable tools? • Or do we assume that all applications are the same? • Everyone should just write proto files! • Or, no one ever needs enums, just use JsInterop!
  • 20. 20 Options to find "all" types • Somehow limit reach of processor • By dependency • By package • By rules • Limit or warn on "too general" of types • GWT-RPC already does this for Object
  • 22. 22 Not human readable • JSON is pretty readable after beautifying it • Rewriting with APT gives us the exact same server and client code • However we’d still need a tool compiled with the same rules to make this work • (I haven’t written this yet, but can explain it…)
  • 23. 23 Not human readable: half credit?
  • 24. 24 Doesn’t use X • We can’t play flavor of the month and rewrite to support everything • No Protobuf for GWT impl exists… • …that is generally available and more than an experiment
  • 25. 25 Doesn’t use X ALL OPTIONS FAIL THIS TEST
  • 26. 26 Changing versions = incompatibility • "NoSQL" means "NoSchema", just never change your app, then you won’t need columns!
  • 27. 27 Changing versions = incompatibility • This is a feature of RPC that JSON is lacking • Protobufs solves it differently… with more compiled output • JSON doesn’t solve it at all, code may just fail • Today, RPC gives an error, just requires latest version
  • 28. 28 Changing versions = incompatibility • If you need one server to support many client versions, avoid changing types, or use something which expressly supports this • Don’t remove fields when sending to client • Don’t add fields when sending to server
  • 29. 29 Versioning - one right answer for all?
  • 30. 30 Code Size • What makes code size big? • Too many types? Too many unused types? • Too many unused properties server still sends? • Multiple services supporting the same super- interface used in all beans?
  • 31. 31 Code Size • What makes code size big? • I don’t believe this argument applies to RPC.
  • 32. 32 Huge app from type explosion • List vs ArrayList • Map vs HashMap • One FieldSerializer per supported class
  • 33. 33 Contrast "huge" • AutoBeans must have code to copy each property • Protobuf must have code per property (and support all versions!) • Plain JSON has no copy… • …but has full property names all over app • And either no type safety or… • Per-property checks!
  • 34. 34 Huge app from type explosion • How big is big for an app? • How huge is huge for an explosion? • I’ve never seen concrete numbers, just a lot of "RPC is terrible!", so I decided to run some experiments…
  • 35. 35 Place your bets Simple test: • control (simple app) • RequestBuilder, one call • AutoBeans, one RequestBuilder call • RequestFactory, one empty bean, one call • GWT-Jackson, one RequestBuilder call • RPC tests (cont’d)
  • 36. 36 Place your bets, cont’d RPC tests: • void method with no params • String method, String param • List Method, List param • Map Method, Map param • Collection method, Collection param Repeat above with Guava in project, unused Repeat above with "final" serialization turned on
  • 37. 37 RequestBuilder, one call RF, one empty bean, one call AutoBeans, one RequestBuilder call GWT-Jackson, one RequestBuilder call 0 25000 50000 75000 100000 39,424 bytes 9,725 bytes 93,547 bytes 6,705 bytes
  • 38. 38 Results (not in recording) • RequestBuilder is a baseline, everything else uses it anyway • Jackson is pretty big for a simple app, but RequestFactory is huge! • AutoBeans are fairly minimal (for a single simple bean) - low overhead compared to the other two
  • 39. 39 RequestBuilder, one call RF, one empty bean, one call AutoBeans, one RequestBuilder call GWT-Jackson, one RequestBuilder call RPC, void method, no params RPC, String method, String param 0 25000 50000 75000 100000 7,281 bytes 7,231 bytes 39,424 bytes 9,725 bytes 93,547 bytes 6,705 bytes
  • 40. 40 Results (slide not in recording) • RPC is only bigger than plain RequestBuilder (since it uses RequestBuilder • Let’s add every reachable collection in a few experiments…
  • 41. 41 void method, no params String method, String param List method, List param Set method, Set param Map method, Map param Collection method, Collection param List method, List param + Guava Set method, Set param + Guava Map method, Map param + Guava Collection method, Collection param + Guava Collection method, Collection param + Guava + Final Map method, Map param + Guava + Final 0 27500 55000 82500 110000 102,298 bytes 99,015 bytes 77,814 bytes 73,378 bytes 58,380 bytes 22,953 bytes 23,678 bytes 19,489 bytes 19,190 bytes 16,044 bytes 7,281 bytes 7,231 bytes
  • 42. 42 Results (slide not in recording) • Without adding Guava, the biggest possible explosion of List/Set/Map type is still smaller than RequestFactory (or even gwt-jackson) with no collections at all! • The base application at least used a LinkedHashMap, LinkedHashSet and ArrayList - but never used Guava
  • 43. 43 Results (slide not in recording) • This means that the Guava numbers are the worst possible case: telling RPC that all Guava types are allowed, but never using them • If you use Guava, you would likely already have included some of those types, so the worst case scenario of 102KB is actually the worst possible case, not a baseline!
  • 44. 44 Results (slide not in recording) • None of these figured account for gzip
  • 45. 45 Type Explosion: Not so bad? • (bullets not in recording) • Unless you are deliberately making types or adding libraries that aren’t used in your app, yet are eligible to be serialized, you shouldn’t be worried • Even if you are worried about 20kb in your app, a future RPC tool will have features to tune this better
  • 46. 46 RPC for a new GWT • Annotation processor • Support two JVMs, support version check • Shared module, not package • Already a good idea, new suggestion to use J2CL • Controls to pick packages/dependencies to scan, or be specific • Seems like more work? Reasonable defaults? • How often is customizing RPC requested?
  • 47. 47 RPC for a new GWT • Drop ancient browsers • No more IE6-specific hacks, IE9 memory leak • TypedArrays? • Better packing of data, esp with GZIP • Pass between workers (or MessagePort) for free • Still compatible with GWT2 • Existing projects can switch for future-proofing