Saturday, April 30, 2005

More election fun

Ever thought that there was no point in voting for your favourite political party because there was no chance of them getting in? Well, the the tactical voter website provides an interesting way to make your vote count by swapping it with someone else. The webiste describes how it works as follows:


In the past, a Liberal Democrat in a seat where his party were running third and had no prospect of winning had two choices: vote LibDem, knowing his vote would be thrown away; or vote tactically for the Labour Party to try and prevent a Conservative from winning.

Vote swapping offers a new option: use the Internet to find a Labour supporter stranded somewhere Labour can't win, and make a pact to "swap" votes, support each other's parties and have the best chance of beating the Conservatives in both seats.

That way, you get a tactical vote for your party in exchange: two votes that can make a difference instead of two votes that are thrown away.



Vote swapping has a long history, for more details see this article.

Wednesday, April 27, 2005

C++ Template Metaprogramming

I've just finished reading C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond, and I'll admit it's blown my mind. I had no idea that the template resolution system in C++ could be so powerful. C++ is a huge language, but this book makes me realise that it's a lot bigger than I expected.

In my first year in University we were taught Miranda, a functional programming language. At the time we wondered why we were being taught a relatively unknown language with few real practical applications. The functional aspects of Miranda made it very different to the the procedural languages that most of us had encountered previously (which was of course one of the reasons why they taught it to us). However, I'm very glad that we were taught Miranda all those years ago, as it's made understanding the concepts of other functional langauges such as XSLT and now the Boost MPL much easier.

The book is well presented and readable, and it provides a great overview of what template metaprogramming is all about and how the Boost MPL can help you. The middle sections of the book go into the details of how and why the MPL works; if you find this heavy going then I suggest you read the first few chapters and the last few, as these concentrate on the uses of template metaprogramming in C++.

I particularly liked the concept of Domain Specific Embedded Languages (DSEL) which are outlined in the last few chapters. In essence these are micro-programming languages for specific problem domains that are embedded in C++. As an example, the last chapter shows how to implementate a language to generate finite state machines using the MPL. The implementation ends up being beautifully efficient as most of the work is done at compile time.

This book is well worth reading, but you'll need a good understanding of templates to do so.

Tuesday, April 19, 2005

Election fun

Lots of fun politcal websites have appeared following the announcement of the general election next month. These came from a friend.

The Political Compass website has a test that measures where you lie on a 2-dimensional political scale. The 2-d scale combines the usual right / left distinction with an authoritarian / libertarian scale. I came out as a libertarian lefty with roughly the same political stance as Nelson Mandela.

The Who Should You Vote For website asks you questions about various issues (healthcare, European union etc.) and then compares your answer with the manifestos of the five main UK political parties (Labour, Conservatives, Liberal Democrats, UK Independence Party and the Green party). I should vote for the Lib Dems, apparently.