Programming languages re-visit


After many years of experience in programming, gradually I have newer perspective towards the programming languages. Previously, I was fervent in C language, which I assumed as a low level, powerful programming language. The OS kernel such as Linux is written in C language. To use C language, we need a lot of computer science knowledge, such as pointer, memory buffer, linked list, and so on. Furthermore, there are a lot of libraries supported in C, and C libraries can be ported to C++. That is why I liked C so much. Moreover, the library such as “glib” can make C written in object-oriented. By the knowledge of C language, learning other programming languages will be easier.


However, writing programs in C language is exhaustive. They are difficult to maintain, and writing the functions with the parameter “struct” pointer is troublesome. Creating linked list, stack, queue, tree, and other abstract data type (ADT) are time consuming. That is why I finally adopt the object-oriented paradigm (OOP), C++ language. With the C++ standard libraries, C++ development is far easier than C. Creating the objects and also the templates allows to re-use the source code easily. Exception handling makes the debugging process easier. It is better use for the application development. Furthermore, most of the C programming codes are compatible to C++, since C can be considered as a subset of C++ (though not totally subset).

Command-line compilation

Since I like C and C++, I preferred to use command-line compilation. The best way to perform command-line compilation is using GCC and autotools (automake, autoconf, and libtool). By learning to use these tools, this make me gain the profound knowledge about compiler, linker, libraries, compiled object (object code), binary, and binary executable.

PHP and Perl

However, different programming languages should be used in different situation. It is possible to develop web applications or interactive webpages using C and C++ through CGI, yet this is slower than other programming languages targeted on web development, such as PHP. Besides that, the applications which highly requires text processing should use the language such as Perl. I like these languages, but less fervent as C and C++.


Similar to PHP and Perl, Python is another interpreted programming language (though it can be compiled in bytecode like Java). This programming language becomes my favourite since it is used in rapid application development (RAD). Without compilation, I can test my code (algorithm) easily. Without compilation, using Python is time saving. It is used in general purpose including developing GUI applications, command-line applications, text processing using regular expression, reading CSV file, read-write SQLite file, processing JSON file, preforming complex mathematical calculations, implementing computer vision (using OpenCV libraries), or even creating web applications (though I have not use it in this purpose). It is especially good for me to test the AI (Artificial Intelligence) algorithms, such as Genetic Algorithms, Artificial Neural Network, etc.

Android application development

Previously, I had done a little Android mobile development. Since I prefer C and C++, and Android provides NDK (native development kit), it was interesting for me to create Android applications with C and C++ through command-line. However, I found that it was too exhaustive and time consuming. This is because Android is not designed to use C/C++. Though the NDK is provided and it uses GCC and autotools, building the application is not same as the conventional way in GCC in normal desktop. That is why it recommends to use Apache Ant, run the “ndk-build” command, and even create the project from the sample project.

Java is the primary programming language use in Android. It is used with Eclipse installed with ADT plugin as the main IDE (integrated development environment). Developing Android application using these default tools are far easier than using NDK.

Microsoft Windows and Linux

As a result, now I accept the GUI development using IDE. Previously, I had bad experiences using Microsoft Visual C++. This was because linking the libraries are difficult (because lacked of the knowledge during that time); compiling open source libraries did not work well (due to the C and C++ standard differences between Visual C++ compiler and GCC).

Therefore, cross platform source code without modification for target OS is not working also. Then I used Cygwin and MinGW. Both work fine, yet not the best. Cygwin has the license issue and MinGW has a lot of compilation problems. That is why I abandoned Windows and focused on Linux.

Yes, Linux is the best for development, since there are a lot of development tools: GCC for C language, C++ language, Haskell compiler, interpreters for PHP, Perl, Python, Ruby, Lua, OpenJDK for Java, Mono for C#, and thousands of libraries.

OS, IDE, compiler

Therefore, now I understand that, just like different programming languages are chosen to solve different problems, the OS is also a factor to decide the programming languages to be used. Such as developing Windows application, .NET Framework related programming language is a better choice. Android application development should use Java language. Linux developers can use wide range of programming languages.

Furthermore, developing the Java applications, the IDE such as Eclipse or NetBean can be chosen. They are useful in creating GUI components. The applications involves Qt can use Qt Designer; applications that involves Gtk+/GNOME can use Anjuta DevStudio. By using IDE, debugging becomes much more easier than using GDB (command-line debugging).

Compiler and the OS are also related. Just like the case in Windows, the compiler such as MinGW or Cygwin has its own issues/problems, Visual C++ compiler has its own limitation also. Besides that, FreeBSD has adopted LLVM/Clang as the default compiler instead of GCC (though I does not use it and does not know what is the major differences).


Programming languages and software development are interesting. Knowing one language can only develop limited areas of application. Knowing one OS can only target on the audience of the particular OS. Using one type of IDE can only limited the knowledge within the IDE. Using command-line compiler will limit the productivity of software development (as what I did).

Lastly, knowing one type of programming paradigm only, such as procedural paradigm or OOP, will limit our perspective to solve the problem. Learning other paradigm such as functional programming will make us think differently to solve the same problem.

