Saturday, May 05, 2012

The Galloway Effect

So, local elections, and the LibDem councillor of 17 years is standing down on health grounds. The election communication comes out with an introduction to the anointed successor, and isn't it wonderful what the parliamentary party has achieved.

Then suddenly, the first active canvassing I can recall for at least those 17 years, and maybe more -- phone calls, doorstepping, the full works. Then another more locally focussed election communication with a lot of "Please don't vote for the independent candidate" -- the only other horse in the race (I think I saw one Conservative poster the whole time).

So, results now in, 516 for the independent (a local character), 514 for the Libs, the rest down in the noise under 100, and a total turnout of under 1200 (which I would be surprised to find was much over 25%).

Maybe not as decisive as Galloway's win in Bradford last month, but a bit of a kick against complacency (though I don't think that Andrew Lansley has any cause for concern as yet).

Wednesday, May 02, 2012

Anime — Mobile Suit Zeta Gundam

One of the major series that are set in the same continuity as the original, but to my mind rather the weaker of the two. Where the original had the main characters caught up in actual warfare, doing what they could to escape to safety, and then becoming caught up as an irregular unit in the larger conflict, this is the story of a boy named Sue Kamille; and it all starts when a soldier (of the now rather fascist Earth Federation) makes fun of his name. So, he decides to sneak onto the base and cause mayhem with one of the new Mark II Gundam models; and gets out thanks to the fortunate timing of a raid by spacer guerillas.

So we reprise some of the structure of the previous series -- battles in space, then down to Earth for a while (meeting more of the old characters) before getting back into space, bouncing around the Moon and colonies before a final battle. And like last time, there's a somewhat fae girl whom the hero falls for, and who of course dies fighting for the other side, and a set of annoying kids aboard the battleship (purely gratuitously). But this time, rather than just "Federation good, Zeon bad", there is an attempt at some more Byzantine politics, with various Zeon successor groups being introduced, though often in a way that seemed to suggest that you should have known about them all along (maybe you should have read/seen something else in the canon?).

While there are a number of stronger female characters who turn their coats, or at least seriously consider it, they also get above and beyond the usual Kill 'em All Tomino treatment. And then the final battle -- they saved up all the character deaths, including at least one who'd been on borrowed time for several episodes; and after that ... it just stopped.
No aftermath, no epilogue, nothing.

In all, a series to be watched because it gets quoted so often, but being somewhat more ambitious than its predecessor, it also needs to be judged more harshly.


Bonus feature — Mobile Suit Gundam Wing

One of the alternate canon Gundam series, with the same Earth vs Colonies backdrop; but this time it kicks off with five superpowered delinquents being dropped to Earth in their own overpowered Gundams to #occupy the place, fighting each other as often as the Earth military. Oh, and one of them somehow is attending a school where the oujo-sama (daughter of some diplomat) showcased in the ED sequence goes, so he can threaten to kill her (which gets her all hot for him).

Meanwhile, there is a Char-alike following his own agenda, and military bases in Africa which appear to have the same racial mix as a Democrat party campaign HQ...

Dropped after five episodes.


Tuesday, May 01, 2012

3601.6

Bluebells

Bluebells at the start of the month


So despite a very wet April (albeit one that opened and ended with warm, sunny spring days), I managed 130 miles on the bike. Need to do twice as much each for the next two months to hit my target; and May isn't looking too good (but that's Bank Holidays for you).

Flowers in the Rain

More typical weather


Sunday, April 08, 2012

Anime -- 2011 in review (part 2)

Continued from last year

One of the potentially interesting things that happened last year was ANN's launch of the anime-on-demand streaming site, which opted not to have the advertising supported option that Crunchyroll does. Alas, the player they used still stuttered and juddered (losing a few seconds' video), and often crashed each time there would have been a commercial break -- and also had a splash page telling us that the advertising revenue supported the original creators.

And, whatever else you might say about Crunchy, at least they announce what they've got early, release on a timely basis, rather than leaving it a month after a series aired to offer the last three episodes, or a month into the quarter before putting up a single new series.

So, what did I watch from last year... A lot of duds, mostly.

Winter season


