Archive for the 'Programming' Category

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

Mar 08 2016

GPL No Fun

Published by under Programming,Software,Thoughts

I saw a blog post called “GPL Fun” by Jonathan Riddell on Ubuntu Planet today, and it triggered this immediate stomach reaction:

The GPL remains the #1 reason why it’s always a smarter choice to bet on FreeBSD or other BSD-/MIT-licensed products/projects for commercial use. I doubt that the Nas4Free Folks will ever have a discussion – or lawsuit – like the one that VMware is seeing because they use some kind of modified Linux kernel in their ESXi hypervisor.

I believe that putting the Linux kernel under the GPL was a very, very bad idea at the time. I never understood when Linus Torvalds said that he “was afraid that somebody could take away Linux”. Did somebody ever “take away” FreeBSD? Yes, Apple built something called OS X and later iOS on top of FreeBSD that they didn’t have to openly share with the world anymore – but the original FreeBSD was still there for everybody else, so in my understanding of the term nobody took anything away.  Did Apple take away SQLite (which is in the Public Domain) when they integrated it into Aperture? No, SQLite is still there for everybody to use.

It is the whole purpose of the BSD/MIT license to enable the kind of business that Apple has been doing with their taking of the FreeBSD foundation and turning it into a commercial product.

The reason why the author of SQLite put his work into the Public Domain was to make absolutely sure that “anyone is free to copy, modify, publish, use, compile, sell, or distribute the original SQLite code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

Unless you want to force a certain ideology down your user’s throats, one where everybody is FORCED to share his own derivative work with the world, there absolutely is no upside to choosing the GPL as your license. Putting something under the GPL only means that you’re not really willing to give something away and let it be truly free   – you want something back in case somebody wants to build something else on top of your work and you’re intentionally sabotaging traditional software licensing business models with the GPL. That’s not really the spirit of “free” and “open” – it’s the spirit of restriction, it’s the spirit of “I want to keep control, just in case”. I don’t think that this is “fun”, it’s the opposite, actually. Hence “GPL No Fun” is a more fitting title.

I understand the temptation behind the GPL. After all, a lot of time and work goes into any piece of software, so once you decide to open it and share it, isn’t it only fair to get something back from the people who might want to use and modify it? Sure. But it’s also inconsequential to impose onto others. It was your own choice to open your work and share it, that is what YOU, the original author, wanted to do. In my view, it’s just not right to force others down the same road – unless, of course, your intention is to prevent them from maybe making money with your work. But if you’re going down that route, then you could as well use a proprietary, commercial license for your product. That would at least be consequential, and there’s nothing wrong with that in my opinion. People deserve to get paid for their work. But if you’re pretending to give something away and if you’re pretending to make software free by using the GPL or similar open source licenses with certain backdoors and trapdoors, then you shouldn’t be surprised when someone like me will question your motives for doing so.

I don’t want to have a religious or ideological debate about this on my page, so comments will be disabled for this post. It would all be redundant anyway – the web is full of that stuff, just google your way through GPL vs BSD and have some fun with it.

No responses yet

Next »