Archive for September, 2005

Stimulation junkie

Thursday, September 22nd, 2005

I realised the other week that I am a stimulation junkie. I always have to be doing two things (at least) at once or I get bored and frustrated. The two things have to be things which use different parts of my brain (or one thing which requires me to use my hands and one thing which doesn't). Some examples:

  • I always eat meals while surfing the web or watching TV (or both) or having a conversation.
  • When I'm watching TV I'm always either eating or using my laptop.
  • When I am at work I always listen to the radio at my desk.
  • When I walk to work I listen to music.
  • When I'm on the bus I listen to music or read a book as well as looking out of the window.
  • When I'm driving a route I know well I listen to the radio (but I often turn it down or off when simultaneously navigating unfamiliar territory).
  • When I'm cycling it's dangerous to do anything else but navigating, avoiding traffic and enjoying the scenery are enough to keep me stimulated.
  • When I'm in a social situation I am always much more comfortable if I am eating or if I have a drink in my hand (doesn't have to be alcoholic).
  • I often get frustrated in meetings at work because I don't have a work laptop and my personal laptop is too noisy to take into meetings. My mind ends up wandering from the topic at hand and other participants in the meeting wonder why I am staring blankly into space and seem to be in another world. Usually it's because I'm thinking about some completely unrelated thing in the second part of my brain.
  • I got frustrated recently when trying to watch a movie with subtitles because I couldn't make sense of the movie and work on my laptop at the same time.
  • I get bored going to the cinema unless the movie has a plot which keeps me guessing, or unless the visuals are sufficiently spectacular that I can marvel at them while I'm following the story.
  • Even when I'm going to sleep I like to listen to the radio at the same time.

Do other people experience this phenomenon to the same extent?

Mind control

Wednesday, September 21st, 2005

Derren Brown has some seriously cool Jedi mind control techniques. I saw his show "Mind Control" on TV in the UK back in 2000, but never remembered who he was. So I was delighted to see that he has a more recent show and there are some video clips online. Be sure to watch the first few if you have the bandwidth.

Beard

Tuesday, September 20th, 2005

When I was getting my hair cut recently the guy sitting opposite me in the barbers' had this huge long black and silver beard. As I watched, the barber cut the whole thing off and left the man completely clean shaven. It was really quite surreal - when he left he looked nothing like he had when he started.

Three slices

Monday, September 19th, 2005

My parents live in a fairly rural place. It's sufficiently far from shops that in general they avoid doing food shopping more than once a week. This necessitates certain food storage measures such as putting bread in the freezer so it keeps longer. Sometimes lunchtime would come around and all the bread would be frozen. No problem, just cut off some frozen slices (harder than slicing unfrozen bread but you do get very neat slices) and pop them in the toaster for a bit. Result - fresh, perfectly formed, defrosted and delightfully warm slices of sandwich bread. But there is a complication! A standard toaster only takes two slices at once and (as you will know if you know me well) I have 3 slices of bread for my lunchtime sandwiches. Now, if I use a naive toaster slot allocation algorithm and completely defrost 2 slices first, followed by the third on its own, I not only have wasted one slot-toasting worth of electricity, but I now have one slice that is significantly warmer than the other two (or vice-versa). The solution is to use three half-toastings, each with a different combination of slices. I got extremely good at judging just how long to leave the slices in the toaster for.

This post was inspired by an Eddie Izzard bit about toasters that Gennie and I watched recently.

Personal Rapid Transit

Thursday, September 15th, 2005

It would be so cool if they built this. Be sure to watch the video. I can imagine similar systems scaled up to entire cities and making urban cars obsolete.

In related news, my bicycle has a flat tyre which is tremendously annoying (especially as it happened 3 miles from home on a rainy day). Given how much stuff I have to do over the next couple of weeks, I have no idea when I'll get time to have it fixed.

Bootstrapping a compiler from nothing

Wednesday, September 14th, 2005

Two posts today 'cos I missed yesterday due to being disorganized.

Recently I've been working on bootstrapping a compiler from nothing. Just for fun. I know it's been done before but I wanted to learn about parsing and optimizing and how compilers are constructed.

The first stage of my compiler is a pretty clever hack, even if I do say so myself. I didn't want to use any external tools to get my compiler started, but that left me with a problem - how do I generate the first executable file? Well, one way to generate an arbitrary file from Windows is to just use an "echo" statement in the Windows command prompt and redirect the output to a file. But that only works reliably for ASCII characters (and not even all of those). This poses a problem, because the opcodes for even simple "MOV" instructions are all non-ASCII characters. But it turns out that the "constrained machine code" for x86 consisting of only ASCII bytes is actually Turing-complete and can be used to do useful things (non-ASCII opcodes such as the one for "INT" can be constructed using self-modifying code). So I put together an ASCII program that takes two characters from the command line, combines them into a byte and outputs the resulting byte (which can then be redirected to a file). Calls to this program can be strung together to make (almost) arbitrary binary files, which can be used to compile more complex languages.

In this way (13 iterations later) I have built up a simple but effective 2-pass 16-bit DOS assembler which outputs .com files. I have also written a recursive descent parser for simple infix expressions on unsigned 16-bit integers, and am working on writing a code generator which can output binary code for these expressions.

Eventually I hope to evolve this into a fast and powerful language to rival C++. It will be a language which combines very low-level and very high-level concepts, and will therefore be an ideal language for writing compilers (such as itself) in. I could then use it for writing all sorts of other fun things - maybe I'll tackle an OS when I've finished the language. But for now I'm just having fun learning about things.

Overreactions to terrorism

