Skip to content

LJC Community Talk: "How Should Java Developers Build Front-Ends for Web, Mobile & Desktop Today?"

Published on · Updated on · 11 min read
LJC Community Talk announcement poster

Share

Talk

The London Java Community (LJC) regularly hosted community talks, where two speakers each got 30 minutes. On Thursday, February 25, 2021, I presented “How Should Java Developers Build Front-Ends for Web, Mobile & Desktop Today?” there. I looked at various frameworks from the perspective of a Java developer and suggested which toolkits to use in typical scenarios.

I want to thank Dominique Carlo and Barry Cranford from RecWorks. They made these community talks possible! So if you need to hire Java developers in the U.K., consider RecWorks!

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 Facebook’s React Native, Google’s Flutter, Microsoft’s Xamarin, and JavaFX. Important web application frameworks were Facebook’s React, Google’s Angular, and Vue.js. I looked at all these frameworks 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. The videos are below. I then decided to use Flutter for native mobile apps in my project at the time. Based on my experiences, I highlighted typical Flutter issues and how to solve them.

Who Made Me the Expert?

I’ve been a Java developer for 26+ years and still write code every day. As a full-stack developer, I was about to put my third project into production since 2017. I was the sole developer on two of them and the lead developer on the third one.

I wasn’t affiliated with the projects I was discussing here. I wasn’t selling books or training courses. I was just sharing industry analysis and my project experiences to give options for the next project. You then needed to apply your own criteria, evaluate these options in your own environment, and make your own choices.

Slides

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

Download slides (PDF)

The slides were also available in their original Keynote format (14 MB, including a video) — animated to better convey information and to make them more pleasant to watch, with a look behind the curtain of individual effects; that version isn’t available for download here.

Video

The talk is on YouTube. It’s 41 minutes long, followed by nearly ten minutes of questions.

Watch the video (YouTube)

Mobile App Prototype with Flutter

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

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 uses the “Service Worker” in a browser to install on your device and cache data. That was about four weeks, and it was my first PWA. I used Google Workbox for this, but developed my own offline storage solution in the browser. I built my back-end with Java, JHipster, Spring Boot, and Angular. This video has the details.

Watch the video (YouTube)

Historical note (as of February 2021): At the time, I was looking for a new project starting in October 2022, in Milton Keynes, London, or remote — as a contractor or fixed-term employee.

Additional Talk Information

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 had stable APIs and was feature-complete by then.

I adapted the counter sample in 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 — 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. You see some HTML code in there because I didn’t use components to keep things simple. If I had, it would have looked 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>
  }
}

Notable Flutter Plugins

Getting Started

React & JavaScript

The React website was a good starting point. React uses 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 if you used Angular. And you could use it with React.

You could take a peek in the “TypeScript for Java/C# Programmers” article. If you liked it, the TypeScript handbook was your friend, also available in Epub and PDF.

Learning React

Flutter & Dart

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

Learning Dart

You started with the Dart language tour. Java developers took the “Intro to Dart for Java Developers” next. Then there were options:

Installing Flutter

Here were the instructions, straight from the Flutter website:

Learning Flutter

Here’s a selection of Flutter tutorials and courses:

Making Of

Third Time’s the Charm?

This was the third time I gave this talk: the first time at the LJC Unconference 2020, the second time at the Cincinnati JUG. So I was familiar with it and went from about 50 minutes at the Cincinnati JUG to 41 minutes this time around.

But that wasn’t enough: for my JavaLand talk, I needed to get this down to 35 minutes — in German. So I needed to cut nearly 10 minutes while also wanting to add some things. 😓

The Summary Stash

I used the “Summary Stash” for the first time ever in a talk. And probably for the last time! But what is that? And why wouldn’t I do this again?

The “Summary Stash” is a slide where I collected miniature versions of important slides for my wrap-up. Since I used Apple Keynote’s Magic Move, it really was a miniature version, not a picture. Here’s an example:

Watch the video (YouTube)

Then at the end, I went through the stash, one slide at a time:

Watch the video (YouTube)

Well, it certainly looked the part. So why wouldn’t I use it again? Three reasons:

  • It took a lot of time in the talk. Between filling the “Summary Stash” and going through it at the end, it took four minutes in total. And I needed to cut nearly ten minutes!
  • I showed & talked at the same time. Although my audience had seen the slides before, they still needed time to read the slide again. In this talk, I didn’t give them that time, violating the “don’t show & tell at the same time” rule of talks.
  • It was a lot of work to keep the different versions of the “Summary Stash” slide up-to-date. I changed some slides, which I then needed to fix on dozens of “Summary Stash” instances.

I had an idea for how I could replace the “Summary Stash”, but I wasn’t sure if I would do this.

Out of Sync

When giving a talk, you have three options to sync up what your audience sees and hears:

  1. Show first, then tell: You show your point first on the slide, then talk about it.
  2. Show & tell: You show your point on the slide and talk about it at the same time. You see this most often, but you shouldn’t do this: people can’t listen and read at the same time, so they either don’t listen while reading — or don’t read what you’re showing.
  3. Tell first, then show: You talk about your point first and then show it on the slide. That’s what I did here most of the time.

Here’s an example — I talk about a point before it appears on the slide:

Watch the video (YouTube)

This was the second time I did it. And the last time. Why?

  • As my wife pointed out when I told her about my talk, it’s confusing to the audience. They see a point on the slide while I’m already talking about the next one. Think about subtitles in movies: you see the subtitles first, then you hear the dialog. Listening to your wife is always a good idea. Here it was an especially good one. I only wished I had asked her earlier!
  • It’s harder to talk about an upcoming point while working in your presentation program. Instead of looking at the same screen/content that your audience sees, you need to look at the next screen — on a second screen.

So I went back to option 1 — show first, then tell.

Eyes Up Here!

I always say that you should look directly into the camera in an online talk. Well, where did I look? Not into the camera! Why?

I didn’t use the web cam of my Mac. Instead, I used my iPhone with the Reincubate Camo software. And I clearly put it in the wrong place this time. It also didn’t help that the “next slide” I was talking about was on the right side of my screen (from the audience’s perspective).

I definitely needed to record myself before my next talk!