The writings of Peter Stuifzand

Archive for October 2009

A person who says a thing has only advantages and no disadvantages, is either a fool, or a liar.

A bytecode interpreter is basically a loop and a lookup table. The interpreter starts at the beginning of an array of bytes. Each byte in this array is an index into the lookup table. For each key in this table there is a piece of code that needs to be executed. Code for that may look like this:

typedef unsigned char byte;

// the simplest program
byte program[] = {
    0,   
};

byte* ip = program;                   // instruction pointer

while ((ip=(lookup_table[*ip])(ip))!=0) {
    // does nothing else, but could
}

The expression in the while loop is a bit complex, but we can divide it in parts. First there is ip. This is the instruction pointer. It points to the instruction that needs to be executed.

The lookup_table is an array with the functions that correspond with the bytecode. The typedef for that looks like this:

typedef byte* (*bytecode_function)(byte* ip);

byte* func_end(byte* ip) {
    return 0;
}

bytecode_function lookup_table[] = {
    func_end,
};

The two lines define the lookup_table. The size of the lookup table is defined to be 256, because that's the size of bytes. The bytecode_function returns the next ip. This way a function can change the ip and jump to other places. If the function returns a NULL pointer, it will end the loop.

The instruction pointer ip is dereferenced to give the current byte at that place in the program. This byte is the bytecode that is used to lookup the function that needs to be executed.

The last thing is the ip argument to the function. This argument lets the function look at the bytes around the function. These bytes are the arguments to the function.

This is the first article in a series about new Perl 5.10 features. I'll try to write one article each week, but you'll never know.

This first article is about the new builtin function say. The say function is similar to print in how it works. Whenever you want to use say or other features from Perl 5.10, you need to declare that you want to use these features.

use 5.010;

After you have done that you can use the function like this.

say 'Hello world';

This will print the text 'Hello, world' to STDOUT and add a newline "\n" after it, equal to:

print "Hello, world\n";

This doesn't seem like a big feature, but it will also help with the following.

say for @lines;

This is instead of

print "$_\n" for @lines;

The say function removes some complexity in this example. You don't have to add the newline anymore.

In Makebelieve help, Old Butchers, and Figuring Out Who You Are (For Now) talks about how if you forget who you are, you'll procrastinate; and thoughts about learning and play, mastery and old butchers and playing with the stuff you have lying around your desk. It's a forty minute video, which with Merlin is always worth your while.

Via PubHubSunday - Tim Bray:

On the other hand, Twitter clients which rely on polling seem to make their users happy. I see nothing in the spec about supporting polling, i.e. how a client might ask a hub for its version of a feed, but that seems to me like it might be a real useful function.

I don't think that adding polling to PubSubHubbub (PuSH) would be a good idea. Removing the need to poll from feeds is one of the reasons for its existence.

Also, polling is already possible using HTTP GET requests to the feed. So there is no need to add an extra layer between the server and the client, further increasing the complexity.

The only extra functionality that a Hub would add is caching, but that is not something we need Hubs for. There are already better ways to having caching in feeds (i.e. Feedburner).

PuSH was created to make realtime feeds a possibility. There is no need for extra layers of complexity that don't further that goal.

Seth Godin: Quieting the Lizard Brain from 99% on Vimeo.

Shipping is more important than creativity.

I wrote an article about GTD and Vimoutliner. This post adds a few simple things you can do to simplify your edits to the todo.otl file.

In Vim it is easy to autocomplete a word or line. You can complete a word by typing the first few characters of the word you want to complete. Then type CTRL-N to complete the word. You can try other words by typing CTRL-N more often. This will try to complete your word with a word that can be found in the same file.

Sometimes you need to complete a full line. This can be a person from the PEOPLE section or a context from the CONTEXT section. To complete a full line, type the first few characters of the line you want to complete and then type CTRL-X CTRL-L and then you can try more lines by typing CTRL-N.

I like this, but too bad it doesn't work in the Dutch search engine, yet.

I upgraded my webserver to Debian Lenny last night. It went almost without problems. This was because I followed the release notes. This helped a whole lot.

Still this morning there was a small problem that I didn't notice yesterday. I didn't receive any email. So I took a look in the exim4 mainlog at /var/log/exim4/mainlog. It contained the following message:

lowest numbered MX record points to local host: servername

All messages that should be delivered in a local mailbox were frozen. The solution was actually quite simple. First I needed to change one line in a config file. It contained something that looked like: DEBCONFxxxDEBCONF. This is a line that would normally be replaced by the update-exim4.conf script. But that doesn't work anymore.

Now the files conf.d/main/005_local_hostnames contains a line like this:

MAIN_LOCAL_DOMAINS = localhost:servername:dsearch;/etc/exim4/virtual

All hostnames on this line should be delivered locally.

Jesse Vincent released a new development version of Perl 5:

It gives me great pleasure to announce the release of Perl 5.11.0.

Perl 5.11.0 is a DEVELOPMENT release. We're making it available to you today to make it easy for you to test your software on what will eventually become Perl 5.12.

The nice thing about this release is that there will be releases of Perl every month, with the dates already scheduled. The next release (5.11.1) is coming on October 20.

I hope this will increase the development speed of Perl. I also think that this way it's easier to make new releases.

One month ago Debian released a new version of their operating system. The new version is called Lenny. These release notes contain a list of things you need to do to upgrade without problems.

This afternoon I upgraded a virtual machine image and tonight I will upgrade my server. By doing it this way I found a few problems I will have that I can fix then or before they will happen.

View archived entries