Wednesday, September 16, 2020

Re: New Presentation about Modern GWT Webapp Development

On Wednesday, September 16, 2020 at 6:49:36 PM UTC+2, wrote:
Hi Thomas,

... actually I feel that doing platform specific stuffs in my code it's not the way.

It is comparable to GWT vs. jsweet. In GWT you have everything in Java semantic. In jsweet you actually have everything in Java but with JavaScript semantic. jsweet is for me still better than JavaScript 😉but I lost the Java semantic.

Putting platform specific stuffs in the code mixes the separation of concern, IMHO...

Last time I wrote super-source was… last week!
Using @JsType(isNative=true,namespace=GLOBAL,name="Object") classes to talk to ProseMirror, translating between some XML and those JS objects (context:
In this case, this is purely client code, but I didn't want to use a GWTTestCase to test my XML↔Objects transforms, so I wrote the test to run in the JVM (and also made it work in a GWTTestCase, to make sure it does indeed work, but it's a lot slower).
Now how would you handle arrays? Well, I just use a @JsType(isNative=true,namespace=GLOBAL,name="Array") with a few @JsOverlay methods delegating to Js.asArrayLike(this)… in the super-source, with a simplement implementation wrapping an ArrayList for the JVM.
And how to compare the object trees in the tests? I cannot use things like isEqualToComparingFieldByFieldRecursively, and I didn't want to build something equivalent just for tests, so I just serialize them to JSON, using JSON.stringify() in super-source for GWT (not directly JSON.stringify() though, as object fields are not in a predictable order, but more, which relies on JSON.stringify for "primitive" values), and GSON (that we already have around in GWT) in the JVM.
Of course I could have built things differently, with abstract factories so I could inject a GWT-specific or a JVM-specific one, and I actually went that route initially, but honestly, just so I can use a different List subclass within tests?

(granted, the previous time I wrote super source, besides GWT's own javaemul, was a long time ago :D but I never really shared a lot of code between server and client anyway: besides that rich text editor, those 10 other subproject dependencies are actually only there for enums and some constants, and of course one of them is about RequestFactory interfaces)

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment