2008-07-05

On task list managers

The use cases I need for a task list application are:
  • I am at the middle of nowhere and some task pops up in my head. I need to save it quickly to prevent it being forgotten. I need to action my mobile phone into "new task" and type the text or record a voice message that will be voice recognized or later transcribed by me to text to be able to full text search it.
  • I also need to quickly append to tasks. So, I need to buy something and I just type shop and my shopping list entry appears. I select it and just add an item to it. (this feature needs full-text search with partial word matching)
  • I need to be able to full text search all my tasks, and since they are so many, they should be indexed to be able to search (like Google) by typing some words. They could be tag categorized (hierarchies are not as useful).
  • Each task should have a reviewed date attached to let me be able to review most old entries and update that date after review.
  • Tasks should notify me at a certain date/time and/or (using Assisted GPS) when I am near a place where I may be able to complete the task (just like Geolife does). To this end each task should have optional date/time and location fields.
  • There are certain repetitive tasks like, for example, cutting the grass that need to be rescheduled once they are completed (otherwise I forget and too much time can pass), so I need to set a time to notify and be able to review if it was too long or too short.
  • Be able to group tasks into toplevel projects or goals. So tasks can have subtasks. And be able to perform operations like review on a task's subtasks.
  • Any task may depend on any other task that would block the first task until it is completed. The user interface should (by default) show only tasks that do not depend on any other for completion. Dependent tasks may be external (maybe other person) and they may be on the shared task list with that other person or even in a public task list.
  • It needs to be scalable to a lot of task entries without losing performance. It should be as O(1) as possible. I have 800 tasks just for one year of use (the Nokia N80 slows a lot with so many tasks) so it would need to be scalable to 100000 tasks to cover a life time. This requirement adds up to using efficient storage like SQLite and having a GUI that can cope with 100000 tasks in the full task list view (probably it should only render some tasks at a time to be fast and do not require huge amounts of memory something that the N80 is not doing)
  • I need to be able to sort tasks by priority. (You can not sort tasks by priority if you have more than 5 tasks using just 5 priorities)
  • Off-line usage. I may not have Internet connection but I still need to access (and search) my tasks.
  • Synchronization. I want to be able to add, edit and remove tasks from by mobile device and my desktop computer. This will also serve as backup as the tasks will reside in any synchronized device.
  • Keep history of changes. In case I did an incorrect edit or deletion.
GTD: Task management with Android software apps is also a good requirements list and a comparison of Android applications.
I am currently using my Nokia N80 as my task list manager, but as you can see from the above list it does not meet all my requirements.
A good on-line task manager is Remember The Milk: Online to do list and task management but it is mostly an online app. Things for Mac and iPhone is also a great one.

2008-06-19

On library and its API versions

Many people still confuse the library version and its API version. This leads to problems like not knowing what APIs are supported and when deprecated API will be removed.

There are lots of unuseful versioning examples out there. I am going to present the most useful and correct one.

The API version needs just one number, that is increased when new API is added to the existing one.

So, for example. we can have our "geometry3" API that has an API version number of 1.
If we add a method area() to our Shape class we increment the API version number to 2. There should not be any problem because old API version1 users will still be able to use all the implemented API.

Also, it is possible to have a library implement various APIs. Like in our example it would be able to implement "geometry2" and "geometry3" to support an easy migration to the new API. After some time of "geometry2" being deprecated it could be removed.

For the library version we just need a number (or date) to be able to differentiate old releases for new ones (and be able to differentiate library files).

So, for example, or library version could be 20080610 and if you look what API versions it implements you would be able to see "geometry2.5" and "geometry3.2".

So when you create a new interface like "geometry4" you start from scratch and can add API from new minor API version to the next, but you must not change or remove API since that would break compatibility from prior minor API version number users.

It is common to just have different binaries that implement each API mayor version like having libgtk-1.2.so.0 and libgtk-x11-2.0.so.0 but you could be able to just have a libgtk that implements both APIs in the same binary. You could also be able to have different binaries implementing the same APIs in that case there is a need to a way to specify what library should provide what interface to your binary, maybe using dependency injection.

So, package managers like APT, should work by having programs depend on API versions like "geometry3.2" and be able to fetch a library package that implements "geometry3.2" or newer like "geometry3.4"

2008-05-31

On Office Document formats

I am horrified by what Microsoft is doing to the world with the introduction of their suspiciously ISO fast-tracked bad designed OOXML formats, that made ISO not independent anymore as it seems ISO has been bought by Microsoft.

There is already the great OpenDocument format that conforms to other ISO standards.

I think Google expressed very well the problem with OOXML. But anyway OOXML is not even harmonic itself.

Now, that ISO made clear that their standards are not serious. The effort would be either to stop the corruption inside ISO or made international governments either audit ISO or stop accepting ISO standards and move to a fairer organization that maintains standards. At NoOOXML there is much more information about this issue.

OOXML is just an excuse for Microsoft to break the document format again and force users to upgrade. I am sure they could not care less about standards and collaboration.

On Software Build Systems

A Software Build System is a program that accepts a series of input files:
And outputs a series of files in another location (to allow building from read-only sources):
  • Archives (WAR, or JAR) (compiled or minimized code and minimized HTML and CSS)
Apache Maven is a great build system as it can automatically upgrade and download external dependencies and uses a clear folder structure shared by most projects.

2008-05-19

On Debian OpenSSL problem DSA-1571-1

It is sad what happened to Debian OpenSSL leaving all keys weak (DSA-1571-1 openssl -- predictable random number generator) (Slashdot | Debian Bug Leaves Private SSL/SSH Keys Guessable).

When I started using Valgrind long time ago and Valgrind warning about it, I knew something like this could happen.

To detect weak keys, all the keys to take advantage of this problem are already available: Debian OpenSSL Predictable PRNG Toys.

Open source software is getting lots of momentum and it needs software changes reviewing to prevent this kind of things happening. The Linux kernel has mostly good reviewing by having each patch needing review from at least two developers, one of the module maintainers and a core Linux developer (Introduction to Linux kernel development process).

2008-05-14

On GNU Autotools

I do not like the GNU Autotools because they make me program shell scripts which I do not like, they generate shell scripts that must be distributed with the released tarball (I do not like to distribute generated files from source if I am already distributing source code), and it is neither backwards not upwards compatible making it problematic to maintain these files. Here is an old article that explains the main problems with the GNU Build System.

2008-04-23

On Wikis

I have found Wikis to be a really useful tool for documentation in any environment.

For Wikipedia it has been such a success because it allows editors to collaborate in an article without having a direct approval of any modification but doing any rollback if the change was incorrect.

For corporate environment a wiki is a clear winner. I have seen most people just do a document that it is left to be rotten as people share it over email and is gradually outdated. Just having a URL with a wiki page is a much more useful resource to keep any documentation up to date.

My preferred Wiki software is MediaWiki because it is extremely intuitive and fast, has a clear UI design and is actively developed (compared to other wikis like MoinMoin or XWiki that have no clear UI or are just bloated). MediaWiki is being used at Java projects like Eclipse, even being written in PHP.

2008-04-22

On SQL Injection

SQL injection is sadly still a very common problem. Software broadly deployed like WordPress still has SQL Injection Vulnerabilities because instead of using prepared statements in PHP with MDB2 they encode the parameters they think that could be used in a SQL injection. I really think that is not the way to go and I suggest to everyone using prepared statements (java). Also, many SQL servers like MySQL have support for prepared statements, so it may even speed up the application. To force you to use prepared statements and clean your application from unsafe SQL some databases, like H2, allow you to disable literals in SQL statements.

Using object-relational mapping solutions like Java Persistence API/Hibernate can ease programming to prevent SQL injection because most INSERT, UPDATE, DELETE takes care the ORM directly. You still have to use setParameter in SELECT.

Community owned software

The Linux kernel is community owned software because the source code is copyrighted by many individuals and companies whereas OpenOffice.org, OpenJDK or Qt is company owned software because Sun Microsystems and Trolltech have the copyright respectively. This allows them to license the software using any license, open source or privative ones. With community owned software like the Linux kernel this is really difficult because every owner should agree to any licensing changes and it can not be licensed privately because of this.

