JFS 2021: "Wie sollten Java-Entwickler heute Front-Ends für Web, Mobile & Desktop bauen?"
Logistics
Conference
I was happy to give a German talk, “Wie sollten Java-Entwickler heute Front-Ends für Web, Mobile & Desktop bauen?” (“How Should Java Developers Build Front-Ends for Web, Mobile & Desktop Today?”), at the Java Forum Stuttgart 2021. It’s the biggest Java conference in the South-West of Germany, and it was an online conference again that year.
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 a project that went live in May 2021. 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 “New Web Application”:
Here was my advice on “New Native iOS & Android Apps”:
And here was my advice on “Got a Web Application - What Now?”:
Historical note (as of October 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 (2.1 MB); the PDF version is available for download here.
Historical note (as of October 2021): Back then, the slides were also available in their original Keynote format (13.8 MB) — with less text, but animated and with a look behind the curtain of individual effects; that file is no longer available today.
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’s a video demonstrating it.
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.
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.
Historical note (as of October 2021): At the time, I was looking for a new project starting in October 2022, in Milton Keynes, London, or remote.
Additional Talk Information
Java Developer Wish List for Front-Ends
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 went 1.0 on July 28, 2021.
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 and had recently been delayed from November 2021 to Q2/2022. 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>
}
}
New Web Application
Popularity
I recorded all numbers on August 25 & 26, 2021.
Here’s the link for Google Trends: Angular, JSF, React, Vaadin, and Vue.js. It showed how unpopular JSF and Vaadin were at the time. Thymeleaf wasn’t on the list because Google only allowed five search terms. Here’s a version with Thymeleaf instead of Vaadin.
Here’s the link for Stack Overflow Trends with all frameworks: Angular, JSF, React, Thymeleaf, Vaadin, and Vue.js. It showed how unpopular JSF, Thymeleaf, and Vaadin were at the time.
Here were the search queries for the Udemy course data:
The Indeed job search went across 63 countries, representing 92% of the worldwide GDP in 2020. It was a full-text search in both the header and the body for the technology name, such as “Flutter”. In most countries, the result also had to include at least one of multiple ways to say “developer”.
Here were some of the adjustments & caveats:
- 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.
- The word “react” often appeared in job advertisements. In countries where I didn’t have translations for the various forms of “developer” (such as China or Russia), I manually adjusted the number of jobs found down.
- Flutter Entertainment is the world’s largest online betting company. Although I was looking for developer positions, this may have inflated the number of jobs found for Flutter a bit.
- About a third of the JSF results were defense industry jobs that referenced the Joint Strike Fighter aircraft program. I removed those for the US. This may have slightly inflated results in other countries, too.
- In Japan, “JSF” was a popular abbreviation. Since I didn’t have translations for the various forms of “developer” in Japanese, I set the number of jobs found here to 0, because I couldn’t determine how many jobs were actually for the JSF framework.
- “Vue” has multiple meanings in French and Spanish. So in French-speaking countries, like France, Canada, Spain, Luxembourg, and Switzerland, I searched for “vue.js” instead. This may have deflated the number of jobs found for Vue a bit.
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.
New Native iOS & Android Apps
Popularity
I recorded all numbers on August 25 & 26, 2021.
Here’s the link for Google Trends: Flutter, JavaFX, React Native, and Xamarin. It showed how unpopular JavaFX and Xamarin were at the time.
Here’s the link for Stack Overflow Trends with all frameworks: Flutter, JavaFX, React Native, and Xamarin. It showed how unpopular JavaFX and Xamarin were at the time.
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.
Notable Flutter Plugins
- flutter_bootstrap: made your app responsive with the Bootstrap grid.
- flutter_platform_widgets: provided UI element abstractions that automatically created either an iOS or Android UI element, depending on the current mobile operating system.
- google_fonts: added Google Fonts to your Flutter application.
- url_launcher: launched apps to open links, send emails, or start phone calls or text messages. You could probably also launch application-specific URLs.
- flutter_email_sender: sent email in-app, using standard iOS/Android components.
- google_maps_flutter: opened Google Maps inside your app. Using Google Maps in your app was free on iOS and Android.
- connectivity: found out when the network connectivity of your app changed.
- image_picker: accessed photos & videos on iOS and Android.
- camera: accessed the camera on iOS and Android.
- image_cropper: edited pictures.
- photo_view: showed pictures with pinch-to-zoom.
- flutter_markdown: showed Markdown.
- native_pdf_view: showed PDF documents.
- flutter_html: showed HTML.
- freezed: generated immutable classes, complete with JSON serialization.
- flutter_easyloading: showed toast overlays for progress & success/info messages.
- package_info: got the application version number for your “About” screen.
- device_info: got device information for your “About” screen.
- fluent_ui: provided a native-looking Windows UI.
- macos_ui: provided a native-looking macOS UI.
Getting Started
React & JavaScript
The React website was a good starting point. React used JavaScript to create web applications.
Learning JavaScript
- The MDN Web Docs (formerly known as “Mozilla Developer Network”) offered various tutorials based on skill level.
- academind offered a JavaScript course with 40 hours of video. The same course was on Udemy, where it may have been cheaper in a sale.
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
- The React site had a tutorial for beginners where you built an app.
- The React site also offered a tutorial for the React concepts.
- academind offered a React course with 40 hours of video, including React Hooks and Redux. The same course was on Udemy, where it may have been cheaper in a sale.
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:
- Google offered several free Dart tutorials.
- Code with Andrea offered a 10-hour Dart course.
Installing Flutter
The installation instructions came straight from the Flutter website:
Learning Flutter
A selection of Flutter tutorials and courses:
- Google offered several free Flutter tutorials.
- freeCodeCamp offered at least two free Flutter courses:
- a one-hour course for mobile apps, and
- a three-hour course that also claimed to cover desktop & web.
- Code with Andrea offered two paid courses:
- a 2.5-hour “Flutter REST API Crash Course” (I took it and liked it a lot!), and
- a 21-hour course on Flutter & Google Firebase.
- Finally, academind offered a Flutter course with 41 hours of video. I used the 2019 version to learn Flutter myself and could highly recommend it! The same course was on Udemy, where it may have been cheaper in a sale.