Skip to content

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

Published on · Updated on · 13 min read
JavaLand logo

Share

Logistics

Conference

JavaLand 2021 was a two-day online conference that ran from March 16 through March 18, 2021 (the third day was a training day).

It was Germany’s biggest Java conference and had 2,100 visitors in 2019. The German Oracle User Group, the Association of the German Java User Groups, and the German publisher Heise Medien organized this conference. Due to COVID-19, the conference in March 2020 had been canceled.

Talk

My talk was an online talk in German. Its title translates into “How Should Java Developers Build Front-Ends for Web, Mobile & Desktop Today?”. I presented on Tuesday, March 16, 2021, from 16:00 to 16:45 CET.

Unfortunately, the conference had lots of technical issues on the first day. I gave the second-last talk of the day. Given the eight parallel tracks and the 1,300 participants, I expected an audience of at least 30 people. Before I started my presentation, I saw maybe 3 or 4. I wasn’t sure if that was accurate. And then the moderator couldn’t participate in the chat where I was supposed to get questions. So off I went to Gather.Town after my talk!

What’s Gather.Town? Glad you asked! It’s an online meeting tool that looks like a Super Nintendo game from 30 years ago. Here’s me, waiting in front of the theater (“Schauspielhaus” in German) for people with questions:

I did have a video chat with one listener and a text chat with another one. Nice!

Abstract

Smartphones are the most popular way to access applications. iOS and Android provide mature platforms for native app development. However, it is expensive and time-consuming to develop two separate apps for iOS and Android. Web applications run on both platforms. Unfortunately, they lag behind the capabilities of native apps on iOS and offer a rather poor “developer experience”.

That is why platforms that generate native apps for iOS and Android from one code base are becoming more important. Facebook’s React Native and Google’s Flutter lead this field. Just like Apple’s SwiftUI and Google’s Jetpack Compose, both use declarative programming and offer an excellent “developer experience”. However, Flutter is more ambitious as a “UI toolkit for every place where pixels are painted”: web applications with Flutter are in beta, desktop applications are in alpha (as of September 2020). Flutter is also more attractive to Java developers because the Dart programming language can be described as “two parts Java, one part JavaScript”.

The author developed a Flutter prototype in the summer of 2019 and a PWA in winter 2019/2020. Then he decided to implement the native iOS and Android apps with Flutter for Software as a Service (SaaS). The back end was a Spring Boot application, and the web front end ran with Angular. The author demonstrates the iOS and Android apps and reports on his experiences with Flutter in the talk. Using code and tool examples, he shows advantages and goes into typical problems and their solutions.

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, nor was I selling books or training courses. I shared industry analysis and my project experiences to give options for the next project. I used 12 criteria for my evaluation. You could use my criteria, pick your own, or weigh my criteria differently than I did. But you needed to apply your criteria in your own environment and make your own choices.

Feedback

Here’s the feedback I got on my talk. You can view the second page with the arrow button in the bottom left.

Historical note (as of March 2021): The rating ran live via Mentimeter. That poll is no longer reachable today.

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 (8 MB) — with less text than the PDF version, but animated and with a look behind the curtain of individual effects; that version isn’t available for download here.

Video

No video of this talk is known.

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 is a video demonstrating it.

Watch the video (YouTube)

Mobile App Prototype with Flutter

Although it was a bit old by then, this was still a good example of what a native Flutter app could look like.

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.

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.

Watch the video (YouTube)

Historical note (as of March 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>
  }
}

Web Applications

Popularity

Historical note (as of March 2021): The following figures are a snapshot from March 2021 and no longer current.

  • I recorded the Google Trends and Stack Overflow Trends data on Thursday, March 11, 2021.
  • I recorded the Stack Overflow Jobs, Monster, and Udemy data on Friday, March 12, 2021.
  • The Google search numbers were too low for Vue.js because many people searched for “vue” instead. But “vue” has other meanings in English, so I didn’t use “vue” results. Only the “vue.js” ones are counted 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 the Google Trends and Stack Overflow Trends data on Thursday, March 11, 2021.
  • I recorded the Stack Overflow Jobs, Monster, and Udemy data on Friday, March 12, 2021.
  • Flutter was at a disadvantage on Monster. Often, you found the following in job ads there: “experience with a cross-platform framework like Xamarin or React Native required”. Now Flutter was a cross-platform framework. But if you just had “Flutter” in your resume, you still might not have gotten the job.
    • First of all, most big companies at the time used Applicant Tracking Systems (ATS). These systems scanned your resume automatically for keywords. So 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 in all sorts of professions. So if they didn’t know about “Flutter”, you were out again. It’s not all sunshine and roses, you know!
    • Hopefully, the developers at the end did know Flutter.
  • I didn’t include Flutter course numbers from Udemy. Usually, when you searched for a popular topic, Udemy offered a special “Explore X courses” link. You see that below for Angular:
  • But Udemy didn’t do this for Flutter. That’s why there are no Flutter numbers here.

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 the Google open-source Skia Graphics library. Chrome and 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?

Responsive Design

Flutter gave us little help on responsive design: find out the screen width and change your UI. Wonderful! So no grid, like in Bootstrap or the more powerful, but also more complicated HTML version. Anyway, I went with flutter_bootstrap for the time being.

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 that they closed 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 we needed to update our code. And the plugins we used also needed to be null-safe. And so did their dependencies… It was clear to me that this would take a while and that some plugins would not be updated and would fall by the wayside. Flutter now had a migration tool for null safety that was stunning: a web server that could automatically update your code! Watch it here:

Watch the video (YouTube)

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: