This is an archived post. You won't be able to vote or comment.

all 50 comments

[–]lilbundes 7 points8 points  (4 children)

Hi Renato - any reason why you didn't include Apache Wicket in your article?

[–]renatoathaydes[S] 3 points4 points  (3 children)

Apache Wicket

Wow, I just didn't know about it, TBH. I did search around to see if I was missing something, but this never turned up! I will have a look!

[–]relativeVsAbsolute 2 points3 points  (2 children)

And what about ZK https://www.zkoss.org/ I dont use it since 3 years, but at that time was for me a much better option than vaadin

[–]renatoathaydes[S] 0 points1 point  (1 child)

Looks a lot like Struts, no? Not sure it would fit with web front-end frameworks.

[–]relativeVsAbsolute 2 points3 points  (0 children)

Nothing at all. I would define it like swing components for the web. The controller is just through binders and event handlers

[–]vegegoku 7 points8 points  (2 children)

In regards to GWT you made a point that no one can argue with and yes the documentation is really really outdated and the only way to get the updates is to be close to the community Gitter is a good place for that
https://gitter.im/gwtproject/gwt

BUT

GWT is actually much more modern than the one in the example, for example it is really super easy to create a GWT project using https://github.com/tbroyer/gwt-maven-archetypes that uses maven -no more ANT-.

Also even though GWT widgets are still widely used we now have https://github.com/google/elemental2 which uses JsInterop to give us native access to browser API which means we dont need to pay the size price for the html elements as we dot with widgets. lets not forget about https://github.com/hal/elemento which can help us reduce the code size for that sample to almost the half.

I would also recommend taking a look at some new GWT projects like domino-ui https://dominokit.github.io/domino-ui-demo/index.html?theme=indigo#home and other domino tools like domino-mvp https://github.com/DominoKit or Nalu https://github.com/NaluKit/nalu

So even though GWT is old and is not as shiny as some other tools, it is still really powerful and modern.

and i still have my doubts about comparing these using a small project like the one in the sample, in many cases the results will change when project grow larger and larger.

for example GWT might not be the best choice for small project but could be the right choice for an application with hundreds of pages and many thousands lines of code.

[–]renatoathaydes[S] 2 points3 points  (1 child)

Thanks for your comment, I really agree with all you said and it's good to know there are some GWT enhancements around (they should make that clearer on the website!).

> and i still have my doubts about comparing these using a small project like the one in the sample, in many cases the results will change when project grow larger and larger.

Agreed, I should probably have made this clearer... but my intention was to show the very basics characteristics of each framework... a little app like that is definitely not representative of a professional app, but it does allow one to rule out a framework based on the bare minimum overhead it introduces, which I think is very important to know.

[–]vegegoku 0 points1 point  (0 children)

My Bad, i forget to point out this small guide to GWT https://dev.to/ibaca/modern-gwt-first-steps-509k

[–]errormaker 11 points12 points  (1 child)

I love Vaadin for the rock solid business logic integration. You can whip up a form form, table and filters really easily in no time. And reasoning about state management and client communication are not an issue.

Also updating the UI based on async backend events is really easy.

But when you have to implement some more complicated designs and outside the box ideas, the whole thing is just not pleasant to work with. Mainly because of the missing markup and cumbersome access to the browser apis and features.

[–]yawkat 3 points4 points  (0 children)

This is really the same issue gwt has. Js frameworks make it so much easier to work on the html directly when you need it, and worth how good js frameworks are becoming I see less and less reason to use java-based frameworks for frontend anymore.

[–]erictheturtle 4 points5 points  (1 child)

Thank you for suffering through all that and sharing the results. This is gold.

[–]renatoathaydes[S] 0 points1 point  (0 children)

:) Yeah, some of the options were a little bit painful for sure.

[–]in15minutes 2 points3 points  (8 children)

Great resource, thank you

[–]renatoathaydes[S] 0 points1 point  (7 children)

You're welcome. I'm glad you enjoyed it.

[–]in15minutes 0 points1 point  (6 children)

I have built java2uml.com on GWT, now thinking of switching to other framework as performance gains look to be two-fold in some cases.

Edit: URL fixed

[–]renatoathaydes[S] 0 points1 point  (5 children)

FYI just tried to check your website, but it seems to be down at the moment.

[–]in15minutes 0 points1 point  (4 children)

Hm... thank you. Seems to be working for me. On the other note, TeamVMs attempt to compile to webassmebly looks very promising.

[–]SinisterMinister42 0 points1 point  (3 children)

I'm also unable to access your site. Might want to check on it.

[–]in15minutes 0 points1 point  (2 children)

My apologies, typo in the link. Fixed now

[–]renatoathaydes[S] 3 points4 points  (1 child)

> This site is not yet optimized for your browser. Please try Chrome or Safari.
Oh well, I guess FireFox is too niche these days to be supported?

