GWT Collection Performance and Recommended Practices

What is the best way and / or recommended practice for working with collections in GWT, especially if you are looking for performance?

The options I have found so far are:

  • JRE emulates collections. Most of the natural way for a Java developer, but, in the GWT command words "is not an ideal match for restrictions within browsers, especially mobile browsers." can be found here and here

  • GWT Lightweight Collections . Between other improvements, they promised to bring a minimum compiled script size and an absolute maximum speed. However, there is no news regarding this project for 7 months.

  • Guava libraries Is it safe to use Guava in GWT? If so, does it bring a real performance improvement?

Any other alternatives?

Thank you very much

+4
source share
2 answers

If you are looking for absolute optimal performance in the browser, you should use something like Lightweight Collections - your own JS arrays and only maps, and all contained objects - like JavaScriptObjects (overlay types).

However, this will greatly limit your coding efficiency, since they are not at all as easy to use as the JRE collections. No contains() , no improved for loops, none of the intricacies of Java. And in the end, the "subtleties of Java" seem to be the reason that you are programming in GWT rather than JS.

Guava does not strive to bring any special benefits to the GWT application, it basically just provides a simpler coding experience, and sometimes a tiny optimization here and there that you might not have considered. Guava is not optimized for GWT, it is just available in GWT.

So, this is for you. If you want to use regular Java collections, you must use Guava. If you want absolute maximum performance, do everything in your own collections.

+5
source

Agree with the previous answer and provide additional information:

GWT Light collections designed for customers only. If you want to transfer them using the RPC mechanism, most likely you will end the exception.

Another approach to speeding up JavaScript is to use arrays instead of collections, where it is possible for both transport and processing. Arrays are closer to their JavaScript counterparts, and GWT does not compile too much wrapping code for compatibility purposes.

I would not expect any performance benefits from Guava.

+3
source

Source: https://habr.com/ru/post/1337397/


All Articles