Thursday, July 14, 2016

GWT RPC's future

This post is about why I do not think that GWT RPC is something valuable to be carried forward.
I am also being slightly harsh with GWT RPC which has served many GWT applications as a good RPC mechanism. Please keep in mind that this post is not about assigning blame, I do think that the engineers who designed GWT RPC did a great job, they just had other more important goals in mind.

When I first discovered GWT RPC in somewhat 2008 I thought it was magical. Send all my Java objects over the wire and just use them on the client side. All I need to do is define a simple interface. I loved it.

But as time went by I have started to dislike GWT RPC more and more. This blog post is about the bad choices that GWT RPC has made and why I do not think its a good choice to be carried forward for applications that transpile Java to JavaScript. However this does not mean that its not possible to port it forward (with some changes), but I think its not worth it there are simply better alternatives.

Bad choices

GWT.create call type inheritance broken

AsyncChronousVersion instance = GWT.create(SynchronousVersion.class);
Why do I need to pass in the synchronous version? From a type perspective this does not make any sense what so ever.
The synchronos version extend the RemoveService interface, the asynchronos version did extend nothing. Why not simply use the Asynchronous version all the way?
If you know what a GWT.create call looks like in the compiler you realize that this is really broken.

Exploding code size

Let's take a look at the second problem that GWT RPC has that is way more severe.
Assume we have this simple RPC interface:

public interface MyServiceAsync {
  void doSomething(List strings, AsyncCallBack callback);

The interface defines a simple method that takes a list of strings. The problem with this code becomes apparent when we take a look at the serializers and deserializers that have to be generated for this class. Since we need to have a serializer for every concrete type that we have in the program, you end up with potentially hundereds of serializers just for this one method.
The GWT team always recommended to be as specific as possible to get rid of this flaw, but this is against a core design principle in Java. We want List on the interface, not ArrayList.

Doing a simple search for subtypes of ArrayList in a hello world GWT applications returns 16, this is obviously a bad choice.

Version skew during deployment

Because of the need for serializers that were specific to your current applications, GWT RPC had a serious issue with version skew. Make a slight changes to your problem and you might have ended up causing GWT RPC to fail between these version of your app. When you have multiple thousand servers running you will always have an old client talking to a new server or an old client talking to a new server. Not dealing with this is unacceptable for a RPC system and has cost many teams at Google headaches.

Slow compiles due to global analysis

If you want to generate all the serializers of a type you need to have global knowledge of your program. You need to be able to answer questins like:

  • "Who is implementing this interface?"
  • "Who is subclassing this class"
This means that you can not incrementally compile GWT RPC code since you would not be able to answer these questions correctly. The only reasons that super dev mode works with GWT RPC is that we do the initial slow full world compile and then keep track of these types as you update your code.If you want really fast compiles, which we want for GWT 3.0, you really do not want any global knowledge.

GWT RPC can not be done with a Java annotation processor

All other GWT code generators can be changed to be Java annotation processors, since they do not require global knowledge. Since GWT RPC requires global analysis it can not be easily ported.

But I really like GWT RPC, what can I do?

Well as I said earlier in this post, you can port it to an APT, but you need to make changes to it:

  - Change the interface to list all the types it needs so you do not require global knowledge
  - Remove the synchronous or asynchronous interface and generate one from the other
  - Replace the GWT.create call
  - Make the serialization format compatible with different versions of your app, by the way this is what we do with GWT proto RPC, which unfortunately is not open source.

This could potentially look like this:

public interface MyServiceAsync {
  void doSomething(@Serializer(accept = {ArrayList.class}) List strings, ...)

// MyServiceAsync_Factory is generated by an APT
MyServiceAsync service = MyServiceAsync_Factory.create();

I hope this blog post helps people that really like GWT RPC to understand why there are better choices one can make for a RPC mechanism and why we should be striving to have something better.


  1. There are multiple ways to fix the async interface:

    1. Rewrite it around a promises paradigm.
    2. Get rid of GWT.create mechanism and use an annotation processor to generate the Async proxy. IE something along the lines of @GWTRemoteService annotation on the interface instead.

    The other 3 issues are less about GWT RPC and more about SerializationPolicy implementation details and the fact that it is buried so deeply in the process. It is hard to dig through and replace the SerializationPolicy generation and even if you do, you don't bypass the old one. So I think a simple solution there would be to make the SerializationPolicy and its generator easily replaceable.