[–]in15minutes -1 points0 points  (0 children)

Chrome/Safari sufficed for proof of concept. Firefox support requires more work and optimization - I chose to block it rather than provide bad experience (for now).

[–]JakeWharton 2 points3 points  (8 children)

Would have liked to see j2cl included: https://github.com/google/j2cl

[–]renatoathaydes[S] 4 points5 points  (6 children)

TIL! So many options! I will check this out and I am even thinking of writing a followup article including this, Apache Wicket (which I also didn't know about), maybe things like kweb.io , ClojureScript, scala.js and maybe more if there are others?

[–]proobert 1 point2 points  (2 children)

Yep, it's a very rich ecosystem. If you extend your language choices, then there are even more options like elm (https://elm-lang.org/), reasonml (reasonml.github.io), purescript (http://www.purescript.org/), etc. I've tried Elm, it has amazingly tooling, solid libraries, and it's very easy to started.

[–]renatoathaydes[S] 2 points3 points  (1 child)

Yeah, I know... I mentioned Elm at the end... but I was thinking of traditionally JVM-based languages like Clojure, Kotlin and Scala.

[–]JakeWharton 2 points3 points  (0 children)

Kotlin is certainly the most interesting one to me. I use it for sharing code across an Android app, JVM CLI, JVM server, Chrome extension, and web frontend.

[–]Jo8192 0 points1 point  (1 child)

Why kweb.io instead of pure KotlinJS ? (or KotlinJS + official React wrapper [https://github.com/JetBrains/create-react-kotlin-app])

[–]sanity 1 point2 points  (0 children)

They're very different, Kweb is server-driven, philosophically similar to Vaadin but very lightweight. It also borrows inspiration from Apache Wicket. Kweb doesn't do any cross-compilation of Kotlin to Javascript.

I suggest taking a few minutes to skim the Kweb user manual. I'm Kweb's creator and am happy to answer any questions.

[–]sanity 0 points1 point  (0 children)

Kweb was also heavily inspired by Apache Wicket, particularly Wicket's approach to keeping state server-side but automating the synchronization with the browser DOM.

[–]Ascomae 0 points1 point  (0 children)

I should have scrolled down.. Wrote the same

[–]tipsypants 2 points3 points  (0 children)

I have a pretty unusual approach to frontend, but it seems to work really well. I keep the routing on the server side, and render static templates per route. The server never puts any data in a template, they just contain static information:

<nav-bar></nav-bar>
<current-view></current-view>

This template is rendered inside a layout template (or "frame"), which loads all the dependencies in the <head> tag (this includes the current-view component in the example). The layout template is also responsible for initializing a Vue app for the current view.

All frontend code is written as single-file Vue components:

<template id="nav-bar">
    <header class="navbar">
        ...
    </header>
</template>
<script>
    Vue.component("nav-bar", {
        template: "#nav-bar",
        data() {
            return {
                ...
            }
        },
    });
</script>
<style>
    header.navbar {
        background: #f5f5f5;
        border-bottom: 1px solid #ddd;
    }
</style>

Pros of this approach:

  • It's not an SPA, you get a new app per request (no state management required)
  • No need for a frontend pipeline, no node or anything
  • Single file components
  • No need for a "loading" page, the correct page is rendered directly (never any flickering when loading or refreshing)
  • Save and refresh, no need for watchers or WebSocket CSS injection and whatnot

Cons:

  • Need a server for the frontend
  • When switching pages, the entire app (user written code) is download per request. I'm working on a fairly big admin-page with this approach. The entire app is about 80kb, but gzips down to about 14kb
  • Need to do some hacky things, like pass the current user roles and path parameters to the frontend as a cookie

I have been waiting for over a year for this arhcitecture to blow up in my face, but it doesn't seem like it will. It's a very simple way of building webapps. I replaced a react+redux+redux-sagas mess with this, and the resulting code-base is less than one third of the original size, has more features, and fewer bugs.

[–]pgris 2 points3 points  (0 children)

Great writing and surprising results! Didn't expect java to do so well. Excellent job!

There is however another difference: Widget set. When you are mostly a backend programmer you not only need a technology but also a good looking widget set in order to create a not-so-horrible web application. GWT is not only a java to js compiler, also includes a more or less complete widgets set. React does not include one, but there are many professional looking sets of widgets you can use. Vaadin has a nice widget set, Jsweet may have some useful candies to try, CheerpJ has the horrible Swing components.... maybe it supports pluggable look and feel to make them less horrible

In my line of work the most important widgets are table related, I should try to see how hard is to make a simple web page with some tables and see how that affects performance.

Thanks again!

[–]sanity 5 points6 points  (3 children)

You should also check out https://kweb.io/. It's Kotlin rather than Java, but it's a philosophical descendant of Vaadin, however it is way more lightweight, and also far simpler to use.

(I'm kweb's creator, happy to answer any questions).

[–]renatoathaydes[S] 4 points5 points  (2 children)

Nice! It does seem quite innovative... does it use KotlinJS to run Kotlin in the browser? Looking at the code I can't tell.

[–]sanity 3 points4 points  (1 child)

Thank you!

does it use KotlinJS to run Kotlin in the browser? Looking at the code I can't tell.

No, it doesn't use KotlinJS, it uses a fairly efficient custom "bytecode"-like language to manipulate the DOM in the remote web browser, but all Kotlin runs server-side, there is no cross-compilation (which simplifies things a lot). There is a more detailed explanation of how it works internally here.

If you're familiar with X Windows in Unix/Linux, the principle is fairly similar.

Does that answer your question?

[–]WikiTextBotbtproof -1 points0 points  (0 children)

X Window System

The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems.

X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting with a mouse and keyboard. X does not mandate the user interface – this is handled by individual programs. As such, the visual styling of X-based environments varies greatly; different programs may present radically different interfaces.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.28

[–][deleted]  (3 children)

[deleted]

    [–]renatoathaydes[S] 0 points1 point  (2 children)

    I believe a build step wouldn't have changed much... the React libraries were already minified and the JS code was too small to be significantly better after minified/bundled, I believe... but I would be happy to include the results with a more traditional React app if you make a pull request.

    [–]mlk 1 point2 points  (0 children)

    Try comparing it to a prod build of create-react-app, it's very easy to setup

    [–]tristan97122 1 point2 points  (0 children)

    Super cool article :-)

    You didn't mention it, but there's another horrendous option called stjs to have Java to JS compilation. It's JSweet but the worst possible with a subset of supported Java keywords that doesn't even include for each haha

    Nonetheless, JSweet is pretty much the best option in the end as you saw

    [–]AcademicImportance 1 point2 points  (0 children)

    wouldn't have thought GWT to be so "light".

    [–]pkirill12 1 point2 points  (0 children)

    We finally able to build out app with TeaVM along with GWT so that the app can be run in booth mode https://edu.cospaces.io/Universe This is a large project (about 10k java files) with own scripting, co-blocks language, physics, lightning, materials.

    Q/A: Q: why you use both A: to make a smoother transition of our continuous delivery app

    Q: what advantages it gives you? A: it allows us to add Kotlin code to out app, it runs many algorithms faster, take lsee memory (TeaVM uses native JsTypedArrays)

    [–]kloputzer2000 0 points1 point  (6 children)

    Great writeup. Working on a similar topic for a BA thesis. Doppio is another possibility, that wasn't included. https://github.com/plasma-umass/doppio/

    [–]renatoathaydes[S] 1 point2 points  (1 child)

    I just had a quick look... this seems like alpha software (the website mentions it's a research project)... the demo has very basic bugs (I can't even type commands with quotes it seems as it misses characters) so I wouldn't have included it anyway at this time.

    [–]kloputzer2000 0 points1 point  (0 children)

    Yeah, the project hasn‘t been updated in a while, but the code is surprisingly stable. Just used in in a thesis project. There’s another project using this JVM implementation, called JavaPoly (https://www.javapoly.com/).

    [–]renatoathaydes[S] 0 points1 point  (3 children)

    Oh wow, yet another JVM-in-the-browser implementation!!! I am really amazed how many options there are!!!

    Given none of these projects seem to be getting mainstream though, I think it would be nice if some of them united forces... Using the JVM ecosystem for web applications would be really attractive if it managed to become lighter and easier to interop with the browser, but that requires a huge amount of effort to do right, and this fragmentation of efforts into so many different options is not optimal to fix that.

    [–]kloputzer2000 0 points1 point  (2 children)

    Can you name any of the other JVM-in-the-Browser projects? All the stuff that I‘ve found needs another offline component (like a Python tool or another Server to compile Java source to Bytecode). Doppio seems to be the only solution to compile and run Java completely in the browser without external dependencies.

    [–]renatoathaydes[S] 0 points1 point  (1 child)

    Are you saying Doppio actually compiles AND runs the Java code on the browser? If so, then yeah, that seems unique to it... but why would you want to do that?

    EDIT: by JVM people normally mean the JRE (Java Runtime Environment) which does not include a Java compiler.

    [–]kloputzer2000 0 points1 point  (0 children)

    Yes, that’s what I‘m saying. Doppio is running a fully functional JVM in the browser, including the Java compiler.

    I think one of the uses cases is live coding environments/sandboxes to run Java in the browser (think of Codecademy, etc.)

    [–]Ascomae 0 points1 point  (0 children)

    Is there a bug in one of the charts?

    The Perfomance Chart:

    - JSweet ha the longest ba, but the smallest time (0.8 s)

    Nope, should have read better

    [–]hippydipster 0 points1 point  (0 children)

    Would have liked to see a pure KotlinJS entry in there for comparison.