jLuger.de - C programming by a Java developer

At the beginning of the millennium I've learned C and did some small hobby projects but then focused on Java. I've tried once in a while to do some C but coding C in a text editor compared to program Java with Eclipse is a total mess. In fact IDEs like Eclipse are the reason why I stick with Java and didn't go to the new shiny JVM languages like Groovy. At the end of the day I'm faster with Java and Eclipse than with Groovy and a text editor. Then there was the release of Eclipse 3.7 and I've thought that I may give C a chance again.

I gave it a chance and I was very impressed. Not only autocompletion works but you can also do code browsing in the header files under /usr/include, do refactoring, and after compiling it will show error markers in the code editor. All this isn't as good as it is in Java but it is quite usable so the IDE support is no longer a reason to avoid C. So I've started a project that should search duplicates in my mailbox. I've found a library that does the mail access stuff. The library was well documented so getting the mails was easy but then I've started to realize that C is just a language and Java is a language and a Framework. In C the language provides no Collections to store the data from the server, there is no message digest algorithm, and no interface for database access. You have to search libraries that do this. One for each task. That's pretty frustrating as it isn't easy to tell what are good libraries. With good I mean, small, well document, available on much platforms, and actively maintained. OK, a large list but for most libraries I can't even answer one item.

Sounds pretty scary. For another project I've found that there is an alternative. I've stumbled across it when I wanted to create an extended version of this photo viewer: http://vimeo.com/25483019. The video lasts 12 minutes and in this time the guy shows how to create a photo viewer with python and GTK+. I wanted to create the same thing in C/GTK+ and extend it so that you can sort your images into good, bad, and neutral. See this screenshot:


Good and Bad just move the file to a subfolder with that name. What happens when you open a photo in Good/Bad folder? The text changes to Neutral and you move the photo in the parent directory.

What taught me this application? To get back to the libraries, it turned out that GTK+ with GLib is a pretty complete framework. They have a kind of collections, a message digest algorithm, and a GUI. Problem solved? Well yes and no. I didn't use Eclipse for that project but Anjuta. The advantage of Anjuta is that it creates all the necessary configuration for GTK+ based applications and that it has a decent integration of Glade (a GUI designer for GTK+). On the other hand it is inferior to eclipse when it comes to autocompletion and refactoring. So I had my framework but not anymore the cool IDE. Maybe I can get the two together for the next project.

After I've finished the application I've found out that you can slow down C based applications the same way as you can do with Swing applications. Doing long operations in callbacks has the same effect like doing long operations in Swing listeners: The GUI freezes. To get a responding GUI I will add some (pre-)caching. For a productive application I should also add a progress bar and put all work into threads but I think the pre-caching will solve it for me.