2008-04-21

On Linux distributions

My preferred Linux distribution is Debian because:
  • APT and dpkg, these tools make life so easier that is difficult moving to anything else.
  • Debian web tools are great to keep track of any package and discuss anything with the Debian community.
Ubuntu is 2nd, but I recommend it to anyone, as desktop operating system, instead of Debian, as Ubuntu is more user friendly and easier to use than Debian.

I do not use:
  • SUSE Linux because YaST has always got me headaches (different problems with different versions of SUSE) and I do not like the Microsoft-Novell pact.
  • Gentoo Linux because it is not a practical distribution as you have to spend ages recompiling software (you can also do that with Debian if you want) and is definitely not user friendly as you have to configure too many things where a distribution like Ubuntu (or even Debian) provides sane defaults. Take a look at this video of Gentoo Linux installation.
  • Fedora. I would try it if it did not use RPM that I dislike. Fedora also has some problems that you will see quite early like font rendering. Fedora is also a good candidate to a desktop Linux distribution but I have found that Ubuntu is just more polished.
  • Slackware. Just do not use it. Having simple packages with no dependencies can give you major headaches.
Of course, for quality and industry proved support Red Hat Enterprise Linux and SUSE Linux Enterprise Server are the distributions to go if running production critical applications.

2008-03-16

On Issue Tracking Systems

I have found Issue Tracking Systems to be much more convenient than email in many tasks.
In any organization having an Issue Tracking System is a must as it keeps clear what task should be done by what department and who is the person assigned the task.
The problem is that as currently business work they never show the issue tracking system to an outsider (aka client) but instead the client must always communicate with the call center. An issue tracking system should be open to outside client for maximum effectiveness.

Any company or project should always use an issue tracking system.

My favorite issue tracker is Bugzilla, but I would change the comments list with a wiki entry and associated discussion (like Wikipedia has) for every issue.

Popularity of Issue Tracking Systems among developers

2008-03-02

Client/Server APIs are essential

I have to work with lots of systems where only one UI is provided and no programming API is available so accessing that systems programmatically needs to use code like HtmlUnit or similar.
Instead business should always develop and/or install software with Service-oriented architecture always in mind. Another very important aspect is the use of Business Process Management to take care of every process of the organization first correctly documenting it and later automating it.

2008-02-13

Component-based software engineering

I am a big supporter of Component-based software engineering.

When everything is a component you can remove any of its components without any problem and the application continues working but without that component. It is always a very good idea to componentize your application to clean the code and make it easier to read and modify.

In GLib you must always make your objects throw signals instead of calling other objects methods. This way you can remove any other object and have you component still working.

Using the GObject system of GLib is quite easy and efficient to make components encapsulated and reusable.
In Java you have Observer/Observable and OSGi.

2008-01-28

On Memory Leaks

I have been using Purify and Valgrind to debug memory leaks in C/C++ programs both in open source projects and for some clients.
For practical reasons both have the same functionality and are able to debug the same problems (memory leaks and invalid access to memory regions)
If you are developing any C/C++ code and doing any allocation in the heap (either using malloc() or other means like new) you must run always your code through either these power debuggers that will almost always find any problems in your code.
If you need any help do not hesitate to contact me. I will help you with your code.

For Java, I recommend the great free open source Eclipse Memory Analyzer that will for sure help you plug the leak.

2008-01-25

Data Backup Systems

Something I am very interested in is Data Backup Systems.

The cases I want to prevent are:
The solution needs:
  • Be able to backup my data and only backup URLs of data that can be easily downloaded from the Internet, not wasting backup space.
  • Data stored in multiple places separated physically from one another (to prevent both being damaged at the same time) using a remote backup service.
  • Data stored to be only read, so no computer virus or malicious user can corrupt backups.
  • Data stored incrementally to be able to quickly and easily see changes in time of the data.
  • Be able to get any file at any point past in time.
  • Be totally automated and non-intrusive.
  • Do a perfect snapshot of every backup. Backups should never be corrupt.
  • Encrypted, so data can be sent to untrusted external storage.