Knowledge Tree

This is an interesting thing. I love the tree so much. The Knowledge Tree here I mean is not referring to the Tree of Knowledge of Good and Bad.

Tree is a graph theory. The powerfulness of tree, is that almost any data structure can be represented into the tree. In order to store the data, we can use a single variable, for a single data. In order to store a list of data, we can use array and associative array (or hash, map, dictionary), list, vector, and others. Another powerful data structure which I like is the 2D array, especially used in matrix calculation. The 2D array represents the data in the table form. It is very useful in database. An image can also be treated as 2D array. Comparing the tree to the matrix, the tree is possible to represent the matrix (though it is not preferred).

Tree is mostly used in the programming, especially data representation such as JSON, XML, HTML, YAML, scene graph. Even the object (oriented) can be assumed as a tree, with the attributes and methods as the leaves, and the inheritance a parent-child relationship in the tree. Moreover, the programming languages can be parsed into parse tree and abstract syntax tree. The Python language is wonderful with the indentation syntax, which the indentation can be thought as the tree also.

In the decision support tools, the decision tree is used. In the pathfinding, such as depth first search, breath first search, A* search, these are also represented as graph and tree. In the file system, we have files and directories, these are also tree representation that is why the “/” is called the root directory. Furthermore, in the version control such as CVS, SVN, Git, Mercurial and else, they are also trees. That is why there are trunk and branches in the versioning system. In a document, we have heading 1, 2, 3, and so on with the body text. This makes our documents also a tree structure.

As a result, by combining these together, especially Python’s indentation syntax, I am creating my knowledge base using the tree forms. This is easy because creating something like concept map needs image editor software, it is time consuming. So, just using a plain text editor, with indentation, this helps me to manage my knowledge easier.


Text editor
        quit, open, save
        buffers (open multiple files)
        insert, delete, select (or highlight)
        cut, copy, paste (or yank)
        find, find next, find previous
        search and replace (with regular expression)
        undo, redo
        windows (split)
        syntax highlighting

The above is an example of my knowledge node, which is a text editor with the generic features. The next one is about the data types of database.

            int, tinyint, samllint, mediumint, bigint
            varchar, char
            enum, set

The Arch way of syncing script

I like FreeFileSync, a syncing utility. There are several reasons for me to consider it is a good syncing utility,

  • Allows preview
  • Mirror, destination exactly as source
  • Update, update destination based on source, no deletion
  • Sync, allows propagate deletion, detects conflicts.
  • Delete to Trash can (or Recycle bin)
  • Multiple pairs of folders
  • Swap directions
  • Allows to edit the direction of specific files, or ignore the files.

All the bold features are which I prefer the most, especially the last one. That means, after the preview (or comparing), I can decide to change the direction of the files to be copied, left-to-right or right-to-left.

The next thing I like about FreeFileSync is the cross-platform. It is working on Windows and Linux. However, there is a drawback, it does not work in Mac OS X. Then, I look for other alternative syncing tools that work on Mac OS X with these features. None of them works as FreeFileSync.

The best among them is Synkron. However, the Synkron’s interface is not as intuitive as FreeFileSync. It uses multiple tabs for the syncing pairs. I cannot edit the syncing direction of specific files as FreeFileSync.

As a result, I tried to write a shell script to solve the syncing problem on Mac OS X. The script does not have all the features as FreeFileSync, but it provides an easier way for me to do the syncing. Since I like Arch Linux, I tried to use the Arch Linux way to write the script.

So, my shell script uses “rsync” for synchronisation. The script will read a configuration file, written in shell script form. The pairs of folders are written in an array form.

#example, sync.conf
pairs=("temp/" "temp2/" #first pair, always use variable called "pairs"
"foo/" "bar/") #next pair
# Always trailing with "/" for each directory, it is based on rsync

The script actually works with rsync for each pair of items in “pairs” array. To use the script,

./ -f sync.conf

Then, there are 2 prompts, first let you make sure the then pairs and the pairs and the synchronisation mode, update, mirror, or merge. Default mode is “mirror”.

The following is your synchronization setting:
temp/    =>     temp2/
foo/     =>     bar/
Mode: mirror
Confirm this setting? [y,n]

If “y” (yes), then the script will use rsync to do a dry-run (meaning without any changes), this is something like preview. Then, the second prompt asks for confirmation whether you want to continue. If “yes”, then start syncing.

One of the features I like over the script is the backup. The script will backup the deleted files into the folder “syncYYYYMMDD”. This is because I cannot use the Trash Can from command-line. So, I am using this script to sync in Mac OS X.

The script is available here.

My rules of thumb for using multiple programming languages

Since I know multiple programming languages: C, C++, Python, PHP, Perl, Java, C#, I would like to share about my rules of thumb to choose which language during the development. So, when do I use these languages?

When doing the web development, I will definitely use PHP. It is easy to configure with Apache and MySQL.

When doing the text processing, cleaning the unwanted text, search and replace, I will definitely use Perl, because of the power of regular expression it provides. However, if the search and replace pattern is simple, then I will just use “sed” command or “awk” command.

