Interview with Johan Thelin

25 Sep 2008

Johan Thelin works as a consultant focusing on embedded systems and software development, and will deliver a speech on "Qt for Embedded Linux" at FSCONS.
See also Johan's bio page and his presentations:
Qt for Embedded Linux
QtCentre Contest
For a little background, can you describe the general topic of your presentation and tell us what is new in the last few months?
My presentation will be about Qt, or embedded Qt development, and by that I don't mean maemo or handhelds - those are too general to be called embedded - instead I will focus on industrial control panels and such. We'll have a good look at the tools, the quirks but also some of the classes available at hand.
I will do a second presentation as well, but with a lighter topic. In it, I will show you some of the winners of this years Qt Programming Contest held by the QtCentre community site. The aim is really to show the quality of the contestants. Personally, I'm really hoping for the "Demo" category. It's definitions starts with "Impress us!". Hopefully that will mean eyecandy for me to show!
A handheld of today almost is a PC of yesterday, what do you see in the next step for handhelds?
I'm a believer in ubiquitous computing and I think that it is the direction that we are heading in. For example, in the past, I've relied on the printed yellow pages to avoid the computer's boot time, but now I just use my mobile phone to go to hitta.se or a similar service. That is where I think we're heading - always connected and always available at hand.
Do you think that humans being online all the time will change the way we act and take decisions. Are we becoming too dependent of the computers..... yes I admit, I just finished reading "I, robot". [http://www.wired.com/wired/archive/8.04/joy_pr.html]
I don't think that we're dependent on computers as much as information. Asking me as a technologist, yes we are dependent on computers as I see all devices with a CPU as a computer. Ask my mother and she'll say no - and then send a text message using her cell.
The key here is really that computers is only the infrastructure - just as paper was before. The current information revolution is really no different than the change that took place when the printing press came into action. All that is happening is that information is getting more available.
What is the minimum need cpu and memory wise to run Qt and Linux (the kernel)?
All you need in a framebuffer really. Another thing that is helpful is native atomic operations to be able to implement mutexes and semaphors as Qt often relies on those mechanisms. For example the 68k line of CPU needs a bit of kernel tweaking to get that working. But generally speaking, your CPU is always enough.
Memory wise I'd say, realistically, you will need at least 4 MB of RAM for Qt and your application. It might be possible to squeeze it in under a meg (I've tweaked Qt to a little less than 700kB, but that didn't leave much more than the core functions). My experience is that today's embedded system very rarely have less than 32 MB of memory, which is comfortable working space.
How well does Qt scale, since it ranges from really small devies to fullblown desktop applications? Can you compare this to other toolkits?
I'd say that is scales well. You can tune it quite nicely, something that I'll talk about. Used right you can also reduce the number of additional components required in a deployment. The trolls really work hard to make Qt a complete framework and the dependencies can be built as a part of Qt.
Performance wise you need to know what you're doing - but that applies to everything. Doing semi-transparent dialogs over a movie player requires quite a lot of processing power, so that is not really appropriate for an embedded platform. But it can be done and you as a developer can decide what you want, how you want it and how much - then you'll just have to know what your platform can deliver.
What are the most important things to consider when writing Qt code for really small devices?
Qt is no different than other embedded pieces of software. You simply need to think about what you're doing and not rely on too much memory or too much number crunching powers. Then there are some tweaks that you can use to help Qt on its way - for example telling it not to double buffer widgets and such.
Given that you're going to present Qt on really small devices, I wonder what eye candy means to you?
For embedded devices I consider fading and sliding parts of the screen being eye candy. But for the demo category in the contest I'm hoping for OpenGL and widgets being blended into something amazing.
How do you define eye candy and how much weight do you give to this in the judging?
It depends on the category. If you visit http://contest.qtcentre.org you will find the categories available this year. I'd say that the Plasmoid and Demo categories are the one's that value looks the most.
How many of the nominated projects are KDE related?
We have five registered Plasmoid projects - those I know for sure are KDE related. For the rest of the entries, we really urge them to try to rely on Qt and not KDE. There are so many community resources for KDE development so we want QtCentre to really focus on Qt. That does not mean that we exclude KDE, we just don't want to rely on it. We want to welcome developers from all platforms using Qt.
Can you give a summary of what you will present? Why should someone choose to come to your presentation?
I will present how to build embedded software using Qt - with a focus on tools and building. My aim is to explain how everything connects and why the odd things really are there. The audience would be anybody who's interested in Qt, from a beginner to the hardened pro who thinks that it has oddities.
So after your presentation everyone can build a small Qt driven device with a small lcd watering their plants?
Or making them a cup of tea :-) On a more serious side, they'll know how to do it, what tools to use and the basics of Qt. To actually make it water the plants they'll need the home automation presentation too.
As an author of a Qt book, what do you get most questions about? What seems to be hardest to learn in Qt?
The funny thing is that the biggest issues seems to come from the object orientated concept and pointers versus values. These are not really Qt issues but Qt relies on them so you need to know them. When it comes to Qt issues, the trickiest issues seems to come from threading and making blocking calls from the main event loop. That can mean that one part of your application puts a halt to another part - meaning that you try to debug the wrong code.
Speaking about debugging, does the Qt pre compilers make it harder to debug the code, looking at the source.
Not really. There are really three tools producing C++ code in Qt. The first two are the resource compiler that makes it possible to include files such as icons and sounds in your binary, and the user interface compiler that takes an XML definition of a user interface and creates a C++ class that implements that UI. Neither of these pose any problem because they simply generate straight forward code that never fails.
The third one, the meta-object compiler, has been subject to discussion, but I've never run into any issues with the code that it produces. What it does is that is keeps track of the inheritance tree so that you safely can do casts "downwards" to more specific classes. It also keeps a list of slot function names and associate them to function pointers to each such slot function.
The most common mistake surrounding this is really when you mix up slot names when making a connect call. The result is that the connections isn't made and that the call does not take place. This can produce rather confusing bugs, but the connection function always emits a warning message if the connection could not be made.
Then there is the danger of overloading functions that you point function pointers to - i.e. slots. This means that you really need to keep track of your types so that you ask the right meta-object for the function pointer. Otherwise you might end up with the base class' slot implementation.
Knowing these hurdles keep you from making these kind of mistakes and, when you really have to, work your way around them. For example, make the slot of the base class call a virtual method instead of making the slot virtual. But this isn't really affecting the debugability of the produced code, more the consequences of it. As always, you need to understand how is really works before trying the non-trivial.
How did you get involved in Free Software and in what way is it important to you?
I've been a Linux user since the late 90's and that was really my first contact with free software. Since then I've learned alot and I started contributing around 2000. My main contributions are really writing - tutorials, PR, etc - but also some smaller hacks.
If I had to explain why free software is important to me today, I would really say that it means a level playing field. To me, today, free software means business. My profession is to sell services and to write about technology. Using free technology means that I can skip all the details of NDAs, not having to worry about licensing and royalties and that I can patch the code of the tools instead of relying on a large vendor to do that.
Have you seen a change in the skills level among developers?
Not really. The biggest change I've seen is the attitude towards Qt. Back in the QPL days with licensing controversy and other nastiness Qt was not always treated nicely. Trolltech has learned a lot over the years and now all editions of Qt are available as free software under the GPL license. Looking at it from a managerial level, I can understand that they have had to fight a lot of "truths" and fear before coming to this stage. They've really dared to try this and now it feels that they have reached a business model that is free and still puts food on the table for the developers.
Is there any other particular presentation you'll be going to? Why is that topic of interest?
I've picked out a few, but not checked which ones that collide. If possible I'd love to see John Buckman's "Squeezing the Evil out of the Music Industry" because that is a problem that really needs a good solution. Working out how the music and movie industries can live in a digital world is really important.
I'd also love seeing Niclas Nilsson speak about "Agile / SCRUM" since I really believe that agile methods can give service provides such as my self a competative edge.
Then, there's Ville Solarius on "Jabber". I dream of strange automated systems emitting, filtering, exchanging and presenting short snippets of information and I think that Jabber could be a nice infrastructure for such a system.
Finally, Peter Stuge's "Coreboot" is real close to the hardware, so I just have to listen to that.
What do your customers say about free software?
It really depends. Most of them are using embedded Linux so they are accustomed to the idea, but in commercial projects commercial Qt licenses are quite common. Much because the concept of the product is built into the Qt application. However, most have evaluated the free and open source edition before buying a commercial license.
To be honest I appreciate the fact that companies are willing to pay for Qt as it means that Trolltech can hire the very best developers and maintain the a high quality support. The support and software is then made available to both the paying customers and the community. Having seen the support from both the free and closed sides I can say that there really is no difference in willingness to help and the time that it takes to deliver an answer or patch.
When will we see a new version of your book, covering the new Qt release?
I'm in the note gathering stage, but since we have a toddler at home right now I'd say at least one more year. I keep in touch with Apress and when the time is right we'll start the process. Qt 4.4 really brought lots of news not covered in any book, so there is a lot of new material to write.
What are your thoughts about Nokia buying Trolltech?
I think that it could be a good thing. The impression that I've got is that Nokia wants to learn about free software from Trolltech. I just hope that Trolltech doesn't drown in such a huge company.
What do you think was the reasons for Nokia buying Trolltech, given that Nokia's Maemo platform is gtk based?
I understand that Maemo now has Qt 4 support. Also, the Qt port of mozilla is intended for the Maemo (according to Oleg Romaxa).
There is a lot of politics involved when discussing Qt versus GTK, so it is important to point out the differences between the two. As Qt and GTK have, or at least had, different design goal, there is no reason to assume that one would replace the other.
GTK was created as a toolkit for X11. Qt on the other hand was created to make source code platform independent. So, looking at it from that perspective, Qt's interest is really to make Qt applications integrate well with GTK (and Gnome) environments.
GTK has takes great steps towards platform independence, but since the design did not start with that goal in mind, Qt is more flexible in that respect right now. Having listened to the GTK 3.0 discussion, that is bound to change as many of the issues discussed there are related to portability.
Looking at the Nokia deal in the light of this, it seems that Nokia did not have the patience to wait for GTK 3. Instead it seems like a quicker, safer and cheaper way to bend Qt so that it fits their needs.