An expert in PLINQ for a day

One of the nice things about writing a book is that you become an expert on a subject (albeit in my case, just for a very short time). At the moment I know exactly how to make different parts of a Parallel Language Integrated Query (PLINQ) expression sequential so that the order of the output set is the one that you want. 

Not many people can say this.  (Oh, and PLINQ is a very neat technology by the way). 

Arduino Retro Computer

Derek put me onto this. It's a retro computer made from two Arduino devices, one of which generates VGA output. Many years ago I discovered that people were using PIC devices to produce video output, this does something similar with an Arduino to generate VGA video. It uses a tiny interpreted basic that is not a million miles away from my HullOS software, although the Basic implementation uses a lot more gotos....

Using the StopWatch class properly

Most people don't really care about the speed that their programs run at. Unless they run too slow of course. 

However, if really do want to know timings, C# provides a rather useful StopWatch class in the System.Diagnostics namespace that you can use to measure the time it takes your program to do something. You use it like this:

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// Do something that takes a while
stopwatch.Stop();
Console.Error.WriteLine("It took: " + stopwatch.ElapsedMilliseconds);

It is especially useful if you're trying to re-write a program so that it uses parallel processing, and you want to find out how long things take to complete. Parallel programming is where your code makes use of all the processors in your computer, not just one of them. It should be faster. 

I'm writing some stuff about parallel features in C# at the moment. For a book that I might have mentioned. So I wrote two versions of the code and then discovered, to my dismay, that the one I'd carefully optimised actually seemed to run slower than the original. I know that for small data sets a parallel solution might not be worth the effort of setting up all the parallel gubbins, and I also know that if there are any shared variables that the parallel code ends up fighting over, this can impact on speed, but whatever I did, the parallel version always took at least as long as the original. Wah. Took me a little while to find the mistake. Here's my code:

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// Do single threaded version
stopwatch.Stop();
Console.Error.WriteLine("It took: " + stopwatch.ElapsedMilliseconds);
stopwatch.Start();
// Do parallel version
stopwatch.Stop();
Console.Error.WriteLine("It took: " + stopwatch.ElapsedMilliseconds);

The parallel version always, always takes longer than the serial version. Have you found the mistake yet?

Turns out that stopping and starting a stopwatch doesn't reset it. So the time for the parallel version is added onto the time for the original. And I'm an idiot. The method: 

stopwatch.Restart();

- resets the stopwatch and starts it, so that my second operation is timed correctly. I'm now getting sensible speedups, which is nice...

I'm writing a new book

Last year I wrote a book about Python. This year I'm doing another about C#. It's an exam text for the 70-483 Programming in C# Microsoft Certified Professional exam. 

The Amazon site says, rather optimistically, that the book will be in the shops at the end of April this year. I'm fairly sure that it will be a little bit later than that.

But it will be well worth waiting for. 

Super Duper Hardware Meetup

We had a really good hardware meetup today at c4di. A whole bunch of new members turned up. along with a bunch of "regulars".

I did a talk about the latest developments on the Hull Pixelbot front. The system that controls the Hull Pixelbot has been renamed "HullOS" for marketing reasons, and is now available on GitHub. There's also a manual for the new scripting language supported by HullOS and an editor program you can use to create HullOS scripts and load them into the robot. 

Finally, I've added the DXF files for laser cutting Hull Pixelbot chassis components, along with STL files for the 3D printed parts that you need as well.

I'll be adding more Hull Pixelbot stuff in blog posts over the next few weeks. 

There were lots of really interesting conversations going on all round the room, which was great. We've still got room for more though, the next meetup is on the 15th of February. You can sign up here

Bank with Monzo

I'm not sure if Monzo is the "bank of the future". But I am sure that it provides a bunch of features that people are going to want in their future banks. Once you've used it for a while you start to think "Why can all banks be like this?".

Banks and their mobile phone apps have been getting steadily better over the years. We can now send money instantly and check our balances. But the balances always tend to lag between "real life" as payments and credits take their time to meander through the banking system. Monzo isn't like that. Within seconds of paying for something with my Monzo card my watch goes buzz and tells me how much I've spent.

The app keeps track of how much I've spent each day, and it knows the retailers I use, their location and the kinds of things they sell. So I can see how much I spend on coffee, petrol and groceries and do (or at least attempt to do) sensible budget type things. 

The customer support is excellent and registering for an account was a snap (quite literally - as you have to record a 5 second video of yourself asking for an account as part of the process).

