Translate

Archives

Currently C Is the Most Popular Programming Language

The TIOBE Programming Community Index for April 2012 shows that C is the most popular programming language (17.5%), closely followed by Java (17.02%) followed by C++ at 8.89%. It is not that C is becoming more popular – it has been flatlined at 17-18% for a long time – it is that the use of Java in new code is declining. Frankly, I am not surprised by the decline in Java. It was dreadfully over-hyped in the first place and has become increasing difficult to support due to the large number of overlapping class libraries. Like Cobol, Java still has

Sprintf Portability and Leading Zeros

On some platforms, code such as the following can be used to output a string with leading zeros left padded to a length of 4. sprintf(*str, “%04s”, *pstr); This works on AIX for example. However if the same code is compiled on Linux using gcc, it outputs leading spaces, padded to a length of 4, instead of leading zeros. There is no simple way to fix this behavior. This particular usage of leading zero padding with the string format is explicitly undefined in the various C standards. What is outputted depends on a platform’s libraries rather than the compiler. As

Programmatically List Installed .deb Packages

While RPM packages have a robust ecosystem around them for programmatically retrieving information about package metadata, the Debian package management system is sorely lacking in this respect. Here is a simple C example which demonstrates how to programmatically list all installed Debian packages. #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> #include <dpkg/pkg-array.h> #include "filesdb.h" const char thisname[] = "example1"; int main(int argc, const char *const *argv) { struct pkg_array array; struct pkginfo *pkg; int i; enum modstatdb_rw msdb_status; standard_startup(); filesdbinit(); msdb_status = modstatdb_open(msdbrw_readonly); pkg_infodb_init(msdb_status); pkg_array_init_from_db(&array); pkg_array_sort(&array, pkg_sorter_by_name); for (i = 0; i <

Programmatically Retrieve RPM Package Details

This post shows you how to access various types of information in the RPM database and RPM package files using C and Python.

V8 JavaScript Engine on Fedora 14

This post shows you how to build the two V8 JavaScript shells on Fedora 14 and modify them to support shebang functionality. It also shows you how to modify the samples shell to support command line history.