I’ve been reading a lot of books lately.
Mostly it’s been non-fiction but the last few books have included a couple of non-fictions which I’ve enjoyed a lot. It’s strange, but I always look forward to reading a good non-fiction book but see fiction as a potential chore, even though I usually end up enjoying them more.
Anyway, I can recommend “The Coma” by Alex Garland, even though it’s so short that it can be read in a little more than an hour. Should have been longer.
I can recommend even more “The Raw Shark Texts” by Steven Hall. It’s kinda like the matrix with a shark as the bad guy. Actually, with the concept of a shark as the bad guy. Just read it… then I’ll make sense.
I need more book recommendations though. I’ve just bought “Calculus for Dummies” which is a sure indication that I desperately need more non-fiction on my to-read pile.
June 20th, 2007
The reason why Mum went fucked-up mental whenever we covered furniture with stickers.
June 17th, 2007
This neck is becoming a problem. Each morning, is seizes up a little more and this morning it took a whole hour to summon up the courage to roll out of bed and hobble, Frankenstein’s monster-like to the bathroom for a piss.
Fortunately NHS 24 came to the rescue and I got booked into the hospital for an emergency once-over. The visit consisted of “Well there’s not much we can do but wait for it to get better. Buy stronger pain-killers. That’ll help”.
It might not have been the euthanasia media event I was hoping for to scream my pain to the world, but it was certainly the best advice so far. Today has been a day driven by a coctail of co-codamol and iboprofen and I gotta tell you, those little pills are magic. I’m almost normal feeling.
And that’s good because it meant we got to go out to the local park where there was a fair going on with the usual park fair stalls and kiddie attractions.
Best part was the dog show which had a “Best in pedigree” contest just starting. We decided that it’d be a laugh to enter, but some pesky little daschund beat our puppy to the covetted rosette.
Never mind, because forty-five minutes later there was another category - “Dog that the judges would most like to take home”. That puppy knew exactly what to do - rolling over wanting his tummy rubbed and acting as playful as you like. And wouldn’t you believe it, we are now the proud owners of a first-place red rosette, a toy rabbit and a bag of premiere dog food. We are also, of course, the proud owners of a prize-winning puppy.
The cynical side of me has taken to calling it the “Dog most likely to be stolen award”, so there is talk of getting him chipped pretty soon. Round of applause though please, for Bailey.
June 16th, 2007
Tonight is gym night. Monday night was gym night too, making this the second gym night in my new twice-weekly fitness regime.
Monday night’s work-out was ridiculed by my wife for my hour-long effort-total of 250 calories. At least it wasn’t ridiculed as much as the previous Monday which induced no less than four days of unsympathetic laughter. I still say that 200 calories is a good effort for a first visit, and that 1000 calories must simply be a result of her using the machines wrong, somehow.
I’m sure it will improve over time, and anyway if there are rivers of sweat pouring down your pain-wrecked body then I can’t see how increasing your vigour five-fold could possibly be good for you.
Tonight will have to wait though since I’ve been let off of one painful event by another - namely a cramped muscle in my neck. Every now and then, I’ll go through a phase of sleeping in a stupid position, and screw up my neck. I’ll wake up face down in a pile of pillows thinking “Oh no, not again” and there will be several nights of this until the phase passes again for a while. Meanwhile my days are spent looking like a social freak who can’t look anyone in the face when they talk to me because it’s too painful to turn my head.
This time I could barely get out of bed for work. Not normally an unusual situation, but this included being unable to switch off the alarm clock. That kinda sucked. Along with the cold bath because the timer was set wrong. That didn’t help. Must get my shower fixed.
June 14th, 2007
So today was the first day of puppy training class.
Oh yeah - and we got a dog the other day.
Yes, I know, I’ve heard all the “What did you go and do that for?!” stuff and also the “No, don’t get a dog!” stuff, but we got one anyway. Without wanting to sound like an unsuitable owner, I’m still pretty much against the idea but these things have a way of happening without heed to my opinions.
In truth he’s a lovely wee guy who we’ve named Bailey (Not sure how to spell it actually, but I guess that typing it just now makes that the official spelling.) My key objections are not based around any aspect of the having of a dog, but more around the whole not having all your previous freedom.
Still - the deed is done and he’s with us now. Whippet - kinda looks like a tiger, colour-wise. Readers from previous and ancient posts to this blog in previous incarnations will know that I’ve had a whippet before who was a bit of a maniac and this may be a factor in my reluctance this time around.
To make things seem better though, my sister-in-law and her husband coincidentally decided to get a dog at the same time - also a puppy. This one is a cross between a great dane and a labrador, which means that it’s a fecking huge puppy. I haven’t told her, but it kinda reminds me of the terror dogs from Ghostbusters but with the nature of George from “Of mice and men” and without the scary horns and glowing red eyes.
By contrast, our getting a dog seems quite sensible.
At least I hope. Like I said, I used to have a whippet, but now I’m not so sure that I did. This puppy looks just like my previous dog, in size and everything. It wasn’t until we’d bought the dog that we thought “The puppy’s parents were awfully… big, weren’t they?”
I can think of two possibilities. 1) We didn’t have a whippet at all, but perhaps an italian greyhound, or a freakish dwarf whippet. 2) Those weren’t the real parents and were small greyhounds brough in to make the pedigree seem genuine.
Anyway, he looks vaguely puppyish, and even if he grows up to be much larger than the small, manageable dog we imagined, I don’t think I’ll mind any more.
And he did very well in his first puppy training class, so well done Bailey. Must post a photo.
June 13th, 2007
As a vague effort to keep this site on the fringe of ‘maintained’, here is a rambling from the world of Java ME development.
How Switch Statements Work in Java
Switch statements are more efficient than if-else chains in all good languages and java is no exception. It’s worth understanding how they work though when considering a piece of code that must run as small and as fast as possible.
Consider the following example:
switch(a)
{
case 1:
System.out.println("1");
break;
case 2:
System.out.println("2");
break;
case 3:
System.out.println("3");
break;
case 4:
System.out.println("4");
break;
case 5:
System.out.println("5");
break;
}
return;
We can see what bytecode this produces by using the javap command
Code:
0: iload_1
1: tableswitch{ //1 to 5
1: 36;
2: 47;
3: 58;
4: 69;
5: 80;
default: 88 }
36: getstatic #16;
39: ldc #22;
41: invokevirtual #24;
44: goto 88
47: getstatic #16;
50: ldc #30;
52: invokevirtual #24;
55: goto 88
58: getstatic #16;
61: ldc #32;
63: invokevirtual #24;
66: goto 88
69: getstatic #16;
72: ldc #34;
74: invokevirtual #24;
77: goto 88
80: getstatic #16;
83: ldc #36;
85: invokevirtual #24;
88: return
The switch statement produces a ‘tableswitch’ command which is literally a table of values, indexed by key integers (The case values). By reading the table at the position indicated by the case value, you can find out the position of the next instruction.
Let’s see what happens when we change the final ‘case 5′ line to a ‘case 6′:
tableswitch{ //1 to 6
1: 40;
2: 51;
3: 62;
4: 73;
5: 92;
6: 84;
default: 92 }
The table now contains 6 entries instead of 5, despite the fact that we no longer have a case statement for 5. Looking at the entry for ‘5′ we see that a value of 5 takes us directly out of the switch block to our return statement.
We would also notice an increase in the size of our class file. The dummy entry costs us 4 bytes onto the size of our class file.
Let’s try changing the 6 now to a 12:
tableswitch{ //1 to 12
1: 64;
2: 75;
3: 86;
4: 97;
5: 116;
6: 116;
7: 116;
8: 116;
9: 116;
10: 116;
11: 116;
12: 108;
default: 116 }
As you may have expected, the table just got a whole lot larger, and the class file jumped to 28 bytes larger than our first example with no apparent change in functionality. You can see entries for the numbers 5 to 11 plugging the ‘gap’ in the range of values for the switch statement.
Let’s push it a little farther and try changing the 12 to a 13:
lookupswitch{ //5
1: 52;
2: 63;
3: 74;
4: 85;
13: 96;
default: 104 }
Now something different has happened. The class file is still larger than it might have been (by 16 bytes, to be exact) but the table has shrunk back down to 5 entries.
The instruction though, is now different. Instead of a table, the JVM will recieve a ‘lookupswitch’ instruction. This instruction does not use an efficient table lookup to find the next instruction. Instead, it provides a sorted list of case values and instruction pointers.
At run-time, the JVM/KVM implementation is free to use whatever means to use this information to determine the next instruction. The may mean a binary search, or it may mean a linear search through the lookup list.
The compiler will substitute a table switch for a lookup switch when it judges that the table method is becoming too costly in terms of space.
Switch statement strategy
For the most part, this doesn’t really matter very much. It may matter though, if you are implementing code that simply must be fast, and must be small. In this case you may wish to take notice of the switch values you are using and if possible, alter them.
To make the most efficient use of switch values you should use contiguous values, preferably with as few gaps (Or no gaps) in the range as possible.
April 27th, 2007
But still… how cool was this?? (You might need to fast forward a bit to a few minutes before the end because I couldn’t be arsed working out how to link to a specific part of the clip).
Richard Hammond’s face - that’s what my face was like when I was watching whilst drying the dishes.
February 19th, 2007
So my new laptop arrived yesterday. I’ve finally accepted that I don’t play computer games or use any of the heavyweight nonsense that my monster PC offers. Out it goes and in comes a fresh space in the bedroom, in comes some serenity (No hair-dryer-like fan noise from the glowing black/blue monolith in the corner) and in comes a sleek, shiny, wireless laptop that can be hidden away in a drawer when not in use and does what I’ve always done on the PC - checks email, browses the internet and simply holds my photos and a few small files.
No sooner had it arrived, than I had to take it back to the shop. Pesky thing was reporting 766MB of RAM, when I’d plainly paid for a full 1GB. It was swapped over happily and the delivery charge was refunded (Thank you 24h Tesco) and the new, perceptively shinier one got booted up… also with 766MB of RAM. A quick look at the BIOS showed that 256MB was given over to the graphics card. Ahem. Anyway.. free delivery 
Being a new laptop, it came primed with Vista Home Premium, and I have to say there are some things I do like, and some things I don’t. First thing I don’t like is the 40 minutes it took to set itself up for the first boot, particularly as I had to do this twice on two different laptops. Surely some setting up in the factory wouldn’t be too hard? First impressions and all that…
To be fair, most of it was Acer’s fault who deemed it necessary to interrupt the Vista sheen with
Windows 2000-style command prompts popping up installing all sorts of uninvited ‘handy tools’. There was a further 20 minutes of de-configuration to remove all the parasitic utilities and toolbars that marred those precious first impressions. If I had a hundred pounds for every time I’ve removed a Norton Internet Security ‘trial’ (geddit?) from a struggling, choked PC then it still wouldn’t be worth it.
After all that, it was time for some proper first impressions. I have to be honest, it was a weird mix of ‘oooh!’ and ‘meh’. The imagined dreadful intrusion of the sidebar turns out to be a bit of a welcome friend on a laptop with a wide screen that would otherwise be far too wide for a browser window. It actually consumes some excess screen real-estate. Flip3D is as gimmicky as you’d think it is. It’s nice the first time you see it, but Alt-TAB is still quicker.
The composite UI effects are quite nice though, and are thankfully on the right side of ’snappy’ without being intrusive. Windows emerge and retract rather than pop up and down and the effect is a surprisingly fluid and interactive experience. The glass aero effect is nice, and it gives windows a surprising tangibility.
With the rest of the world moving over to Firefox and me left far behind (With my beloved Maxthon) I had thought that the new laptop event might be the time to move over to Firefox (While I’m getting used to a different interface anyway). Problem is, the pre-installed IE7 is, well… nice. It’s clean (After removing the parasitic toolbars) and seems to have just enough features on display. I might stick with it for a while to give it a fair trial. Sorry, Firefox.
If there’s one thing that does my head in with Vista though, it’s the ‘High-DPI awareness’ thing. Basically, Vista-aware apps look good, but older ones are scaled up too look bigger on a finer-pixel screen. This scaling is done as a bitmap surface in the graphics card, and that means that older apps actually look slightly blurry. It makes my eyes go funny. And yes, text is horrible to read, particularly as the ClearType anti-aliasing is scaled up too, making the letters have weird eye-ball wrecking colour fringes around them.
I’m trusting that there’s an off-switch for that feature somewhere. Haven’t looked yet.
Hopefully my nice, cheap bargain eBay 4GB pen drive should arrive today and I can start the happy process of shifting over the contents of an old 180GB hard drive and ruining that pristine, snappy new Vista.
February 13th, 2007
There was a trailer for something on TV a couple of days ago. I think it might have been an advert for one of these free film DVDs you get with weekend papers. Anyway, there was a clip of a sunset, and as the sun went down over the horizon, it flashed bright green, just before it disappeared.
How strange. I thought that maybe it was some weird video artifact, or maybe it was an arty film in which the green sun was some kind of meaningful symbol.
This morning though, I was reading my book on the bus as I usually do and it started talking about the sun’s ‘green flash’. Sure enough, it’s a real effect.
I was vaguely disquieted by this coincidence, as I am by all proper coincidences. Was it really possible that the green flash I’d noticed on the screen, and then soon after read about was a simple coincidence, or was there more to it? I have a bad habit of flicking through books to see what develops later on. Maybe I’d picked up on the ‘green flash’ without realising and had become ‘primed’ to notice the green flash on the TV trailer.
Either way, it’s vaguely disquieting. Recently I started humming “Honey to the Bee” by Billie Piper. I was doing the dishes at the time, and hadn’t heard it anywhere for it to pop into my head. I couldn’t work out why I was suddenly humming this tune.
Later on I went back into the kitchen and noticed a jar of honey on the window sill. It was a small terracotta pot with the words ‘Bee Honey’ painted on it in white. It seems that my unconscious mind was paying more attention than I was.
February 9th, 2007
>Despite the fact that it has a huge crack across the windscreen and has just failed its MOT.
Wednesday is the day I get the car to drive to work, and it’s just as well. I drove past the bus I usually get this morning parked at the side of the road looking quite broken down, and being attended to by another bus.
Not a big surprise really; yesterday there was a new driver who didn’t quite know the route and got us stuck in a traffic jam for twenty minutes on a road we weren’t supposed to be on. No sooner had we got back onto the right road, than the gear-stick fell off. Seriously.
The last time that happened was when the previous driver was only just new. It takes time for drivers to become accustomed to the various idiosyncrasies of each member of the number seven’s small fleet.
I can’t wait till he gets the one with the dodgy fuel meter and we run out of diesel mid-route. That’s happened three times in the past. The best bus is the one with the broken door that you have to push open yourself. At least that’s a quirk you can live with.
February 7th, 2007
Next Posts
Previous Posts