Hourou Musuko, another adaptation from the same mangaka as Aoi Hana, was dull, worthy, and totally blew my suspension of disbelief in how it depicted 12 year old kids (having been one once, I sorta know about that). Dropped after 5 episodes.

Gosick started as a Ruritanian fantasy -- a Japanese boy studying in a school in some 1920s central European principality meets a mysterious girl who seems to live at the top of the library tower and solves mysteries. As is the way of these things, when it was episodic, it was fine, but then it grew a plot with little foreshadowing, and was suddenly about alchemists and the murder of the late Princess and court politics, which the schoolboy protagonist had no sight of. And the last couple of episodes just went over the top, culminating in major fast-forwarding with no real sense of what was going on. Japan just doesn't into endings, again.



Level E was the best series of the quarter, nearly the best of the year. A sort of Men in Black, the anime, following the arrival of a trickster alien prince on Earth along with handlers striving desperately to avoid setting off an interstellar incident. For once, a humorous series was actually funny.


Spring season


Tiger & Bunny -- corporate sponsored superheroes in sorta-New York, only with Japanese corporate advertising over their costumes; and played as a buddy movie with long-time hero Wild Tiger and rookie Barnaby "Bunny" Brooks Jr. as the main team, plus a supporting cast of other heroes, all competing for points in live-televised crime busting. It reached a sort of climax about halfway through when a major menace with some apparent connection to Bunny's mysterious past was defeated, and then was still noodling around when a-o-d ran out on me when I'd only got to the 3/4 mark, and I really didn't miss it.

Battle Girls : Time Paradox is not Sengoku Basara with girls, but is alas much sillier. Dropped after 4 episodes. If only Hyouge Mono had been picked up instead.

Steins;Gate was another early drop -- annoying characters, and the prospect of it turning into an alternate reality multiple choice harem were enough.

[C] : The Money of Soul and Possibility Control -- a somewhat topical short "shout out your attacks" battle series with a financial theme. Generally harmless fluff trying to be a bit serious; made a little bit unsettling by watching when it seemed like there might be imminent waves of [C] emanating from the Southern European Financial District.


Summer season


Natsume Yuujincho San -- haven't finished this yet.

Yuru Yuri -- insubstantial. One episode was more than enough

Kamisama Dolls -- the preview looked like it might be Narutaru v2, but alas all that bit seemed to be over in the first 2/3 of the first episode, and it looked like settling down into sophomore hijinks what with an annoying little sister and a Haruhi-wannabe science club president. Dropped after 3 episodes.

The Mystic Archives of Dantalian looked a bit like Gosick at the outset -- mid 1920s setting in England, where ex-RFC pilot Hugh Anthony Disward comes into his inheritance and finds the ancestral pile comes with goth-loli biblioprincess in amongst the mouldering tomes. He is refreshingly competent in their episodic adventures with Forbidden Books That Should Not Be, as one might expect of a gentleman adventurer.

Alas, when the last episodes finally came through, the final two turned out to be a multi-parter that would introduce the Plot. And then it ended, unresolved, in a rather rushed fashion.


Autumn season


Fate/Zero -- I saw the first double length episode and was underwhelmed.


Chihayafuru -- haven't finished this yet, but anime of the year.

Un-Go -- a sort of Ghost in the Shell plus future disaster stricken Japan setting, using old mystery story plots in a modern guise. The first three episodes were OK, but not enough to make me want to go out and pay a quarter's a-o-d subscription for by itself, when I was watching about as much as I could fit in from Crunchyroll anyway.



Saturday, April 07, 2012

Playing with (almost) the latest C++ features -- groundwork

Having had my interest in playing with native code reawoken by the new C++11 features, the first thing I went to look at was portability. One of the advantages of managed code -- JVM or CLR -- is that the VM handles portability for you and the code can be built pretty much anywhere; with native code we have to see what the compilers have in common.

I've been using VC++2010 on Windows as having many of the "big rocks" for the new standard, while being backward compatible onto OS versions before Win7 (unlike the VC++11 compiler and its runtime); and for *nix-like systems, I have cygwin and debian squeeze... Well the distro support for these is a bit behind-hand (gcc versions 4.5 and 4.4 respectively), whereas gcc 4.7 is now out with quite a broad coverage of the new standard. While 4.5 has a good chunk of the new stuff, 4.4 doesn't -- in particular, it doesn't have the new lambda syntax. So, it's build from source time to get an upgrade to a sensible version there, which means I might as well go to the latest and greatest on both platforms...