Wednesday, September 14th, 2005

I do not understand why a terrorist exploding a bomb which kills (say) 50 people is considered so much worse of a crime than (say) a serial killer murdering 50 random people for non-terrorist reasons. The objection people have to terrorism is, after all, the killing rather than the motive. If Al Qaeda pursued non-violent means to their ends instead of violent ones, they would not be nearly the enemy of the US that they are (in fact, their requests might even be taken seriously if they could persuade the US government to listen to them without violence).

I guess the point of taking terrorist crimes more seriously is prevention. Serial killers generally work alone, so once you have arrested one the stops. But if you arrest one terrorist (or he dies in the explosion he causes) there is always another to take his place. So in order to put an end to terrorism, the US government is attempting to eliminate all the people who could become terrorists, even if they have done nothing wrong. The trouble with that plan is that you have to turn this wonderful free country into a police state to do so. It is not enough just to arrest people who attempt to create or buy explosives or who contribute financially to terrorist causes, you also have to arrest people for the books they read, the photos they take, the websites they visit, the people they talk to and the things they say. You have to spy on everyone to find out if they have any sympathies for terrorist organizations. You have to completely gut the concepts of free speech and privacy which are some of the most important principles upon which the country is based. Already such rights are being eroded, and terrorism is showing no signs of disappearing. And instead of abandoning these dangerous and ineffective policies, the US government is trying to expand these anti-terrorist activities and erode more rights in the process. I think most people would (if they thought enough about it) rather take the freedoms we have along with a small chance of being killed in a terrorist attack than live in the world of 1984 but be safe from terrorists. As with all law enforcement it is a question of balance. I for one am more afraid of being arrested on suspicion of terrorism charges than I am of getting killed by a terrorist, which means that the balance has swung too far to the side of fascism. In fact I was in two minds whether to post this lest it be interpreted as supporting terrorism.

Here is what I think the government should do instead: treat terrorists as the criminals they are. There is no need to implement any special policies like deporting people to countries where they will be tortured, or imprisoning people indefinitely without trial, or removing judicial oversight from surveillance operations, or requiring libraries and bookshops to hand over their records. None of these things were needed in the past when it was just normal criminals that were being dealt with, so they should not be needed now. All that is needed is a sensible set of laws and the ability to enforce these laws. If we need laws against things like "possession of explosives with intent to murder" or "financially aiding a criminal organization" then so be it but no laws should be made limiting free speech or evading the checks and balances that have evolved to keep the system fair and just.

At the same time, the US government should be more open to considering the points of view of any political group who feels they have a legitmate gripe, even terrorist ones such as Al Qaeda (there is no point excluding the terrorist ones because any such organization will just split into two groups - a "political" one which does not officially endorse terrorism, but which secretly funds it, and a "military" one which blows things up). The idea is that if a group is given the same amount of attention whether or not they commit terrorism, there will be no incentive to commit terrorism. And there is still a definite incentive not to commit terrorism - namely that if you do so, your followers are liable to get arrested. Also, no-one should ever be left feeling that terrorism is the only option they have to get their point across.

And once you have your enemy sitting at the same table as you and prepared to talk, the war is half over.

Iraq army

Monday, September 12th, 2005

There is a lot of talk in the media at the moment about when and how to withdraw US troops from Iraq. Here's a suggestion - the US army should gradually withdraw as the Iraqi army grows (in size and capability), and when the size of the Iraqi army reaches the size of the number of (US + Iraqi) soldiers currently in Iraq, there should be no US soldiers left. The US soldiers should train the Iraqi soldiers to take over the jobs that they are currently performing. They should give the weapons and equipment necessary to do these jobs.

Of course, the danger then is that this new super-duper Iraqi army might then be so big and powerful that (if they wanted to) Iraq could then turn around and invade the US.

Time travel

Sunday, September 11th, 2005

Suppose that some time in the future, humankind figures out a way to make possible time travel into the past. Suppose, furthermore, that it turns out that the universe is holonomic - that is, there is only one past and one future and we can't change it (so we can't create an "alternative 1985" like in Back To The Future II). Effectively, the entire history of the universe would be predestined. So the going back in time would also be predestined. Anything that the time-travellers do while on their trip to the past would have already have happened and would always have happened. So we know that the time travellers cannot kill their past selves (or they would not be in there in the future to make the trip). In fact, anything that they do in the past must guarantee that the time travellers are alive and sufficiently healthy in the future to be able to make the trip back (which would not necessarily be the case if the time travellers were not there). So effectively, the time travellers would be their own guardian angels, "protecting" their past selves (deliberately or not) simply by the virtue of existing in the past.

Now, suppose that you are a future human in possession of a time machine. You don't worry about "responsible time travel" since you can't break anything or rewrite history. It's only natural for you to wonder just how far back in time you can go. With sufficient technological advancement, you might be able to go right back to the moment at the very beginning of the universe. And, just maybe by going back to that point in time you actually initiate the creation of the universe - you become God.

Sometimes I wonder if the universe is like that. But I suspect it is not - I find it very difficult to believe that free will is just an illusion.

The Lego Imperial Death Star II

Saturday, September 10th, 2005

Is it so wrong that I want one of these? At 3449 pieces, it is the largest lego set ever made. Yeah, despite the mortgage and forthcoming wedding I am still a child at heart. I really hope that when I have children of my own they like Lego and will let me play with it with them.

Talking of Lego, do you why Americans call Lego bricks "Legos"? It's because they needed somewhere to put the "s" from "maths". Thank you very much - I'll be here all night. Try the chicken.