IT-Tage 365 2021 March: "How Should Java Developers Build Front-Ends for Web, Mobile & Desktop Today?"
Logistics
Conference
IT-Tage 365 2021 was a German online conference. The main event ran from December 6 through December 9, 2021 — but there were additional sessions throughout the year, such as mine.
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 gave my presentation on Wednesday, March 24, 2021, from 17:00 to 17:45 CET. The conference was well-organized and ran over Zoom. My talk was the last one of the day, so my audience’s enthusiasm was noticeably dampened. Either that, or I gave a boring presentation.
Abstract
Users access applications on PCs and mobile devices today. There are two obvious ways to build front-ends for these devices: web applications and native applications. Cross-platform solutions combine advantages from both approaches. Examples are Facebook’s React Native, Google’s Flutter, Microsoft’s Xamarin, and JavaFX. For pure web development, Facebook’s React, Google’s Angular, and Vue.js are good options. I look at all these frameworks from the perspective of a Java developer and recommend frameworks for three typical scenarios.
In 2019, I developed a mobile app prototype with Flutter and a progressive web application. I then decided to use Flutter for native mobile apps in my current project. Based on my project experience, I describe typical problems with Flutter and their solutions.
(This is my own translation of the talk’s German abstract — no separate English original exists.)
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
Unfortunately, I got no feedback on my talk.
Historical note (as of March 2021): During the talk, attendees could vote and give feedback 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.
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 publicly available 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! Here is a video demonstrating it.
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.
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.
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. 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.
I recorded the Udemy course data on Tuesday, March 23, 2021.
I recorded the Amazon U.S. book data on Tuesday, March 23, 2021. I restricted it to English books in the category Computer & Technology Books.
I recorded the Stack Overflow Jobs data on Tuesday, March 23, 2021.
I recorded the Indeed job data on Tuesday, March 23, 2021. I restricted it to Greater London (London + 50 miles) to keep the data manageable. London was a good mixture of old economy (finance, insurance) and new economy (start-ups). Plus, I was looking for a job in greater London come October 2021, so it was good to know what the market was looking for.
Unlike the Stack Overflow search, the Indeed search was a primitive full-text search. I wrote my own Java program to read in and correct the Indeed job data. Here are some of the issues my program fixed:
- Some jobs showed up twice in the search results.
- Searching for React also showed results for React Native.
- Most search results for Flutter were for Flutter Entertainment, the world’s largest online betting company.
- A job with the title React Developer could still have Vue in the body. My program did not count this as a “Vue job”.
Indeed only let you see up to about 1,200 search results. So, for instance, you couldn’t browse all 3,000+ React jobs. And my program consistently found about 15%-20% fewer results than Indeed showed: 540 for Vue, vs. the 635 that Indeed showed, or 399 for React Native vs. 471. There was probably something wrong with my HTML parsing. But it seemed evenly distributed among all technologies, so I considered my data still valid as relative data between technologies.
That’s why I calculated the “job reduction rate” with the numbers that my program found and applied them to the number that Indeed showed on the web page. To come back to the Vue.js example: my program found 540 jobs and deemed 500 a match. I then multiplied this ratio (500/540) with the 635 jobs that Indeed showed: (635 × 500) / 540 = 588. And that 588 was the number I used in the talk.
As a result of my program, I, for instance, reduced the React number from the reported 3,581 to 3,106. That was mostly the 400+ React Native jobs being removed. And the Flutter number went from 79 to 35 when removing Flutter Entertainment jobs.
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 Udemy course data on Tuesday, March 23, 2021.
I recorded the Amazon U.S. book data on Tuesday, March 23, 2021. I restricted it to English books in the category Computer & Technology Books.
I recorded the Stack Overflow Jobs data on Tuesday, March 23, 2021.
I recorded the Indeed job data on Tuesday, March 23, 2021. I restricted it to Greater London (London + 50 miles).
Flutter was at a special disadvantage on Indeed. 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, and it was the new kid on the block. 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. And 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 of the process did know Flutter.
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.
React Native didn’t officially support Windows or macOS. But Microsoft did: react-native-windows and react-native-macos. I wasn’t sure how production-ready they were. And react-native-macos was a fork of the official React Native.
Dart = Simplified Java for UI Development. For a good comparison between Dart, Java, and C#, look to this article. If you had some more time at hand, then this “Intro to Dart for Java Developers” was for you.
Will Google Kill Flutter?
Here were two positive pieces of news:
- In 2019, Flutter was the project with the third-highest number of contributors at 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. I wasn’t sure if this was just a test by Toyota or if they’d already decided to go ahead with Flutter for production.
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?
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.
Animations on iOS could stutter when first used. There was now a project for that in Flutter.
“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:
Flutter had hired a development studio to maintain the Firebase plugins, but I couldn’t find a link right then. Firebase is a lot of Google services for applications.
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, start phone calls or text messages. You could probably also launch application-specific URLs with it.
- 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.
Getting Started
React & JavaScript
The React website was a good starting point. React uses JavaScript to create web applications.
Learning JavaScript
- The MDN Web Docs (the site formerly known as “Mozilla Developer Network”) had various tutorials based on your skill level.
- academind had a JavaScript course with 40 hours of video. The same course was on Udemy, where it could be cheaper during frequent sales.
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
- The React site had a tutorial for beginners where you built an app.
- The React site also gave us a tutorial for the React concepts.
- academind had a React course with 40 hours of video, which included React Hooks and Redux. I was taking this course myself at the time of the talk (March 2021). The same course was on Udemy, where it could be cheaper during frequent sales.
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:
- Google had several free tutorials for Dart.
- Code with Andrea had a 10-hour Dart course.
Installing Flutter
Here were the instructions, straight from the Flutter website:
Learning Flutter
Here’s a selection of Flutter tutorials and courses:
- Google had several free tutorials for Flutter.
- freeCodeCamp had at least two free Flutter courses:
- a one-hour course for mobile apps, and
- a three-hour course that claimed to include desktop & web, too.
- Code with Andrea had two paid courses:
- a 2.5-hour “Flutter REST API Crash Course” (I took it & liked it a lot!), and
- a 21-hour course on Flutter & Google Firebase.
- Finally, academind had a Flutter course with 41 hours of video. I used the 2019 version to learn Flutter and can highly recommend it! The same course was on Udemy, where it could be cheaper during frequent sales.