Then, if I want to develop an application rapidly, Python is my first choice. The GUI can be used with PyGTK.

If I want to develop an end user application, then I will use C++. Because it will produce compiled executable binary. No interpreter needed.

When the application I want to build needs to be cross-platform, from the desktop to the web, then I have no choice, but choosing Java. I don’t choose over Java in developing general application because Java uses Swing, but I prefer GTK (in the sense of development, not the Look and Feel).

For the C#, I learnt it because of curiosity. I will not use it if possible.

Then, for the shell script, which I prefer bash. I will write a shell script when processing a bunch of files with other command-line tools, such as perl, sed, rsync, etc.

As a conclusion, my most favourite programming languages are C++ and Python for desktop application development, then PHP for the web development.

My Pomodoro

Do you know Pomodoro technique? I like this technique, which can make me work more productive. That is why, I installed tomate in Linux. It is a very simple application with only a click at the system icon (tray icon). However, there is no way for me to customize “tomate”. So, I tried to write my own Pomodoro application with GTK+. Now, let me share about my recent programming experience.

From C to C++

I love C language, as it is a low level programming language comparing to C++, Java, Python, etc. Yet, it is more portable than assembly language. The C functions allow shared library to be used by other application written by other languages. How good it is! That is why I like writing libraries, functions, command-line, instead of designing GUI (graphical user interface). Because designing GUI involves usability engineering, user experience, and user centred design. That means, developing GUI application should study about the targeted audience. However, I wrote the programs for myself only, I am the user.

Today technology, is more to cloud computing. Everything is about Internet, networking, social networking, web-based application, online games. People will focus more on PHP, MySQL, HTML5, CSS, Javascript, jQuery, Google Chrome extensions, other PHP frameworks such as CodeIgniter, CakePHP, or other languages such as Ruby and Python. Yeah. I know these except Ruby, which I haven’t touched about it yet. I was wondering why? In my opinion, there are several factors:

  • Cross-platform – As we only need a web-browser, we can access any website. We can use Linux, Mac, Windows, or FreeBSD.
  • Useful – Connect everyone, provide information, searching, entertaining (playing games, listen musics, watching video (Youtube))
  • Multi-disciplinary – Programmers can develop the system, designers can design user interface, marketing staff can use internet for advertisement, photographers and writers can do blogging, etc
  • Easy – Anyone can use.

So, I was wondering from the programmer aspect, why theses factors exist. Firstly, a designer can simply design the website easily with HTML and CSS. The design of HTML is based on DOM (Document Object Model). A programmer, needs to have the knowledge at least Javascript, and a server scripting language, such as PHP. Javascript, supporting object oriented, and PHP is influenced by C++, also object oriented. The PHP frameworks such as CodeIgniter and CakePHP are also object oriented. The XML is also using DOM. JSON is also an object. So, everything point to object. Even my favourite GTK+ is also using GObject. Even more, the “string” in C++ is much useful than C string. So, I admit that, C language is powerful, but C++ is even more powerful.

From GTK+ to gtkmm

Since I am moving from C to C++, and since I chose GTK+ instead of Qt because of the C language, so I am moving from GTK+ to gtkmm as well. Since I am using gtkmm and developing the GUI, I try to make the development easier with Glade. I am really glad with Glade. With Glade, GtkBuilder and gtkmm, I can develop the applications more rapidly.

Finally, my Pomodoro is only an alpha version, and I haven’t made it open source. You can download here. It contains both Win32 version and also Linux version.

Pomodoro on Linux

Comic Downloader alpha stage

I wrote several Greasemonkey userscripts. However, the Javascript has its own limitation for security reason, especially when a website uses scripts from cross domain. As a result, Javascript cannot get the information, and my userscript fails to work. Therefore, I start another project, in order to solve the cross domain problem using Python, and targeted on Linux (Ubuntu).

The current development stage is alpha, and targeted only on one website, since the other websites I frequently visit still work with Greasemonkey userscript. The alpha stage of Comic Downloader is currently work in command-line. GUI feature will be added in future with PyGTK. Currently, the command-line is able to solve my problem for offline comic reading.

Feel free to visit the project page.

Running Mono (C#) pre-compiled by Linux in Windows

Finally, I success to run Mono with GTK# pre-compiled by Linux in Windows.

Firstly, make sure Windows is installed with

With the above installation, one can run the Mono application normally. I failed previously because I didn’t install GTK# for .NET.

However, when I run the application, there is a console window, which is annoyance. Thus, build the Mono application with

gmcs yoursource.cs -pkg:gtk-sharp-2.0 -target:winexe

By using “-target:winexe”, there will be no console window.

Yes, this is a light for me for cross-platform software development. Though I haven’t tried this on Mac OS X, but hopefully it works. I found that Mono is better than Java. Mono GTK# unlike Java Swing which cause me a lot of troubles. Java Swing though can run in cross-platform, it produces unexpected GUI differences. (Such as running GridBagLayout of Java in Ubuntu. One can give a try with Password Cipher Java Edition). I think I will move to Mono with GTK# instead of Java.