To add a bit of icing to the already nice cake, it turns out that you can use your Monzo card abroad without paying any of those nasty commissions that other card companies like add on top. It's actually based on Master Card technology, which means that it should work most everywhere.

At the moment you could't really call Monzo a "proper bank account". It's missing a few features that make it a bit hard to use as the only place you put your money. I'm using it by transferring lumps of cash from my main account into Monzo, and then using the Monzo card to spend it. This works very well though, the transactions go through very quickly, so tracking how much cash you left is very easy. 

Monzo have big ambitions to challenge the high street banks, and they are adding features on a regular basis. What they're offering is a big step forward on what is currently offered by everyone else, I just hope they can find a business model that allows them to fund what they are delivering on a long term basis. Speaking personally, I'd be happy to pay a subscription to them just for the improved budgeting tools. I'm sure that all the other banks are looking very carefully at what Monzo are doing, and taking notes.  Banking just got interesting.

You can sign up for a Monzo card here, although there is a bit of a waiting list. Existing account holders are occasionally sent "Golden Tickets" which they can pass on to their chums to get them on the system, so if you fancy having a go, just find someone with a bright pink card, and ask them for an invite. 

Hull Pixelbots at Global Gamejam

The them of the Global Gamejam was "transmission". Over in the university we had a bunch of teams exploring different aspects of this in lots of creative ways. 

I had a bunch of Hull Pixelbots and a newly minted web editor that mostly worked. 

Above you can see a nearly working display of Hull Pixelbots propagating a transmission from one to the other. Each robot is programmed via a web site using a scripting language that runs inside the robot. 

The idea is that each robot "wakes up" the next one by moving close to it. The first attempt fails because the Mr White doesn't wake up Crystal Maisie,, and the second attempt shows my bad planning, in that it leaves Crystal Maisie in the way of the final move from The See Through Kid. Oh well. 

Hopefully players of the completed game will be better at it than I was.  I think it would be interesting for a large team, with each team member controlling a robot and a prize for the fastest transition from one end to the other, using all the robots at their assigned starting positions. I took some pictures during the judging, you can find all of the shots here

Thanks to Simon and David from the university for organising such a great event. 

Hull Raspberry Pi Jam and Hull Pixelbots

Sorry the image above is a bit blurry. My lovely Fuji camera takes fantastic pictures, but only if you're patient enough to let it finish focusing before you take the shot.

Anyhoo, We had great fun at the Raspberry Pi Jam in the Central Library in Hull today. I've written before about how any carefully designed user interface never survives contact with the user. Same happened to day when I turned some kids lose writing little programs to control robots. 

The good news is that making robots do what you tell them was sufficiently intriguing for folks to ride over issues with the interface, and everyone had great fun in the end. I left the event determined to get enough robots together to allow people to do some proper co-operative (or competitive) action.  And set up something rather interesting. 

Then it was on to the Global Gamejam event at the university. The theme of the competition is "Transmission". I've got a plan for that. Involving robots. 

Feeling better - but going backwards

I think I must be feeling a bit better, because I've started making stupid mistakes again. Starting with telling off the database for refusing to find something that I knew was there. After all, I'd put the record there, hadn't I? Turns out that I had. Twice. So my request to find a single item with a particular name was failing because there were two of them.

After a bit of tidying up I've got something mostly presentable. I want to use it tomorrow at the Raspberry Pi Jam in Hull, and also as the basis of a Global GameJam entry. 

Coding while ill

Not well today. Let's just say that there's a particular room in the house that I can't be too far away from just at the moment. And I've got a horrible sore throat. What better time to write code? After all, the day can't get any worse, can it?

For some time I've been meaning to write a web programming interface for the Hull Pixelbots. I want to use MVC Active Server Pages and host the project on Azure. And today I got started on the project. I've not done this kind of thing for a while, and it was a journey of discovery in many ways. There's a very good tutorial on how to do it here

By the end of the day I've got the basics working, and I'm feeling a lot better. I think coding while ill works well for me.

Fibbage is Fun

We spent some time last night playing Fibbage. I first played it earlier in the year at David's. It's so good I actually bought a copy. It's a great party game. You need a PC, preferably with a big screen, and each player needs a device with web access. Then the game invites players to invent answers to silly questions and search for the correct one. 

And  no, I'm not saying it's good just because I won. Although I did. Perhaps those years of being a lecturer have turned me into someone good at inventing plausible lies....