Wednesday, December 25, 2013

Qt Creator: a superb IDE for Linux

I learned programming in school with an ancient IDE: Turbo C++. I never got over the idea: the command-line is great for productivity, but there are times when you just want to explore. An IDE feels just right for such recreation. You can poke around and learn the environment. I developed an itch to test out a C/C++ IDE a few weeks ago.

Many people recommend Microsoft Visual Studio Express, and there is a free version for Windows XP. I spend most of my time on Linux machines so it would be a lot more useful to develop for Linux. In addition, my Windows XP machine is anemic compared to my Linux desktop. So I began looking for a good contemporary Linux IDE. Anjuta and QT creator both get good reviews. Anjuta was built for Gnome development, while QT creator focuses on the Qt toolkit. I am unfamiliar with Qt and have wanted to explore it, so I tried QT creator.

...and I found that QT creator is impressive! You can navigate to their web page or their Wikipedia entry to learn more. In short, it is a one-stop shop for project development, debugging, inspection. They have detailed tutorials through which you can learn the Qt toolkit. You can debug right from the IDE, inspect variables, set breakpoints.

My favorite feature is the integrated assembly debugging. You can get the disassembled output and step over an instruction at a time. You can view registers and it will highlight the ones that have changed after each line gets executed. This is a great way to learn assembly. The code is interspersed with assembly instructions. Even comments are included in the disassembly so you can find your way around. Now I wonder if we could install Qt creator on a Raspberry pi and use it to learn ARM assembly directly on the device. Here is a screenshot of the assembly output on the left and C++ source on the right. Pop quiz: what's my architecture?

Good C++ programmers understand what is going on under the hood. The innocuous line " : QWidget(parent)" produces a lot of assembly above because the child class (AddressBook) is initializing its parent (QWidget). Looking at the generated assembly code, you can learn the innards of C++, in addition to learning about your architecture. There are many books on 32 bit Intel assembly but few on 64-bit Intel assembly. So poking at toy examples is a great way to learn how something is implemented.

Qt creator integrates with good source control tools like git, subversion, ... And it integrates with memory analysis tools like valgrind.

This is an amazing tool, highly recommended for casual C++ hacking. Here's the full screenshot. You can click on it to expand the image.

Image courtesy: me.