Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

December 10, 2007

Progress

I've been translating Parcellite to C for version 0.5. So far I have it catching clipboard history and the history menu is working. Been going at a slow pace, I want to make sure the code is clean and as bug free as I can write it. I would be further along if I hadn't spent more time understanding how the autotools work.

You can grab the current progress from the C branch of my subversion.

svn co http://xyhthyx.googlecode.com/svn/branches/C/ parcellite-C


At the moment you need the latest autotools. Just do the following to compile.

./autogen.sh
./configure
make
sudo make install

December 5, 2007

Language Readability

The latest xkcd comic is win.

For educational purposes, I will compare a simple GTK+ about dialog in Python versus one in C.

Python
about_dialog = gtk.AboutDialog()
about_dialog.set_icon(about_dialog.render_icon(gtk.STOCK_ABOUT, gtk.ICON_SIZE_MENU))
about_dialog.run()
about_dialog.destroy()


Simple, readable. All I did was create a dialog, set its icon and name, run it then destroy it. In C it's a different story.

C
GtkWidget* about_dialog = gtk_about_dialog_new();
gtk_window_set_icon(GTK_WINDOW(about_dialog), gtk_widget_render_icon(about_dialog, GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU, NULL));
gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about_dialog), "Parcellite");
gtk_dialog_run(GTK_DIALOG(about_dialog));
gtk_widget_destroy(about_dialog);


Sacrificing readability for speed? I think it's worth it.

November 21, 2007

Studying C

I borrowed the book C How to Program from a friend in order to get started learning C. This book, in addition to this excelent resource (although outdated) I'll be studying and practicing in my free time until I feel comfortable using C.