    If we could just expose the hooks that are needed into the system to create the pieces of the underlying RPC mechanism, then we could have different RPC libraries with a common interface. That should be the ultimate goal, imo. At the end of the day, GWT RPC is a set of interfaces from a consumers standpoint, those interfaces are not necessarily inherently flawed and there is no reason we couldn't have drop in replacements for different flavors of RPC.

    1. COPE TECHS is an organization of Technology experts🖥️💻 with the aim to help individuals with solving Technology difficulties. We offer the best hacking services as well as our aim is not for Theft purpose but to help individuals overcoming Technology issues with our skills.

      ✴️For example-: There are so many individuals out there who owe a lot of debts💶💷 to Banks and other Loan Firms and are working hard 🛠️⚒️to pay back but really can't pay. That's were our services can help you, we have a way of generating Bitcoin and funding it into a PayPal account and by this you can pay your debts.

      ✴️Another Example of our service-: A Man or Woman who suspects his/her Spouse of Cheating but have no prove, we could help by HACKING the Spouse Cell phone📱 so he/she could get access to Chats, Emails📩, Location📍, Phone calls 📞and text message✉️ of the Spouse anywhere they are.

      ✴️We also Help student in Universities/College/High Institute📚 in changing their Grades/results saving them from repeating exams and giving them a better Degree.
      Other services we offer are-:
      ✴️Clearing of Bad Records from Courts and Police facilities.
      ✴️ Detection of weakness in Computer system security⚛️
      ✴️Funding a PayPal account💷💵
      ✴️Cyber Attacks☣️ and lots more
      Put this on your mind, "AS LONG AS IT'S TECHNOLOGY, IT CAN BE HACKED"
      We belong to the HACKERS forum HackerOne and we have the Top hackers in the forum always ready to take the risk and do a job. If you need hacking Services, contact-: COPETECHS@GMAIL.COM
      We look forward to hacking for you.

    2. Great Article
      android based projects

      Java Training in Chennai

      Project Center in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Hi Jonathon,

    how would to implement serialization for List<> for any generic implementor of the interface in JavaScript without a significant code size hit?
    The fundamental problem here is that one can choose arbitrary Java objects on the interface and thus will always end up with that kind of bloat.

    1. I would imagine a similar case to the current code pruning to determine actual types returned. The actual call tree for a particular RPC service is generally relatively small. IE a service calls a database or another service and does some conversion of the data to a model that is returned to the UI. The implementations of the RPC interface and its call tree could be analyzed to determine what type is actually returned using some form of static analysis and mark that serializer as used. This could also be assisted, as you recommended, with an annotation. I would like the annotation to be on the implementation instead of the interface though. There could possibly be multiple implementations of said interface, yes, but either of those approaches would still be better. Finally, another option, if I return a generic interface, especially a List or Map or Set, I think there would be an option to ignore the actual implementation that is returned and use a generic serializer that creates a particular implementation of the object. This could also be assisted on client side with some configuration in the module file.

      Another, current way, to limit the code bloat is to increase the RPC blacklist. I have done so on the majority of my own projects. I have, across all my projects, blacklisted everything that exists in a *.client.* package, with some tuning for particular gwt things. So I could see a scenario where you scan the rpc interfaces and implementations, then scan the generated AST for the client side, look for actual concretely used implementations during the RPC calls and make a decision as to whether or not the actual implementation is needed or a designated common generic serializer could be used.

      Another kind of similar practical approach would be to incorporate a bit more hierarchy in the serialization generators. Most of the collection/map custom field serializers are based upon two custom field serializers in GWT core. Those could theoretically be leveraged to generate a field serializer for all collections. So all you would need for the majority of collection types would be to generate a base custom field serializer, designate that, and do a pregeneration of serializers, then utilizing code pruning, eliminate those that are never used.

      Finally, instead of using a regular annotation processor, one could utilize a java agent, moving the serialization out of post processing to compile time processing.

      I think, some in part or all of the above proposals, along with modularizing the SerializationPolicy generator interface and the underlying GWT RPC architecture would make "GWT RPC" be less about the current implementation and more about the manner in which RPC is consumed.

  3. Which are the "better alternatives"? You mention them at the beginning of the post but they are not named. We would like to know what should we use in the future if GWT RPC is going to be deprecated.

