Something to read

How I Failed, Failed, and Finally Succeeded at Learning How to Code is an article I really enjoyed reading because it kinda reminds me about myself, even though I never worked with Project Euler yet :)

When Colin Hughes was about eleven years old his parents brought home a rather strange toy. It wasn’t colorful or cartoonish; it didn’t seem to have any lasers or wheels or flashing lights; the box it came in was decorated, not with the bust of a supervillain or gleaming protagonist, but bulleted text and a picture of a QWERTY keyboard. It called itself the “ORIC-1 Micro Computer.” The package included two cassette tapes, a few cords and a 130-page programming manual.

Another nice article is explaining some of basic the Clean Code ideas for those who are to lazy to read the whole book. I read both and really enjoyed them all ;)

This is a particularly simple example of a style of code that I often see (this example is a piece of prman, sanitized to hide the function of the code it comes from):

match(struct table *tab, char *arg)
    int i, found = 0;

    if (tab != NULL) {
	for(i=0; i<tab->nitems; ++i)
	    if (tab->item[i].name == arg)
	found = (i < tab->nitems);
    return found;

This function determines whether tab points to a table containing an item whose name is arg.
I would write the above like this:

<code>int match(struct table *tab, char *arg){
	int i;

	if(tab==NULL) return 0;
			return 1;
	return 0;