Friday, August 7, 2009

Idea: Centralized minimal effort bug reporting

Suppose you are running Ubuntu, and for some strange reason, the cursor disappears intermittently. You don't know why, and you don't really feel like quitting what you're doing to probe into it.

If you were a Good, community-loving person, you might do this for every bug you encounter:
  • Search for an existing bug report similar to your own
  • Create an account on the project's bug tracking website (if they have one, otherwise, sign up with the project's mailing list)
  • Go to your e-mail and click the confirmation
  • Navigate through the bug reporting interface
  • Find a way to consistently reproduce your bug
  • Describe, in detail, what your bug is and how to reproduce it.
  • Wait for a response
  • Attach more information
  • Recompile the program in question with a patch you receive
  • Describe more details
In short, reporting bugs is a painstaking process. That's why I, for one, rarely ever do it.

Wouldn't it be great if you could simply go to one website and fill out a form like this? :

Project(s): Ubuntu, GNOME, Xorg, Compiz
Description: Cursor disappears intermittently. It's kind of annoying. Someone else borrowing my computer noticed it, and it's kind of an embarrassment. Pls fix kthx.

That's all you really care to say (you don't even need to say that much). Just click submit, and go back to what you were doing. If you really feel like following it, you can bookmark the link to the bug ID (e.g. example.com/1gaf35 ). Less lazy people might search through the bug reports and mark yours as an instance of theirs, giving it more weight. Developers might respond on the website so you (and other victims) can see how progress is coming along.

Comments?

Tuesday, March 31, 2009

What is the worst feature of C?

This was a question on the Google Summer of Code application template for the CCAN (Comprehensive C Archive Network) organization.

C's problem is not a "feature" per se. To understand what is wrong with C, you have to ask why it takes six lines or more to do simple things like retrieve a single line from the console and convert it to an integer:
char buffer[32];
printf("prompt> ");
fgets(buffer, sizeof(buffer), stdin);
if (*buffer==0 || *buffer=='\n')
break;
num = atoi(buffer);
By comparison, in Perl it'd be:
num = int(<>);
C suffers from stagnancy. If one wants to create a directory, he/she or he\she has to worry about conflicting standards. Functions for creating and traversing through directories are not standardized across the major platforms. Unix doesn't even have a function call for copying a file (if you do it the manual way with fread/fwrite, that still doesn't compensate for sparse files). Even the language itself has similar issues. Can I use typeof or not? Is long 32 or 64 bits? Is long long even available? I need not discuss creating a window or displaying an Open dialog.

How do programmers deal with this? Most flock to Java, Python, and other low-performance languages. Others rely on toolkits such as Qt to abstract those details while sacrificing the portability of C. Few put up with it by learning the details, and even when they do, they end up with messy (and likely still incorrect) code.

Nevertheless, C has crucial benefits. It is the lingua franca of compiled programming languages. If you write a library in C, it can easily be adapted for use in C++, D, eC, etc.. Most importantly, C and its compile-to-machine-code brethren are fast. If you want an operating system package manager to be quick, you write it in C, not Python.

The reason it is so hard to program in C is because C has an inadequate, obsolete standard library. I believe CCAN, by providing a standard repository for C libraries (analogous to CPAN for Perl and Boost for C++), will soundly overcome this obstacle.

First!

I probably should have started a blog long ago. I've oft wanted to rant about random stuff, and I tended to dump my ideas into IRC and forums. Now that I have some necessity for a blog, a better understanding of what a blog is, and have noticed that many of my Google searches for help land me on blogs, I too have a blog that I hope will be useful to many.

I will probably talk mostly about programming (mainly C) and Linux, though other topics may come to mind. I will never ever cuss on this blog, nor do I plan to say anything worse than "crap" or "drugs". Feel free to let your mother, grandmother, kids, and teacher/boss who's standing right behind you read this blog (if they're interested).

To round up this post and to round up some hits, here's a simple routine in C for randomly scrambling an array:
void scramble(void *base, size_t nmemb, size_t size) {
char *i = base;
char *o;
size_t sd;
for (;nmemb>1;nmemb--) {
o = i + size*(random()%nmemb);
for (sd=size;sd--;) {
char tmp = *o;
*o++ = *i;
*i++ = tmp;
}
}
}
Note that it has horrendous cache performance for large arrays.