Current solutions:
  • Use always RAID1 (at least). Setting up software RAID in Linux is extremely easy and works exceptionally well. With Linux you just need two hard drives (no need for them to be identical) and you do not need a RAID controller if you use software RAID as it works great and it may be even faster than hardware RAID. I will help you if you have any problems with it.
  • Set up automatic encrypted backups to off-site storage (like a web server).
  • Mac OS X users may be able to use Apple Time Machine but it lacks true network backup as backing up just to another local hard drive is not the best option.

2008-01-04

Unicode Strings and byte buffers

Prior to Unicode there was ASCII or ISO 8859-1 (except for Microsoft that used their own encoding to lock-in users) and string manipulation was not hard.

Now, Unicode is the future since everyone wants an easy solution to integrate all the characters of all the languages of the world to be supported by every application.

It seems like lots of programming languages have problems handling Unicode strings, mainly because they put Strings and byte buffers on the same bucket.
Maybe, some of the programming languages that have problems with Unicode handling is because programmers are using the API incorrectly, but some of them have a real design flaw that make working correctly with Unicode strings impossible.

My test to know if a programming language has correct Unicode support is just uppercasing the "á" string and verify the "Á" string is returned.

Languages that have a correct API include:
  • C with glib (using UTF-8) : g_utf8_strup("á",-1) -> Á
  • Java I do not know any way to do a better API. Java totally differentiates a string from a byte buffer. "á".toUpperCase() -> Á
  • C# has correct Unicode support: "á".ToUpper() -> Á
  • Python3 does Unicode handling just like Java did from 1.0 released at 1995. Python is finally catching up with Java! Take a look at What’s New in Python 3.0 so you can know what was fixed. print("á".upper()) -> Á
Languages with hard to use (but correct) Unicode support:Languages that lack Unicode support:

2007-12-27

Shopping for clothing is hard

Here is a list of shops with my comments of them:
  • Outlet shops like Factory suck. There are only too old clothes and most of them of very bad quality and high price.
  • C&A is a great shop where you can find almost anything great there jeans, shoes, socks, underwear, ... for really good quality/price.
  • H&M there are also really great shirts.
  • Celio is also trendy and elegant and very good quality/price mainly for jeans and other apparel like jackets.
  • Zara man is also quite good for fashion clothes and cool and elegant t-shirts.
  • Springfield you can also find some cool shirts at good quality/price.
  • El Corte Inglés is also a good department store for clothing although more expensive than the rest. Anyway there is also quite great quality/price if you look closely.

2007-12-24

On cryptographic hash functions

Now that MD5 is considered too weak for most uses, it is time to look at other cryptographic hash functions like Whirlpool (it is even an ISO standard). We should be reviewing most software and protocols to stop generating MD5 hashes and use some of the currently recommended alternative hash functions like Whirlpool. Even the NIST has started a process to find a new secure hash function (the same process they did with AES).

Spain political system does not work

Today I have seen that political parties of Spain are totally incoherent when referring to a matter and change the views of a matter whenever they come to power.

The suppression of the private copying levy was voted and the main parties changed their vote from the last time when the current opposition was in power. With liars like these no one can believe in Spain politics.

2007-12-17

When standards go wrong

POSIX gets() function should not be used in any program as is a well known buffer overflow. But since it is in the POSIX standard gets() is very difficult to remove from C libraries like glibc because that means that it would break standard conformance. That means that deprecated and unsafe API can stay on standard libraries for long.

Programming languages I have stopped using

I do not support the use of these programming languages. Any people that is still choosing any of these programming languages for production code should be considered a bad manager or programmer. Of course, if you buy any software developed using these programming languages you will make a very bad decision.
I agree with Edsger W. Dijkstra (Why numbering should start at zero) that any one based array programing language is not serious.

2007-12-12

On Java

I have to say that Java is my preferred language to build user applications (as I love C to develop operating system code or low level code).
The things I love from Java are:

2007-12-09

Nokia N80 vs Sharp GX15