  4. Some question from my side. Is Errai or RestyGWT good alternative? We are in the process of replacing GWT-RPC in our ERP app. Should we jump on some of this alternative or better to wait?

  5. With GWT 3.0 most will go with REST or protocol buffers which are much lighter...

  6. I purposefully did not mention any replacements for GWT RPC. I strongly believe that people should take the time to understand how a certain mechanism works and then decide if it fits their purpose well.
    If I recommend something here it looks like a straight recommendation from the GWT team which I do not want. I'd rather see different RPC solutions evolve and become better and convince users by having a solid technical approach.

  7. OK, thanks. It would be very useful for us to have a list of the alternatives to RPC which are (or will be) included in the GWT library. Is this possible? Thanks!

  8. You do point some issues with that but all of them I can match with numerous issues in ANY other approach. We use GWT RPC to a very large extent and have solved / worked around some of the issues you mention. Specifically, we use GWT RPC mainly for serialization. No other known framework offers anything close to the functionality that GWT serialization has, such as, for example, maintaining proper object graphs without duplicating instances that have multiple references to them (that is just one, there are others).

    We route *everything* through essentially one single service and one single method in that service - we pass expression trees to this method that are, then, evaluated on the server. The code backing these expression trees is partly generated and it looks as if the client can make the calls to the server just by annotating a server-side method. The only difference is that all calls are asynchronous so, *if* you want the return value you need to pass an AsyncCallback.

    Slow compiles are a problem especially when interfaces are used for field declarations, which is why we avoid those. But this *can* be addressed in the GWT compiler easily with more efficient searching. It appears as if it is searching over and over again for those instead of storing the class hierarchy somewhere and using it as an index, but this may not really be the case.

    In any case, GWT RPC can be improved, it does not and should NOT be dropped.

  9. This comment has been removed by the author.

    1. I just wrote a post about alernatives to RPC in GWT: 
      Hope it helps.

  10. Download Showbox on Mac and Official Showbox app for iOS. Download showbox for your iPhone and iPad to stream free online movies, TV shoes and series and also download movies

  11. GBWhatsapp apk Download Latest Version 2018. Download Latest GB Whatsapp for Use 2 Whatsapp in One Mobile.  GBWhatsApp APK

  12. Use dual account with GBwhatsapp Latest Application With free of cost. Gbwhatsapp Apk

  13. WPS WPA Tester App will help you see the number of connections to your network using Smart phones.

  14. Which are the "better alternatives"? You mention them at the beginning of the post but they are not named. We would like to know what should we use in the future if GWT RPC is going to be deprecated. gb whatsapp latest version

  15. This comment has been removed by the author.

  16. Gbwhatsapp is the best modded app of popular application nowadays. I am very confident to say you will like this app, because its have many features.


  17. Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading.

  18. Nice post. I learn something totally new and challenging on websites I stumbleupon every day. It's always useful to read through articles from other authors and practice something from other sites.
    Thanks for sharing this information with us. Download Free Xmod and information. Xmod games dot org

  19. Schoolwear Centres specialises in supplying school uniforms, with embroidered Logos to schools across UK. Our year –round services saves you time, stress and money.for more info visit Our Websites

  20. Owning a small business is a huge accomplishment and also a burden at the same time. All small business owners know how liberating it can be to break free from the 9-5 and strike it out on your own.

  21. We all know about the app GBWhatsApp which is the most popular among all mods of whatsapp. It is unofficial also but there is a lot of features in this app that made people crazy. Today with the new technology people want advance technology in modern era that’s why people attracted more with mods of apps then official. As we know that there are many mods of whatsapp available but GBWhatsApp is the best in all of these.for more Updates Visit Our GBWhatsApp APK

  22. We are the best platform for those who don’t have the learning facility in their area. Our plan is to make the Muslims learn the Holy Book in the best possible manner. We teach with the correct voicing Learn quran online.

  23. Thank you for sharing valuable information. Nice post. I enjoyed reading this post.

  24. A special thanks to My Assignment Help for providing an exceptional assignment within a short period of time. Your work is really amazing. Hope you reach heights in the future.You can email us at cs@Myassignmenthelpau.Com or Phone Number: +61-2-8005-8227

