Sunday, 12 June 2005

Quoting in newsgroups

Newsgroups are a great way to communicate. One of the big advantages is, that you don't have to reply immediately, and that everyone can see your reply. It also means that more than one person can jump into the conversation going on, and write a reply, whenever that person thinks it is convenient to do so. This means that a thread in a newsgroups is not linear or chronological, but can have many sub-branches.

If you scan a newsgroup for a new, unread reply, the reply you find may be a reply to a message made a few days ago, and in a completely different thread or subthread than the message you were reading only a few minutes ago. To remind you of the context of the reply, i.e. to give the reader an indication to what the poster was replying, it is usual to quote (cite) a part of the message to which the reply was made. To make it apparent what was quoted, the quotes are usually marked with a special character, often >, at the start of every line. Many newsreaders allow you to automatically quote the entire previous message when you write a reply. That is of course very convenient for the poster, but it can be a problem for the reader.

If everyone simply quoted the entire previous message (with previous I mean the message to which the reply is made), the final message contains quote over quote of all the previous messages, so more or less the entire thread leading to that point. This may be fine for those who start reading in the middle of a thread, but it wastes an enormous amount of bandwidth, and it gets harder and harder to actually find the actual reply, especially since some people reply at the start of the message (i.e. above the quotes) and some reply below the quotes, or inline, i.e. replying separately to each point made.

In Usenet, a large set of mostly freely available newsgroups shared across many servers around the world, people have tried to define standards for quoting, to avoid this terrible mess. A short version of these (very inofficial) rules, with my personal comments, is:

  • Mark your quotes with a > character. There are different ways of marking a quote, but the > has become some kind of de facto standard, and any other way of quoting makes your replies harder to read, for many people.

  • Reply below the quotes, or inline (which is similar). I know this is a controversial point, but IMO this is the only logical way of replying. Like someone said:

    A: Because it fouls the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?

    Top-posting is putting your reply above the quotes. One other disadvantage is that someone who expects replies below the quotes, or inline, will have to scroll to the end of the message to see if there is more.

  • Do not overquote. Delete those parts of the quotes which are not necessary to assist the reader in remembering what the previous message was about. If the relation between quotes and new content of a message is grossly in favour of the quotes, one may talk about overquoting. This is a nuisance, since it requires people to read or scroll over a lot of stuff before they see any reply. It also wastes bandwidth, and space on the harddisks of your readers.

  • Do not underquote. If you don't quote at all, or not enough, the reader does not have a context, and may be forced to re-read the previous message to remember what is going on, or to see to what you are actually replying.

These are my personal views on quoting, and others may have different opinions. But I hope to have given a hint on how newsgroup reading can be made more pleasant. You don't have to follow my rules, but notice that if you don't, you might be doing your readers a disservice, and they might decide that they'd rather not read your messages anymore.

Update: I came across this article from a blind person about top-posting. Top-posting seems to confuse a popular newsreader for the blind. One more reason to abandon it, IMO.

Rudy Velthuis

Links

Saturday, 12 June 2004

Extending arrays

This may seem trivial, but I often see code that does something like:

var
  Ints: array of Integer;
  I: Integer;
begin
  SetLength(Ints, 1);
  for I := 1 to SomeLargeNumber do
  begin
    ...
    SetLength(Ints, Length(Ints) + 1);
    Ints[Length(Ints) - 1] := SomeIntegerValue;
    ...
  end;

Instead of a for loop, sometimes a while loop is used, especially when the number of items to expect is unknown.

This way of constantly adding to the end of the array looks natural, since the array now only contains as many elements as required to hold all values, but this has some serious disadvantages.

When SetLength is used, and the new memory size of the array is larger than the block used for the old array, then new memory must be allocated, and the contents of the array must be copied over. If you do this many times, this could not only fragment memory (this depends a little on what other memory allocations are going on), but it will also get slow, since each time, a larger number of items must be copied around.

To avoid this, you can do a few things:

  • Dimension the array according to the expected number of items. In the loop above, this would be dependent on SomeLargeNumber. But even if you don't know the exact number of items to expect, then be sure to "guesstimate" it, and don't estimate it too low.
  • Since the array dimension is not the same as the number of of valid items it contains, you must keep track of the actual number of items stored.
  • Each time you add an item, you increment the count of actual values. If this reaches the size of the allocated array, you'll have to redimension it. But don't redimension in chunks of one element each. Redimension by a fixed fraction of the already allocated array, for instance add half of the current size, or more.

Of course, if you do this often, this can get tedious to do, so it could be a good idea to wrap this into a class, with methods to add items, get the count, perhaps even insert items, etc. As an example, you can use the source code for TList in the file Classes.pas (if this comes with your edition of Delphi). Or you can have a look at this simple Integer array class on my website.

Rudy Velthuis