Here is a list of differences I have found between my new Nokia N80 and my old Sharp GX15:
  • Nokia N80 feels slower than the Sharp GX15 mainly because the N80 has Symbian OS and the Sharp GX15 does not have a multitasking OS.
  • Sharp GX15 UI is better designed for usability than the Nokia. For example, to use the Nokia S60 calculator you have to hit more keys and is more difficult to use than the Sharp GX calculator where common operators are in the navigation pad unlike Nokia S60 where you have to navigate to the operator and then select it. Also the calendar has a usability problem because you have to type dates using the numeric keypad unlike the Sharp GX where you navigate the monthly view when selecting a date thus making it much more difficult to select, for example, Monday in two weeks, in the Nokia.
  • Sharp GX15 is an older model so it has less functionality and memory but it was a really good deal when I bought it. Nokia N80 also delivers really good value for the money.
Overall both phones are really good for the money but Nokia should look more at usability. It is great that Nokia is working to bring Linux to its products with Maemo but it still has a long way to go unlike Google Android.

2007-12-08

XML (and DOM) vs JSON

The main problem with XML is that it is being abused, by unexperienced programmers, for applications where it is not suited (XML is designed for document text markup) like general data structures serialization (like SOAP where formats like JSON are much more suited) and persistence (where a RDBMS like a SQL database is much more suited).

XML is OK as markup for text documents, but it is not suited as a data serialization format.

In my honest opinion, XML should always be created and accessed through DOM. I have seen lots of software creating XML documents not using DOM and thus making huge mistakes like malformedness, incorrect escaping and even making the data serialized to XML not being the same as the data deserialized from that XML. Take a look at this tutorial to generate XML with DOM otherwise you may perform these XHTML common errors.

The biggest mistake made with XML was making it a text file format by default instead of a binary format. If it was made a binary format everyone would always use DOM to access and modify it both from client and server applications (exiting templates using a XML editor) and many of the mistakes developers make today would not me made.

I have found that for data structures serialization JSON (or its sibling YAML, as used in Google App Engine) is much more suitable than XML, because accessing a list hash and scalar data hierarchy is easier than accessing data from XML DOM. I totally agree with Kris Zyp - XML vs JSON.

Anyway, for maximum efficiency and speed you need to use ASN.1 DER or a less standard but maybe with even more future like Google's Protocol Buffers (see what Google has to say about the inefficiency of XML).

What is the worst abuse of XML that you have seen?

2007-12-02

On date/time (ISO 8601)

Date/time should always be saved in UTC in the database and used in UTC internally in the system and only displayed to the user in its favorite timezone and time-format. (Also, the PC Real Time Clock should run in UT)
It freaks me out when I see an Internet site that still shows date/time of the content in the machine that hosts that content in its local time instead of UTC.
I am a big supporter of ISO 8601 and I use it everywhere.
You should be using ISO 8601 and UTC in case of any doubt.

2007-11-24

Why shell scripting sucks

Writing any program in shell script is like shooting in your own foot in my humble opinion. I am talking about Bourne shell and its descendants. Here are my reasons:
  • Having the default setting of globing '*' returning '*' instead of nothing when there is nothing to match is just plain wrong. Suppose I write a shell script that updates the modify time in all the files in a directory so I write 'touch *', if there are files it works as expected, but if there are no files it creates '*' file!
  • To test that a variable is equal to something you have to do: if [ x$1 = x-h ] that can not be a good programming language.
  • Lack of associative arrays, so it is not useful for anything but really basic scripts. (Bash 4.0 finally has support for associative arrays)
  • It is not compiled, but executed line by line (you may not know it but python is compiled to bytecode at runtime and the bytecode interpreted unlike Java where the bytecode is also compiled to machine specific code)
So, in my opinion you better stop doing any shell scripts and write java or python instead of a sucky shell script.
If anyway, you code a shell script please see Bash Pitfalls to know about all the common shell script mistakes you can make and always write robust shell scripts.

Java Packages

This is a list of some of the opensource Java packages that I am currently using in my programs:

2007-11-17

On Event Loops

Whenever you may have to do any Graphical User Interface development you should have had to learn about event-driven programming and the event loop the widget toolkit you are using has. Like:
One thing that everyone is told (but it is difficult to follow) is to never do blocking IO in the event dispatching thread because that will block the GUI thus making the application irresponsible for an amount of time that depends on the length of that IO.