  25. Watch Pinoy TV, Pinoy Tambayan website to watch all Pinoy Lambingan Orihinal, Teleserye Replay shows of Pinoy Channel Online. Pinoy Lambingan.

  26. Here, Spinbot is available to rewrite human-readable content. Moreover, if you are not free to write content daily, then you should try our bot to rewrite readable content.

  27. Online Quran Classes for kids to learn the reading, Kids Quran Memorization, Quran lessons for kids and children. Your kids will have one on one attention in online.

  28. Transworld gives a submarine fiber optic link organize. Transworld convey web data transmission through a TIER-1 system to Cellular systems, ISPs, corporate association and an immense number of the little and medium association the whole way across Pakistan. The organization gives us an approach to interface with the computerized world. Income tax calculator


  29. To open an APK record on your Android gadget just necessitates that you download it like you would any document, and after that open it when inquired. In any case, APK documents introduced outside of the Google Play store probably won't introduce immediately on account of a security square set up.
    dream league mod apk
    Kick the buddy mod apk
    real racing 3 mod apk
    Netflix mod apk
    Pixel gun 3d mod apk
    Kingdom Rush Hack apk
    Shadow fight 2 mod apk

  30. To sidestep this download confinement and introduce APK documents from obscure sources, explore to Settings > Security (or Settings > Application on more established gadgets) and afterward put a check in the case beside Unknown sources. You may need to affirm this activity with an OK.
    Free Fire Mod apk
    Gangstar Vegas Mod apk
    Dead Trigger Mod apk
    Tinder apk
    Fifa Mobile Hack
    Kinemaster Mod apk

  31. In addition, it is a 2.5D battling game. Along these lines, on the off chance that you have a furor for battling, at that point you should benefit this opportunity in light of the fact that the last form of this game is one of my preferred games. Mortal Kombat 11 Ps4
    Love Calculator

  32. Wow Nice Blog Post Amazing Must Visit The Following links Amateur Blogs
    Its Very Helpful for you Amateur Blogging
    Recommended for you Amateur Blog

  33. I think by luck I have got what I needed. Thank You So Much Friend I really Need this type of Post Right Now. You may also visit my website where you will find the best graduation products like Diploma Covers, Diploma Holders, Wholesale Diploma Covers, Custom Diploma Cover, Graduation Tassels online.

  34. I'm browsing the Internet to get information and find your blog. I am impressed with the information you have on this blog.

  35. This blog is clean and to the point. Thank you so much for creating awareness and for creating such a wonderful blog. I mean it. Also, check my website of best graduation products like AwardCovers, Custom Graduation Cords, Diploma Folder, Certificate Holders, Paper Certificate Holders, Padded Certificate Holders, Padded Diploma Covers, Leather Diploma Cover, Custom Certificate Holder

  36. This is Very very nice article. Everyone should read. Thanks for sharing. Don't miss WORLD'S BEST BikeRacingGames

  37. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading.
    Update Xperia Z2 Tablet SGP511

  38. I like your post very much, because it is very well explained. Thanks for sharing a wonderful post. You can go through my online shopping website to grab the best Diploma Holders, Custom Diploma Cover, Certificate Cover at a great price.

  39. I suggest all members choose SPSS Assignment Help Australia for the best guideline in your academia. The perfect and expert assistant your requirement and learning assignment project by the university.

  40. Thanks for sharing such a wonderful post with us. I really liked the way you described all the things clearly and to the point. Keep up the good work. And in the meantime, if you like to buy graduation products then you can visit my website which is all about graduation items like Diploma Covers, Custom Diploma Folder, Diploma Cover, Diploma Holder, Award Covers, Graduation Tassel online.

  41. Its really nice to see such a beautiful post. I will keep track of your website every week. And I have subscribed the RSS feed. In meantime if you have got time please visit my stationery related website where you will find some best quality stationery like Customized Legal Pads, Legal Pads, Custom Printed Letter Pads, Letter Pads, Colored Legal Pads, Legal Notepad, Branded Notepads .

  42. Thanks for sharing such a wonderful blog. I really liked the way you described. This blog will be help full for computer science students to understand how to develop web and mobile app.

  43. Wow such a nice post shared here. I will keep a weekly track on your website and also subscribed to the RSS feed to get notified about your post. In meantime if you may like to visit my website about stationery graduation and office products like Personalized Leather Portfolio, Personalized Leather Padfolios, Custom Leather Portfolio, Monogrammed Leather Portfolios at a great price.

