Wednesday 3 March 2010

The Road To Hell Is Paved With Bad Programmers

For the new Content Management System (CMS) for the Nyanko website I have been mucking about with MySQL (sadly) a lot, and came across one of the biggest oversights or bugs in MySQL one can imagine. The issue occurs when one tries to execute a 'SHOW TABLE STATUS' query on a table. This query returns a number of fields, one of them being 'Update_time', which contains the timestamp when the table was last updated. Unfortunately, the MySQL 5.4 documentation lists the following for this field:

"For some storage engines, this value is NULL. For example, InnoDB stores multiple tables in its tablespace and the data file timestamp does not apply. For MyISAM, the data file timestamp is used; however, on Windows the timestamp is not updated by updates so the value is inaccurate."

This basically means that it's a useless 'feature' which can in no situation be relied upon. Instead what I had to do was implement this functionality myself, by adding a table to the database which contains for each other table the timestamp when it was last updated. It also means ensuring each INSERT and UPDATE query updates this 'last updated' table.

If you're going to add a feature, at least make sure it works as advertised or just remove it. The same is true for two other software packages I used the past few days. Or tried to use at least.

As I described in my previous post, I needed some forum/wiki software for a private way for the current Even Cats Dream game team members to discuss and share information. As the database backend I had picked PostgreSQL. First I thought I would try installing eGroupWare (EGW), which failed on some mysterious PostgreSQL-related bugs which turned out to be quite common according to a Google search. Then for Small Machines Forum (SMF) pretty much the same story, with PostgreSQL support in the RC2 of SMF 2 being broken beyond repair.

It's something I encounter regularly with C/C++ libraries as well. Popular GUI libraries like Qt and WxWidgets have such a convoluted and developer-unfriendly way of integrating with applications that at times it can be beyond frustrating. Even worse is when the developer(s) of a GUI library assumes that it's okay if the application developer completely adapts the application to fit whatever twisted model the GUI library uses. For example, WxWidgets uses a heavy C++ classes-based model, and requires that any WxWidgets application becomes a sub-application of the WxWidgets runtime, using virtually only derived WxWidgets classes.

Maybe I'm the exception, but I really dislike using classes and other Object Oriented forms of programming unless I can see a really good reason to use them. It's a style of programming which just doesn't jive with me. I also like modular programming with the use of header files to define an API and the source file which implements it. It's clear, easy to understand and follow and has virtually no overhead. The use of classes always requires overhead during run time and can lead to very interesting (read: frustrating) errors.

*listens to Winamp playing The Offspring - Staring at the Sun*

If one reads a site like The Daily WTF ( http://thedailywtf.com/ ), one comes across countless examples of bad programming, poorly thought out and/or implemented ideas and attitudes among both programmers and managers alike which will have you running screaming for the hills. The scary part? At least most of them are confirmed real. Some of such code runs mission-critical business operations, others are in medical devices, yet others run communication networks. Think back to the recent mess around the software used in voting machines which among other things lead to them getting banned here in the Netherlands. While our voting machines were still relatively secure, those in the US were found to be completely unreliable and very easy to manipulate by independent researchers. All due to poor design and poor programming.

I must admit to considering it to be a joyful challenge to design a piece of software which is simple, elegant and reliable. Take for example this CMS I am writing. At this point it's only tens of kBs in size, can do the same things a bloated CMS like Joomla or Drupal can do and then some and is extremely easy to write modules for or otherwise modify.

What I find to be hardest question is that of whether I should release this NCMS to the public in some form or not, and if I do under which license. I have never liked the idea of someone forking a software project resulting in completely independent development when the original project was doing fine. In the case of the XFree86 project which suffered from chronical mismanagement and at least one case of 'better-than-thou' attitude on its developer's side, it was understandable, logical and very commendable that it got forked into the X.org project. Even if I hate X more than is possibly healthy, as it's yet another example of poor engineering and poor programming which has been festering in UNIX and now other OSs as well for decades.

One of my dreams is to use NetBSD as a scaffold to implement a better GUI than X which could totally erase the latter from the face of the earth, much like I hope NCMS will wipe the floor with other CMSs. Simply because I love good code and well-written applications which work as advertised :)


Maya

No comments: