Wednesday, March 27, 2013

Scratching Your Own Itch

It has been said that most program development in the open source community has been done by individuals scratching their own itch. In other words when there was a need they came up with their own solution to that need. Linux itself is an example of that when Linus Torvalds wanted an operating system that took advantage of the specific features of a 386 processor. He released his code, so other students wouldn't have to reinvent the wheel, and they could play with it. A good number of us today use that kernel. Some things you may want may not exist on Linux, but if you are interested in taking the time and effort to scratch your own itch this post is for you.

Development of software on Linux can be done in almost any language. The Linux/Unix community probably supports more languages on their platform than Windows and Mac OS X do. Before you say it, I do know that Mac OS X is Unix, but unless you use Mac Ports there isn't much support for doing this. Two very popular languages for development are C and Python. These two have probably the most libraries out of the other languages. C++ can use C libraries, but libraries with C++ features are not as common.

Since you are going to probably want more than just command-line utilities you should know what toolkits you can use for making graphical applications. GTK+ is the library behind Gnome, Mate, Cinnamon, XFCE and LXDE. Currently there is GTK+ 2 and 3. 2 is still more common on the distributions that are not as bleeding edge such as Debian, Red Hat and its clones, Slackware and others. Depending on your target environment you may want to take that into consideration. GTK+ is written in C and works with it by default, but Python also has bindings to the library in a package called PyGTK. The other major toolkit is Qt which is what KDE is based on. Qt is written in C++, but it can be used by Python as well. Both toolkits will work on Windows if you install the libraries there.

Another thing that should be mentioned is Python has two versions that are being maintained and worked on right now. Those are 2.x and 3.x. 3.x code is not backwards compatible with 2.x, and not all 2.x code runs on 3.x. As of now, most libraries support the 2.x series, and this why sites like Udacity as well as books and tutorials teach version 2 over 3.

There are a good number of development environments on the Linux platform. I have tried IDEs and never really liked them, but some of the ones that I have tried are Eclipse, Anjuta and Netbeans. I use Emacs as my text editor, but Vim, gedit, Kate and others work well for that. Debugging I tend to do using gdb-tui or Insight. Python of course has its own interpreter, but there are a few other implementations out there though I have never tried them. The two popular C compilers right now are gcc and clang. They both have C++ and Objective-C compilers in the suite as well. I like clang better for the static analyzer that tells you more of what's wrong with your code or what can be problematic. Clang is also C99 compliant, but I don't believe it it has an option for C89 only code which gcc does. As for your build process, you will want to read up on makefiles. Make is the standard way of building on the Unix platform. There are other tools that make the process easier such as CMake and Autotools, but I have never used either.

Hopefully that is enough to get you started with your itch scratching. Between Google, some good books, Youtube, and some trial and error you should be good to go. Another helpful resource for finding headers or functions that you may need is the apropos command, but that depends on your already having the needed library installed. Devhelp is a good tool for reference with Gnome related libraries, but not learning how to use them. Happy coding!