Building gcc 4.7 from source

debian

Fortunately there are some handy instructions out there which can be used as a baseline for debian. Following them, I found that I needed to tweak how I built GMP to fit PPL's requirements, by modifying the configure step to be:

CPPFLAGS=-fexceptions ../../sources/gmp-5.0.4/configure --prefix=$PROJECT_DIR/output/ --enable-cxx

before PPL would go through happily. The --enable-cxx is required for the PPL ./configure stage to run through, the CPPFLAGS=-fexceptions is optional, but it avoids a make-time warning about possible unwanted runtime behaviours if you don't.

ClooG also needed a CPPFLAGS=-I$PROJECT_DIR/output/include CFLAGS=-L$PROJECT_DIR/output/lib on the configure line to find GMP.

In the gcc build, as well as pointing at ../../sources/gcc-4.7.0/configure it's also worth taking the advice from the MacOS build instructions and only selecting languages of interest to you i.e. to play with new C/C++ there's no need for Java or Fortran, at a considerable saving in time.

Then it's a matter of just adding soft links from whichever g*-4.7 files to the unadorned versions, and


export LD_LIBRARY_PATH=~/gcc-4.7/output/lib/
export PATH=~/gcc-4.7/output/bin:$PATH

to your .bashrc or equivalent


cygwin

Cygwin is more fun -- I've not yet managed to get that to build all the way through with the loop optimization libraries. When you get to PPL, you find you also need to go back and re-configure GMP with --disable-static --enable-shared, as explained in the friendly manual, to build the shared library version. However then when building gcc, we get a mismatch with the earlier libraries in the configure stage, where it just stops:


checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... no

It is possible that if you start by building PPL and CLooG with shared library GMP in a first pass, then build the rest starting with reconfiguring and building a static GMP it will work, but life is too short. The MacOS build instructions didn't use the PPL/ClooG/graphite libraries either, so we can do this to configure gcc instead:

$ ../../sources/gcc-4.7.0/configure          \
>     --prefix=$PROJECT_DIR/output/    \
>     --with-gmp=$PROJECT_DIR/output/  \
>     --with-mpfr=$PROJECT_DIR/output/ \
>     --with-mpc=$PROJECT_DIR/output/  \
>     --program-suffix=-4.7            \
>     --without-ppl --without-cloog    \
>     --enable-languages=c,c++

which sits and cooks for quite some time to get you the new compiler build.


Linkbait: fixing cygwin "mkdir foo mkdir: cannot create directory `foo': Permission denied"


I got into a state where I had this error, which other people have seen, after having tried to trash the build output of one of the failed PPL/CLooG attempts from Windows Explorer, where anywhere under in my home directory and down it was rejecting mkdir with "mkdir foo mkdir: cannot create directory `foo': Permission denied". Having spotted a tangentially related mailing list message about this sort of problem happening on network shares and there being ACL related, I tried the following and it worked to clear things up:

  1. Start a PowerShell console as Administrator window
  2. Run Get-Acl a folder (like /tmp) which you can mkdir in in cygwin (this will be %cygwin_root%\tmp where %cygwin_root% is where you installed cygwin)
    $acl = Get-Acl C:\cygwin\tmp
  3. In Windows Explorer set yourself Full Control on all the affected folders -- %cygwin_root%\home and %cygwin_root%\home\%USERNAME% at least
  4. In the PowerShell, Set-Acl on each folder you've just frobbed with the saved ACL object
    Set-Acl C:\cygwin\home $acl
    Note that the Set-Acl call may take considerable time (tens of seconds) to execute when it gets to the really problematic node and has to roll permissions down.

SCons -- Death to makefiles

Since I last did native code seriously at home (c. year 2000), I had discovered the very handy MiniCppUnit tool as a nice light-weight unit testing framework, so of course I went and fetched a copy to be going on with. This time, curiosity prompted me to wonder "WTF is this SConstruct file anyway?" and now when I opened it, I immediately recognised that it was some form of Python script, and wondered what sort of Python based make system this might be.

