Mar 09 2017

Android Programming: B4A eliminates the pain of Java

Published by under Android,B4A,Programming,Software

Throughout the last one and a half decades of my career, programming came too short for my liking. I’ve spent most of my work time in networking and building server landscapes and as much as I’ve enjoyed diving deeply into things like virtualization, operating systems, TCP/IP, routing, switching and global infrastructures, I’ve missed building my own software — and by that I mean software that goes beyond the size of the occasional script.

During my teenage years, I’ve created text adventures in Turbo Pascal and Turbo Basic with self-developed parsers that could understand rather long German sentences (in the context of the game world). In my professional career, I’ve written commercial desktop applications and server daemons and services.

Now I want to look at the world of mobile apps — and since I only own devices running versions of Google’s Android and Amazon’s FireOS (which is based upon Android), Android is the beast I will study.

This leads me straight to the biggest issue with Android: Google champions Java as the “official” programming language for Android.

Over the last twenty years, I have tried again and again to give Java a fair chance and to warm up to it. At the same time, Java has proven again and again that all the prejudices against it are true, and I never managed to understand why people – or should I rather say corporations – actually choose to use it. (I think that Paul Graham in his essay about Java raised a very valid point: It is because all the wrong people, normally corporate suits, like Java — it is not chosen by the engineers.)

Some people at Google chose Java as the official language for Android development, so, once again, I tried to warm up to it and spend some time reading some introductory material. There are some very well written books on the market, but it only takes a few dozen pages for the sad realization to kick it that Java is an absolute horrible, overly complex and complicated mess of a language. Even worse, the whole culture of Java is a bureaucratic nightmare, and it shows in every single line of code written in the language.

Just a simple example. You want to fire one of those little text notifications that appear for a brief moment on the screen of your Android device. They are called toast messages, and in the book Android Programming – The Big Nerd Ranch Guide, the sample code for firing a toast message looks like this:


The string correct_toast needs to be defined in a file called strings.xml, and yes, that’s an XML file. Because, well, everything in Java wants to use XML – maybe because XML in its hideousness is such a great match for Java.

< resources>
< string name="correct_toast">Correct!< /string>
< string name="incorrect_toast">Incorrect!< /string>
< /resources>

When you look at the complexity of the Toast.maketext(…. line, it reveals almost everything that’s wrong with Java even on such a small scale. See all those dots? Java is absolutely anal about object-orientation and forces that concept down your throat wherever it can — whether it makes sense or not, whether it’s efficient or not. On the left side of the dot, you usually have an object and on the right side of the dot, you either have a method or a property. Now count the amount of dots and tell me that you think it’s obvious what this thing does. And then look at the Toast.makeText() call itself: There is another dot right after it: Toast.makeText().show(). Yes, makeText() obviously returns another object, and we call the show() method of that object.

Now tell me that this is friendly, simple and easy to understand – especially for people without five billion years of experience in the industry.

Java was designed for large teams of corporate programmers and their daily problems and their project sizes.

Well, I’m not a corporate programmer. I’m a one man shop who wants to get results. Naturally I’ve spent some time looking for alternatives that would make my life simpler.

When you look for real alternatives to Java for Android development, it won’t take long until you find a product called B4A, which before that was named Basic4Android. It also has siblings for Apple iOS – B4I – and for the desktop – B4J. You can find it on the Internet on The desktop version is free as in beer, the mobile versions need to be purchased but have time limited trial versions.

B4A is a Visual Basic-like programming language and the code that you write with it is eventually translated to Java and then compiled using the standard Android SDK tools. B4A comes with an own IDE and visual designer and a set of useful helper tools. (And unlike the IntelliJ-based Android Studio, the .NET based B4A IDE does not take five minutes from launch to reaching a state of responsiveness on my old notebook – which is just another thing that speaks volumes about Java.)

But what B4A really does for you is it takes away the pain that Java is.

This is how you fire a toast message in B4A:

ToastMessageShow( "Here comes a toast message with long visibility.", True )

Now isn’t that MUCH simpler and easier to read?

I’ve invested roughly the same amount of time — the equal of 1.5 work days —  with both Android Studio/Java and B4A, in each case starting from scratch with a book. In the case of Java, it was the book Android Programming – The Big Nerd Ranch Guide that I’ve mentioned before, for B4A I’ve used B4A: Rapid Android App Development Using Basic by Wyken Seagrave.

With the Java book, I got stuck after the first Hello World app and nothing compiled anymore — I’ve followed the tutorial and the compiler kept whining about some menu things it couldn’t resolve and being the Java noob that I am, I couldn’t fix it.

After spending the same amount of time with B4A, I was already playing with a second activity (read: a second program window), had buttons that used the built-in Text-To-Speech engine to actually SPEAK text messages, I had photos displayed in my app and there even is a little browser box in my test app that shows the Dilbert website just to see if I can make that work.

So I bought a license for the freshly released version 6.80 of B4A and once again failed to find any love for Java.

I have a real project for Android that I want to work on, and if things go well, you’ll find the result in the Google Play Store and in the Amazon App Store some time later this year. I will reveal the details at a later time, but you can trust me on this: It won’t be written in Java.

Comments Off on Android Programming: B4A eliminates the pain of Java

Feb 03 2017

Working From Home

Published by under Dogs

Junior in the home office.

Comments Off on Working From Home

Next »