A few weeks ago I told about a question I was asked, which led to my post about full-stack developers. And then my post on user interface options for Java developers.
Today I want to finish off the discussion about cross-platform development with a look at some of the options for mobile app development.
The Client Wants Android
Let’s say you’re approached by a prospective client (or instructed by your boss) to develop an exciting new super-duper mobile application with the stated requirement to run on Android devices.
You do the barest minimum research to find out that Android Studio is the official IDE for Android. So you download and install it, and get busy developing the app. Almost immediately you have to make a decision about what language to use: Java or Kotlin.
You already program in Java, so it’s probably your first choice. But with a bit of more research, you discover that Google now recommends that all new Android development should be done in Kotlin.
Hmmm, decisions, decisions… But your client just needs the app on Android, so you decide to stick with Java.
The Client Expands the Scope to iOS…
A few meetings and demos later, your client asks a simple question, “Can this app run on the iPhone?” “No”, you say. The client makes noises that it’s a really important new requirement, and implies that they’ll have to find other developers to do it if you can’t. Whoops, mad internal panic! “Sure!”, you say, “We can do it. We’ll just need a bit more time.”
In countries like the USA and UK, Android and iOS have roughly equal market share. This means that most mobile apps have to be developed on both platforms, or you’ll risk losing potential clients. To create apps for both platforms, you’ll have to choose between two options: either build two separate native applications or one cross-platform application which will run on both iOS and Android.
Now what? Java doesn’t run on iOS, and in any event, because the two platform APIs are radically different, the whole program will have to be recreated from scratch.
You really don’t want to maintain two sets of code – one set is hard enough, so you decide to look for another development framework.
Kotlin would have given you a head-start, because you would have been able to reuse much of your business logic, database code, analytics and algorithms. By using Kotlin Multiplatform Mobile you would only have had to implement the native user interface (UI) code specific to the Android and iOS devices. So close, yet so far out of reach now because of your initial language choice.
You start looking for other Java-based alternatives. A web search turns up Gluon Mobile. With Gluon Mobile you can build and deploy an application in Java for Android and iOS using the same APIs. Gluon is based on JavaFX, and allows you to create high performance, cloud connected mobile apps from a single Java code base. It isn’t open source and carries an annual right-to-use subscription fee. It definitely ticks the right boxes for Android and iOS, but it would require a total rewrite of your existing Android code. Sigh…
The Client Expands the Scope to Windows, MacOS and Linux…
While you’re still evaluating these alternatives, your client phones and says that they also really need the application to run on Windows, MacOS and Linux. Arrgghh!!
You widen your Google search and libGDX pops up. LibGDX is a cross-platform Java game development framework based on OpenGL. It works on Android, iOS, macOS, Windows, Linux and browsers. Sounds perfect! But wait, it’s a games library, and you’re not developing a game. You can’t understand half of what the website says – meshes, textures, shaders, sprites, orthographic cameras, 2D and 3D APIs, particle systems. Where are the buttons? Labels? Textboxes? Yes, they are there, but they’re oriented towards a game UI, rather than a standard platform look-and-feel like Material Design (Android) or Cupertino (iOS).
Great for a graphical game, probably not so good for your particular business-related mobile app. And it would demand another total code rewrite. Will it ever end?
Xamarin appears next in your search results. Xamarin is another free, open-source platform for building cross-platform applications. You can develop Android, iOS, macOS and Windows apps with Xamarin. Excellent! But wait, now you’ll have to code in C# using the .NET libraries. The entire app will have to be rewritten from the ground up using C# – the UIs, the business logic, data access code, native API access, everything. There’s a promise of a “single” codebase, but it’s limited to about 75% of your code being shared across these platforms.
How about Basic? Anywhere Software has a B4X suite of products that support more platforms than you currently need: Android, iOS, Windows, macOS, Linux, Raspberry Pi, Arduino and ESP8266/ESP32 system-on-chip devices (for IoT). The B4X programming language is a modern version of Visual Basic. Compiled applications are 100% native without any dependencies.
B4A is used to develop Android apps. Together with B4i you can develop applications for both Android and iOS. B4J apps can run on Windows, Mac, Linux and ARM boards (such as Raspberry Pi). B4R is used to create native Arduino, ESP8266 and ESP32 programs. B4A, B4J and B4R are 100% free. Only B4i needs to be purchased.
All this and you only have to learn Basic! Nothing wrong with Basic – Visual Basic had millions of adherents in its day, and was really easy to learn and code. A bit of a jump if you only know Java, but nothing that a bright programmer can’t handle, right? Downsides include a totally different syntax; the language is only object-aware, rather than fully object-oriented; properties instead of getters and setters; and more new language tricks to learn.
Delphi anyone? Using Delphi allows you to develop iOS, Android, Windows and macOS apps from a single Delphi codebase. The latest version supports Windows 11, macOS 12, iOS 15 and Android 12. The Delphi Community Edition can be downloaded for free, but is still a full-featured IDE. It only has a limited commercial use license, but commercial licenses are available for the more premium products.
All this and you only have to learn Delphi! Very similar comments here as for a Basic – a totally different language to Java which you’ll have to learn, with its own APIs and ways of thinking.
Flutter uses the Dart programming language. Dart looks a lot like a cross between Java and Kotlin, so will also be really easy to learn. You can experiment with Dart in the browser using DartPad, a web-based Dart execution environment.
So far Flutter and Dart sound like an awesome combination. If you move to Flutter you’ll have to rewrite your existing Java code, but every development environment you’ve looked at so far has that requirement.
What have you learnt from this? Don’t decide on a language and a technology stack before you know what your client’s needs and objectives actually are. Ask them lots of questions to formalise the scope and the possible future paths. This will help you select the best-suited technology.
Before you start developing a mobile app (actually, any app!), you need to know the business goals, target market, requirements and features. Only then you’ll be able to decide on the best language and toolkit for developing that exciting new super-duper app.
In my opinion, unfortunately Java isn’t the best language to use when doing cross-platform mobile app development.
I say “unfortunately” because I’ve been teaching Java since 1996 when Java was still shiny new and on version 1.0. For me it’s a great language with an extensive infrastructure and a vast selection of frameworks.
It saddens me that Java-specific cross-platform mobile app development has been stunted by the legal issues surrounding Java. So much so that it’s easier for companies to develop new languages such as Kotlin and Dart than to try expand the usage of Java within the mobile app development space.
So, what do you think? I can’t wait to hear your opinions on this topic.
Stay safe, and I’ll see you next week!