It was simple enough to find where it came from -- http://www.scons.org/ -- and looking at the user guide, I felt that it is much more intuitive system than makefiles (admittedly there's not a high barrier there), and far less cluttered than declarative XML based systems like Ant or MSBuild; so I'll be using that for my *nix builds -- it works very nicely for doing things like running unit tests as part of the build e.g.

MiniCppUnit -- Building it under modern C++

Just like I had to patch it to build in C++/CLI, I needed to make some changes to MiniCppUnit to get it to build clean under VC++2010, the out-of-the-box gcc 4.5 on cygwin 1.7.x and gcc 4.7 debian squeeze with -Wall -std=gnu++0x or -Wall -std=c++11 on respectively. First MiniCppUnit.hxx:

92c92
< #if _MSC_VER < 1300
---
> #if defined(_MSC_VER) && _MSC_VER < 1300
93a94
> /* Without the "defined(_MSC_VER) &&" this code gets included when building on cygwin 1.7.x with gcc 4.5.3 at least */
204c205
<  static void assertTrue(char* strExpression, bool expression,
---
>     static void assertTrue(const char* strExpression, bool expression,
207c208
<  static void assertTrueMissatge(char* strExpression, bool expression, 
---
>     static void assertTrueMissatge(const char* strExpression, bool expression, 
304c305
<    catch ( TestFailedException& failure) //just for skiping current test case
---
>    catch ( TestFailedException& /*failure*/) //just for skiping current test case

and the corresponding signature change in the .cxx file:

108c108
< void Assert::assertTrue(char* strExpression, bool expression,
---
> void Assert::assertTrue(const char* strExpression, bool expression,
122c122
< void Assert::assertTrueMissatge(char* strExpression, bool expression, 
---
> void Assert::assertTrueMissatge(const char* strExpression, bool expression, 

Of course there may be other things lurking to be scared out when I ramp up my standard warning levels to beyond the misleadingly named -Wall (when you have -Wextra, formerly -W, provided to switch on a whole bunch more including spotting signed/unsigned comparisons, before getting onto the really specialized ones) and switch on -Werror to force everything to be really clean.

Saturday, March 31, 2012

3471.5

So In the first quarter, I managed 269 miles on my own bike -- a lot more cycle commutes in March than I had expected -- plus 75 on the hire bike for holiday -- putting me 1/3 the way to my target of 1000 for the half-year.


Early cycling holiday


Seckford Hall Hotel gardens

To use up some carry-over leave from last year, I booked the last possible use-by dates, and decided on the cyclebreaks Tudor Treat package, so that even if the weather was awful, I could at least be pampered. As it was, having been their last customer out last year, I was their first out this -- and doing so, I caught the last day of the glorious early summer, before a return to more normal conditions. So on the first morning in glorious sunshine I set off, and let the miles roll past:


View 29-Mar-2012 in a larger map

Setiing out about 09:30, I didn't decide on what route I'd take until getting to the Red Lion at Martlesham, where I turned right, and made the same sort of loop around Ipswich as I did last time I was there -- only this time, I paid more attention to the cycle-route signs when having to clip the corner of the built-up area (where motorists were queueing to full up cars and petrol cans), and then down the only really busy piece of road, the B1113 through Sproughton, which combined up-hill with constant traffic both ways.

I went through the old village at Copdock, rather than slogging up the old dual carriageway, then through the obvious route to the White Horse at Tattingstone, getting there just after midday; by which time it was warm enough to have taken off the brushed cotton shirt I'd started with. And after a pint -- too early yet for lunch (despite the tempting menu) after a huge breakfast -- warm enough to strip down to shorts as well. From there, the cycle-path around Alton Water began shortly after, then to the Suffolk Food Hall for a light lunch.

The return route was pretty much forced into backtracking some of the way in until turning north at Belstead; then having made mistakes in the in-bound route last time, I followed the more direct way to the city centre and then followed the cycle-route signs out East -- no long spells of pushing, only the first little bit around that multiple roundabout -- and out along the country lanes to the hotel.

Sum total, 45 miles; so I was a trifle creaky when having freshened up, I went down for a much needed pint at the hotel bar.



View 30-Mar-2012 in a larger map

Friday opened sunny, and was forecast warm, so I started on the loop down to Felixstowe, to look over at Harwich; but cloud soon bubbled up and socked in completely, with a raw northerly wind, so by the time I got onto the unpleasantly busy road south of Kirton, I thought this was no longer a day for going to the coast, and took the only way out that wasn't back, aiming for the Dog at Grundisburgh for a light lunch; and then took a rather indirect amble back to the hotel, for just over 30 miles in total, before setting off home to beat the evening rush.

Although the second day was more the weather I had been expecting, cold northerly aside, it was really nice to be out and enjoying the countryside in spring -- cowslips, daffodils and primroses running riot in the verges, and daffs in most patches of woodland.


Tuesday, March 27, 2012

C++ then and now

A long while ago (turn of the century) I wrote a little Win32 utility to drag and drop files to get their MD5 and SHA-1 hashes -- useful for verifying downloads. And when I composed the hex-string hashes into a std::string, it looked almost 'C' like, thus (repeated once per hash):

with <string> being the only bit of C++ in sight, in fact

After the recent Going Native C++11 bash I decided to dust it off and revise it using Boost and the TR1 features in VC++ 2010 (which has most of the C++11 goodness all by itself). So now that section looks like:

which gets called in another lambda that is for_eaching over a vector of tuples containing hash contexts.

The code size has gone up (down if you count discarding hand-written MD5 and SHA1 for the CryptoAPI -- which adds its own error-handling bloat); but the increase includes half a dozen little RAII classes, and code to discover a better monospace font than SYSTEM_FIXED_FONT, albeit from a hard-coded list of Inconsolata, Consolas, Lucida Console and finally Courier New.

My immediate reaction is that the provision of lambdas now makes the standard algorithms actually usable -- no more functor classes remote from the point of use -- and I can program it in the more functional style that I'm now used to.

Saturday, March 24, 2012

Summer's lease

Today, even before the clocks go forward for summer time, it was warm enough to sit out in the garden until the sun got too low, at about 3pm -- or 4pm in tomorrow's money.

Still, there's bound to be rain at Easter.

Monday, March 19, 2012

C# under the covers

More of what the compiler does without you realising it, only this time in a C# sample.

The absolutely simplest sort of method, which you can clearly completely cover by calling it once. Right?

That's what I thought until I tried running OpenCover over code rather like this, and it told me I had only covered one of two possible branches.

So naturally, I go "WTF?", and wonder whether it's the return or throw alternatives out of .First that it's alluding to and to be certain, crack open ILSpy, and see that first line expands to

which actually involves first caching the delegate corresponding to the lambda, if it hasn't been already; or using it on subsequent calls.

The release build is much the same; it lacks the initial nop, and the meaningless jump-to-next-instruction at offset 0x23.

Move the constant string out into the method, and make the lambda close over it

and the caching goes away : a new instance of ClassLibrary2.Class1/'<>c__DisplayClass1' gets created every time, debug or release. And with it goes the branch.

Sunday, March 18, 2012

Spring keeps springing

As usual at this time of year, high pressure usually means socked in 8/8 cloud, or fog after a clear night; and with sunset around 6pm, a prompt return from work and/or some remote working after dinner when cycling. Despite that, a clear night before the full moon meant good conditions for cycling to and from dinner; and since then I've managed three days (out of seven possible) cycling to work when it wasn't foggy and/or drizzling.

The garden continues to progress - primroses now all in flower, not just the ones in the sunny places that have been going a month or more; viburnum still, a solitary daffodil, can crocuses and snowdrops giving way to the early dwarf tulips. I've even had the mower out a couple of times now.

Still a lot of April chores ahead -- lawn work, clearing weeds from the various beds; but I've made a start on some of that already, mainly last Sunday when we had the first warm day where I didn't need a jacket going to the garden centre for supplies.


Friday, March 02, 2012

Spring has sprung

After a foggy start, yesterday was bright and mild; a perfect day for spring to open. Let us hope that the month does not exit in too leonine a fashion.

All winter, when the cats have complained about being kept on strictly measured rations, as the vet says they could do to shed a few ounces, I've told them to go and catch something if they want more to eat.

So yesterday, they celebrated spring by leaving a pile of entrails on the kitchen floor, as token that one at least had found a reasonably sized rodent to supplement the kibble.

Sunday, February 26, 2012

My reactions to Stroustrup's keynote on C++11 style

I finally got around to watching this on channel9. Now, I don't do much C++ myself these days, since most of the code at work is in C#, and the language is rather high in ceremony (e.g. header files) for out of hours playtime, compared with the broad spectrum of widely available and popular languages there to choose from these days; but I do from time to time, so it's always good to see where things are going.

Interestingly, for a C++11 talk, a good 60% of it was about how we could drag the usual run of C-with-a-cpp-file extension code kicking and screaming out of the 1980s and into the early 21st century. In-language lambdas, async/futures and move constructors were touched upon, but where real world examples were talked about, it was showing how actual live code wasn't taking advantage of features that have been available in compilers for the best part of a decade, or longer, to make code simpler, more maintainable, and faster -- often considerably faster. And when I have to do some C++ and have been greeted by files full of almost-C-in-files-with-cpp-extensions, written by people who are writing native most of the time, I know that feel, bro :

>2012
>Not using RAII

ISHYGDDT

The "a lot of people don't know that" moment -- when doing random access insertion or deletion from a sequence, the random access part dominates the insertion/deletion reshuffling to such an extent that whatever the collection size, use a vector rather than a list.

The big takeaway -- despite the folklore, going to low-level 'C' style constructs is premature optimization. The machine code generated by the higher level constructs is often exactly the same as for the hand-crafted lower level code; and at times can be better, as the compiler has more context for optimizations.

Heh, almost makes me want to do something with the language again, if only to keep my hand in.

Saturday, February 25, 2012

Signs of the times

A few weeks ago, we went to the Arts Theatre to see Cheek by Jowl's production of the overwrought Jacobean tragedy 'Tis Pity She's a Whore. Entering the auditorium, we were presented with a sign warning that the production contained nudity and bloody violence. Fair enough, given that these days when a character murders and dissects his sister, that sort of thing naturally occasions buckets of the old Kensington Gore for audiences oft rendered blasé by the various species of torture porn that runs through cinemas without any shrieking of "Look -- a video nasty!!".

Today, we went to see the Marlowe Society's production of A Midsummer Night's Dream; and the warning this time was that there would be smoking on stage.

Is this what we have descended to, that when a production decides that Oberon shall open the second half lazily waving a cigarette as he observes the chaos he has occasioned, that we have to warn the sensitive of the fact?

Some people need to grow the hell up.


Monday, February 06, 2012

Dear Diary,...

January was a rubbish month for cycling -- a total of 15.2 miles logged. And February being winter, maybe not so much better.

After having passed 4000 miles on the way back from last holiday, the car went past 5000 coming home from work last Thursday (on a day when it was -4 all journey in, and still sub-zero for going home time).

Cold weather at the end of last week came of a sudden, and I'd forgotten to replace the bubble-wrap over the pond; so Saturday morning that was 2" thick with ice, humped under the plank that was supposed to protect against gentle frost, more than enough to take my weight, but I managed to cut a belated air-hole -- most of the way through with a pruning saw, then hot water for the last bit. That let water gush out from below, and then I could chip away until there was a reasonably sized hole.

I also harvested some sprouting broccoli ahead of the snow that fell after dark as a warm front came over.

Sunday morning was snow-clearing so that Karen's morning call had somewhere dry to park -- but even then the snow was starting to thaw on the car. The amount of snow meant that it didn't shift in a hurry -- the close was quite deep in slush this morning; and I was glad I packed a shovel, as I needed to dig myself clear several times in the car-park at work.

Coming home early to work remotely for the afternoon, I didn't need to dig past what I'd already cleared, but the traction warning was going all the time I was in the car-park. The rest of the drive was just wet -- much black ice if it frosts tonight -- and the close almost clear.

Forecasts this morning were also rubbish -- the Met Office said it was foggy; The Weather Outlook (Forecast issued: 06/02/2012 08:06:10) that it was -5C when Cambridge airport latest METAR reported

Time: 07:50 UTC
Visibility: 8000 m
Clouds: Broken sky, at 800 feet above aerodrome level
Temperature: 1C