  44. thaks admin for that. that is very great work and use full for users.

  45. I love it when people get together and share views. Great site, Eunidrip company has wealth of experience in drilling boreholes. Our aim is to provide quality, clean water and boreholes that can be well maintained and long lasting. We are a Class “A” water contractor certified by the Ministry of water and Irrigation. Greenhouse Construction in Kenya for more.

  46. It is a great chance I had to read your amazing article for sure I have cached for future reading. Kindly keep updating us on new articles. Are you health conscious? Have you suffered from the negative effect of water quality? then Best Whole House Sediment Water Filter System is for you, For best experience in water purification.

  47. The company’s supply chain strategies allow it also to provide to the market with products and services at the right time. article writer

  48. Public
    Buyers and sellers of used cars or seminovos are here for fazer bon bons. Create a comparison list of Buy cars - see cars or a visualization list to compare features of several vehicles at a time of month, is is for Make it easy for you to find and buy your new car.

    Car Ads
    Buy used car or seminovo: Buy ou sell used car : in all the States of Brazil. Advertisements of private cars, resellers and dealerships. Check out announcements of new vehicles every day: Faça uma research by brand or model easily and quickly using our detailed search filter na sessão de Carros a Venda ou na Homepage

  49. Thank you for bringing to a halt my long search topic. I really benefited from your content. If you are experiencing trouble striking a balance between your busy academic life and handling your online classes, you can get help from a professional who will take online classes on your behalf. It doesn’t matter the kind of help you need, whether it is passing your exam, finishing your assignments or even the entire classwork, you can get help here at Online Class Help .

  50. Hello there, great stuff you’ve shared here I will be checking regularly for more articles. But wait! When it becomes hard to manage your online assignment, availing Online Assignment Help is the best choice. Many students often fail to submit their assignment before deadlines and end up scoring low grades because they didn’t have enough time to write the assignment given on time and satisfactorily. Visit Assignment Help . for assistance.

  51. Assignment Help is something most students are actively and constantly searching for assignment writing, regardless of their academic level. Students who lack knowledge and skills to develop proper assignment writing fears hearing the writing of word assignments. online assignment help is all you need to relieve the tension in these circumstances. By that point, the writing of the assignment is just what you need. They provide 100 per cent positive outcomes to customers, including providing expert advice and services. We offer top service assignment help Australia by 1000+ native experts with record of on time delivery. Get your modification done online for any subject assignment. Securing high grades made easy with assignment help.

  52. What an informative article. Tell you what I have bookmarked your website for regular checkup. Thank you for taking time to share such a great content. Are you puzzling about who to contact for Nursing Writing Services? Could it be that you are working on a tight budget yet need high-quality nursing-related assignments? Is it the efficiency that you are looking for? Well, with the popularity that the nursing course has gained over the years, there are a lot of gaps to fill in the health sector. Read more on Nursing Writing Services.

  53. What an informative article. Tell you what I have bookmarked your website for regular checkup. Thank you for taking time to share such a great content. Are you puzzling about who to contact for Nursing Writing Services? Could it be that you are working on a tight budget yet need high-quality nursing-related assignments? Is it the efficiency that you are looking for? Well, with the popularity that the nursing course has gained over the years, there are a lot of gaps to fill in the health sector. Read more on Nursing Essay Writing Services.

  54. du hoc canada vnsava
    Chuyên du học Canada Công ty tư vấn du học Canada nào tốt
    Điều kiện du học Canada 2021
    Học bổng du học Canada vnsava

    Thông tin du học Canada mới nhất

    Chính sách du học Canada 2020
    Du học Canada bao nhiêu tiền Việt
    Học bổng du học Canada 2020
    Du học Canada 2020
    Nhất ký du học Canada
    Du học Canada nên học ngành gì
    công ty tư vấn du học Canada vnsava, chính sách điều kiện định cư Canada, học bổng, chi phí, điều kiện xin visa canada

  55. Thank you for your outstanding article. You will always find clients coming back to us which is a result of our excellent services. Our goal is to offer unique and specialized services to our clients and in return create a long-lasting working relationship. The best thing about working with us being that, we provide samples for any client who would want to see some before ordering from us. Learn more from Nursing Care Plan.