Because not doing blocking IO in the event loop thread is difficult currently lots of applications in every widget toolkit have this problem. See this post by Havoc Pennington of GNOME fame "SYNCHRONOUS IO NEVER OK"

One way to fix this problem would be to have a way of preventing any blocking call from executing inside the event loop by either logging a warning or just aborting the application when debugging it.

Many people do not care too much about executing blocking code in the event loop because they think the call will run fast and the user will not notice the GUI has blocked. But that reasoning begins to break when the user has an scenario where files are on slow NFS, network or just slow permanent storage. Then the application has to be fixed for that scenario (like pidgin: stop doing blocking file IO and Non-blocking Logging Features)

One other problem is that even widget toolkits have some functions (or methods) that block for IO and are not even marked for so. There is also lack of good non blocking interfaces in operating systems (many still do not scale well enough with the number of events or are too messy to program)

Even functions as open() can block for IO since it has to either check for file existence and permissions for open and create the file entry if the file is open for writing. So, currently if you do not want to block your UI for IO you have to put all file management (open, read, write, close, ...) in a separate thread.

There is hope for better event based development with in kernel features like Kernel Asynchronous I/O (AIO) Support for Linux but that is only the first step since any kernel call inside the event dispatching thread should not block under any circumstances.

I personally think event-driver programming is the way to develop any program so I am committed to fix any issue that makes this problem fade.

2007-11-12

Open Source Mobile Phone Platforms

I am looking for a good Open Source Mobile Phone Platform and these ones seem like the one with most of the momentum:
The future of open source in mobile phone platforms is good as the main current platforms (Google Android, iPhone and Symbian) use really important open source components like WebKit and SQLite.

Let's hope for a future OSS platform for Mobile Phones like there currently is with distributions like Ubuntu

atomic file writing

It still shocks me when I see code that is not writing files atomically.
Most people still think that it is OK when changing something in a text file to do something like:
file = open("filename.txt", O_RDONLY);
read(file,...
close(file)
now change whatever in memory and write the file back:
file = open("filename.txt", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0666)
write(file,...
close(file)

This is the correct way to save the file back, also known as atomic save:
file = open("filename.txt.tmp", O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0666)
if(write(file,...
if(fsync(file) /* this is needed as Linux can reorder operations on files */
if(close(file)
if(rename("file.txt.tmp", "file.txt") /* commit */

Remember you have to check every write() and close() and the rename() for errors and rollback with unlink("file.txt.tmp") in case of any error.

This is not something some newbies do, as this problem is in software like Mozilla Firefox with critical bugs like:
The main problem with not doing atomic file writes is that any problem while writing the file can leave the old one corrupted and that means data loss (one of the most common problems is full non-volatile memory)

Good implementations of atomic file writing are in Pidgin
purple_util_write_data_to_file_absolute() (that I helped to debug) and glib g_file_set_contents(). But there are still lots of programs and libraries out there that are still not using atomic file writing.

There is still no agreement on the correct way to save a file atomically as noted by Benoît Dejean. Even the ext3 & ext4 developer (Ted Ts'o) does not do proper research on this.

2007-11-09

Things I like to do

Software I use

Why I use Open Source

  • Because I can modify the source code as I want.
  • Because I do not have to accept things like DRM. (Why DRM is bad, anyway DRM is dead)
  • Because I do not have to wait for updates from the company that produced the software. In Open Source software anyone can update the software.
  • Because I do not want a monopolistic company setting my software price with market segmentation (market segmentation is used in most Microsoft products).
  • Because I do not like proprietary software reinventing the wheel every day. Proprietary software lacks collaboration so it duplicates lots of unnecessary work.
  • Because I like standards and good implementations of them. See for example OpenOffice.org OpenDocument in contrast with suspiciously fasttracked OOXML that just seems like the ISO has been bought by Microsoft and is not independent anymore.
  • Because I can do things that can not be done with proprietary software. (Like DRM)
  • Because free software ends up being better than the proprietary counterpart.

2007-11-07

About me