Thou shalt not ignore warnings

Here is a quote from a wise comment in the discussion of the “Linux system programming” book review:

Build your code with -Wall -Werror (or your compiler’s equivalent). Once you clean up all the crud, that pops up, crank it up with -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith. Once there — add -Wreturn-type -Wcast-qual -Wswitch -Wshadow -Wcast-align and tighten up by removing the no in -Wno-unused-parameter. The -Wwrite-strings is essential, if you wish your code to be compiled with a C++ compiler some day (hint: the correct type for static strings is ” const char *”).
For truly clean code, add -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls.
The people, who wrote and maintain the compiler, are, most likely, several levels above you in understanding programming in general and C-programming in particular. Ignoring the advice their code generates is foolish on your part…
As a minimum, solved warnings will make your code more readable by reducing/eliminating the “Why is he doing this?” questions. More often than not, they point out bugs you would otherwise spend hours chasing with a debugger later.
And they make your code more portable. But if you don’t understand, why a warning is generated — ask around. Don’t just “shut it up”. For example, initializing a variable at declaration is usually a no-no. If the compiler thinks, the variable may be used before being initialized, scrutinize your program’s flow. If you can’t figure out, it may some times be better to disable this one warning temporarily with -Wno-uninitialized to move on, instead of shutting it up for ever by a bogus “= 0” or some such…

Twinkle – sudden popularization of Cyprus

There was an sudden boost in searches for Cyprus yesterday.  The reason for that was a bug in Twinkle – a Twitter client for iPhone.  For some reason, Twinkle was identifying current location wrong for a whole lot of users.  Instead of being somewhere in the States, they were said to be Nicosia, Cyprus.  That probably felt very surprising for them, especially considering the fact that not many of them knew what or where Nicosia, Cyprus was.  Hence, all the searching.

There is a rumor going around that it was the work of Cyprus government, desperately trying to keep tourism levels up.  You, of course, should believe whatever your tin foil hat tells you to believe…

A quick follow-up on rapid development

Yesterday I posted about some ultra-rapid development – a couple of days for a web application. Well, it turns out I didn’t do my homework, since two days is an ultra-slow development.  At least compared to 45 minutes for a killer web application.

If you could gather together some of the smartest Web developers and ask them to brainstorm a killer app for you, what would you ask them to build? Oh, and they will only have 45 minutes to do it.

“Wow!” is all I that I can say right now… Stay tuned for the actual development.

Portability and flexibility win over performance

I noticed this ticket in WordPress TracChange enum to varchar and went in to see if there is any heated discussion.  The issue is around field types used in SQL scheme for WordPress tables.  Certain fields, such post status employed ENUM type with a set of allowed values.  The proposed change in the ticket is to convert them to VARCHAR type.

Why the change?  Well, VARCHAR is just a text field.  Anyone can put pretty much any string into it.  It has more flexibility for plugin developers and future changes – no need to tweak the SQL scheme.  ENUM on the other hand works a little bit faster.

Side note: I also thought that ENUM provides some extra data validation, assuming the ENUM field is set to NOT NULL, but it turns out this is not the case.  If you insert a record with a value which is not in the list, the NULL is used. 

The change has been approved, the patch was attached, and the world will see it in the next WordPress release.  Once again, it has been proven that human time is much more valuable than machine time.  Making it easier for plugin developers to extend and change the system has more value than that of a few extra CPU cycles to lookup in strings instead of numbers.