Skip to content

JJUG CCC 2021 Spring: "How Should Java Developers Build Front-Ends for Web, Mobile & Desktop Today?"

Published on · Updated on · 12 min read
JJUG CCC 2021 Spring logo

Share

Logistics

Conference

The Japan Java User Group (JJUG) hosted the JJUG CCC conferences in spring and autumn — Japan’s largest Java community events. JJUG CCC Spring 2021 was an online conference.

I was honored to give a session there on “How Should Java Developers Build Front-Ends for Web, Mobile & Desktop Today?” on Sunday, May 23, 2021. I looked at various frameworks from a Java developer’s perspective and suggested which one to use in three common scenarios.

Abstract

Users accessed applications on PCs and mobile devices at the time. There were two obvious ways to build front-ends for these devices: web applications and native applications. Cross-platform UI toolkits combined advantages from both approaches — examples were Google’s Flutter, JavaFX, Facebook’s React Native, and Microsoft’s Xamarin. Important web application frameworks were Google’s Angular, JSF, Facebook’s React, Thymeleaf, Vaadin, and Vue.js. I looked at all these toolkits from the perspective of a Java developer and suggested which one to use in three common scenarios.

In 2019, I developed a mobile app prototype with Flutter and a progressive web application prototype. I then decided to use Flutter for native mobile apps in my SaaS start-up. Based on my experiences, I highlighted typical Flutter issues and how to solve them.

Why Should You Listen To Me?

I wasn’t affiliated with the projects I discussed, and I didn’t sell books or training courses. I shared industry analysis and my own project experiences to give you options for your next project. I used 12 criteria for my evaluation. You can use my criteria, pick your own, or weigh them differently than I did. But you need to apply your criteria in your own environment and make your own choice.

Summary

Here was my advice for “Building a Web App From Scratch”:

Here was my advice on “Building Native iOS and Android Apps”:

And here was my advice on “What to Do on Desktop When You Have a Web Application”:

Historical note (as of May 2021): After the talk, attendees could rate it live and leave feedback via Mentimeter. That poll is no longer reachable today.

Slides

The slides were available as a PDF (3.1 MB); the PDF version is available for download here.

Download slides (PDF)

Historical note (as of May 2021): Back then, the slides were also available in their original Keynote format (13.5 MB) — with less text, but animated and with a look behind the curtain of individual effects; that file is no longer available today.

Video

The talk is on YouTube. It’s 39 minutes and 40 seconds long:

Watch the video (YouTube)

Flutter Hot Reload

Flutter Hot Reload made code changes go live in the device/simulator immediately. It was the main reason why working with Flutter could be such fun! I mentioned it in the talk — here’s a video demonstrating it.

Watch the video (YouTube)

Mobile App Prototype with Flutter

Even though it was a bit older by then, this was still a good example of what a native Flutter app could look like. I wasn’t ready to show the app I was working on at the time.

In the summer of 2019, I built native iOS/Android apps with Flutter to validate a business problem. It took about six weeks and was my first Flutter project. I used Google’s cloud service Firebase for login, NoSQL database, and file storage. I built the back-end myself with Java, JHipster, Spring Boot, and Angular.

Watch the video (YouTube)

Progressive Web Application Prototype

At the end of 2019, I built a progressive web app (PWA) to speed up app development. A PWA used the “Service Worker” in a browser to install on a device and cache data. That took about four weeks and was my first PWA. I used Google Workbox for this but developed my own offline storage solution in the browser. I built the back-end with Java, JHipster, Spring Boot, and Angular.

Watch the video (YouTube)

Historical note (as of May 2021): At the time, I was looking for a new project starting in October 2022, in Milton Keynes, London, or remote.

Additional Talk Information

How Can We Build Front-Ends Today?

Declarative Front-Ends

These five frameworks showed different approaches to declarative front-ends:

Apple’s SwiftUI

SwiftUI was Apple’s take on declarative front-ends. Here’s the counter example from the talk, with slightly changed formatting:

@State var count: Int = 0

var body: some
View {
  VStack(alignment: .center,
    content: {
      Text("Counter: \(count)").padding()
      Button(
        action: { self.count++ },
        label: { Text("Increment") }
      )
    }
  )
}

Google’s Flutter

Flutter was Google’s cross-platform implementation of declarative front-ends. It reached the stable version 1.0 for mobile in December 2018. Here’s what the SwiftUI counter sample looked like in Flutter:

int _counter = 0;

return Column(
  mainAxisAlignment: MainAxisAlignment.center,
  children: [
    Text( 'Counter: $_counter' ),
    TextButton(
      onPressed: () =>
        setState({
          _counter++
        }),
        child: Text( 'Increment' ),
    ),
  ],
);

Google’s Jetpack Compose

Jetpack Compose was Google’s Android implementation of declarative front-ends. So Google had two different horses in this race: Jetpack Compose and Flutter. Of course, it’s Google! 😒

Jetpack Compose entered beta on February 24, 2021. According to Google, it already had stable APIs and was feature-complete at the time.

I adopted the counter sample from this tutorial to look like the SwiftUI sample above:

val count = +state{0}

Column(Spacing(16.dp)) {
  Container() {
    Column() {
      Text(
        text = "Counter: ${count.value}",
        modifier = Spacing(8.dp)
      )
      Button(
        text = "Increase",
        onClick = {
          count.value++
        }
      )
    }
  }
}

Microsoft’s .NET Multi-platform App UI (MAUI)

.NET MAUI was part of .NET 6, expected for November 2021 at the time. And if “Maui” rang a bell for you — it’s the second-largest island of Hawaii.

Microsoft called its implementation of declarative front-ends “Model-View-Update” (MVU). Here’s what I thought the SwiftUI sample from above would look like in MVU. I adapted the sample from the announcement post:

readonly State<int> count = 0;

[Body]
View body() => new StackLayout {
  new Label( "Counter: {count}" ),
  new Button(
    () => $"Increment",
    () => count.Value ++
  )
};

Facebook’s React

And finally, here’s what the counter looked like in Facebook’s React for web applications. I adapted it from this Stackblitz sample. Some HTML code shows up because I didn’t use components, to keep things simple. If I had, it would have looked just as declarative as the other examples:

class App extends React.Component {
  state = {
    counter: 0
  }

  render() {
    return <div>
      <p>Counter: {this.state.counter}</p>
      <button onClick={
        () => this.setState({
            counter: this.state.counter + 1
          })
        }>Increase</button>
    </div>
  }
}

Web Applications

Popularity

I recorded all numbers on Saturday, May 8, 2021.

Here’s the link for Stack Overflow Trends:

Here were the search queries for the Udemy course data:

The Indeed job search was a primitive full-text search in both the header and the body. I searched manually and then adjusted some values:

  • A job with the title React Developer could still have Vue in the body. This was counted both as a result for React and Vue.
  • Searching for React also showed results for React Native. I subtracted the number of React Native results from the React results.
  • About half the search results for Flutter in the UK were for Flutter Entertainment, the world’s largest online betting company. This may have inflated results in other countries, too.
  • About a third of the JSF results were defense industry jobs that referenced the Joint Strike Fighter aircraft program. This may have slightly inflated results in other countries, too.
  • “Vue” has multiple meanings in French and Spanish. So in France, Canada, and Spain, I searched for “vue.js” instead.

You could find the detailed search results with links here:

Ranking

I ranked React fastest, for two reasons:

  • React had an experimental feature called Concurrent Mode. If it made it into production, it would improve data loading with multiple components on a page.
  • ReactDOMServer let us send HTML from the server to the browser before the React application was ready. The other frameworks may have had something similar.

Native iOS & Android Apps

Popularity

I recorded all numbers on Saturday, May 8, 2021.

Here’s the link for Stack Overflow Trends:

Here were the search queries for the Udemy course data:

Please see the previous section for general information on the Indeed search.

Flutter was at a special disadvantage on Indeed. Often, you’d find the following in job ads there: “Experience with a cross-platform framework like Xamarin or React Native required”. Flutter was a cross-platform framework, but it was the new kid on the block. If you just had “Flutter” in your resume, you might still not get the job:

  • Most big companies used Applicant Tracking Systems (ATS). These systems scanned resumes automatically for keywords. If “Flutter” wasn’t an approved keyword, you were out.
  • The next stage was the agency or HR department. They typically had no clue about programming — how could they? They hired people for all sorts of professions. If they didn’t know about “Flutter”, you were out again. It wasn’t all sunshine and roses!
  • Hopefully, the developers at the end of the process did know Flutter.

The same search results were available here for download:

React Native Vs. Flutter

  • React Native always used a JavaScript VM to run our applications. Flutter used a Dart VM during development and compiled native code when deployed — that was faster.
  • React Native managed the native iOS/Android UI elements through a JavaScript bridge. That was slower than Dart: Dart used Google’s open-source Skia graphics library — Chrome, Firefox, Chrome OS, and Android also used Skia. But this also meant Flutter only painted pixels: it had to recreate all native iOS/Android UI elements in Flutter.

Will Google Kill Flutter?

  • In 2019, Flutter was the project with the third-highest number of contributors on GitHub (section “Top and trending projects”). It had 13k. Azure Docs had 14k, VSCode had 19k. I couldn’t find these numbers for 2020.
  • Toyota picked Flutter to power future car entertainment systems. Whether this was just a test by Toyota or whether they’d already decided to go ahead with Flutter for production remained unclear.

Responsive Design

Flutter gave only little help with responsive design: You found out the screen width and adjusted your UI yourself. Wonderful! So there was no grid like in Bootstrap or the more powerful, but also more complicated, HTML version. For now, I went with flutter_bootstrap.

Does Flutter Do Too Much?

  • Animations on iOS could stutter when first used. There was now a project for that in Flutter.
  • Flutter had more than 8,500 open issues. But the team claimed to close at least as many as were being opened — that seemed true for February 16, 2021 – March 16, 2021: 1,210 closed, 695 opened.
  • “Sound Null Safety” was a feature of Dart that was new in Flutter 2.0. It did away with NullPointerExceptions. But you needed to update your code — and the plugins you used also needed to be null-safe, and so did their dependencies. It was clear this would take a while and that some plugins wouldn’t get updated and would fall by the wayside. Flutter had a migration tool for null safety that was stunning: a web server that could automatically update your code! Here’s a video showing it:

Watch the video (YouTube)

Notable Flutter Plugins

Getting Started

React & JavaScript

The React website was a good starting point. React used JavaScript to create web applications.

Learning JavaScript

Learning TypeScript

TypeScript mixed “some Java into JavaScript”, such as types — hence the name! You had to use TypeScript with Angular. And you could use it with React.

The “TypeScript for Java/C# Programmers” article offered a starting point. If you liked it, the TypeScript handbook was your friend, also available as Epub and PDF.

Learning React

Flutter & Dart

The Flutter website was an excellent place to get familiar with Flutter. Flutter used the Dart programming language to build natively compiled applications for mobile, web, and desktop. Both Flutter and Dart could use plugins from a great portal.

Learning Dart

You started with the Dart language tour. Java developers then took “Intro to Dart for Java Developers”. After that, you had options:

Installing Flutter

The installation instructions came straight from the Flutter website:

Learning Flutter

A selection of Flutter tutorials and courses: