Tuesday, March 27, 2012

When the Devil Dances

"When the Devil Dances" (John Ringo) - The third book of the Posleen War.  Word on the street is this and the fourth book were supposed to be combined to make a trilogy.

It should be no surprise that I like things "epic" (very large).  That's why I prefer Babylon 5 to DS9, and elements of Star Wars over Star Trek.

So, I was initially very excited about Ringo's SheVa (Shenandoah Valley) tank.  Basically, a shuttle crawler armed with a cannon.  It's about three times bigger, and nuclear powered.  The gun fires a high velocity DU round, with an anti-matter charge.

I was compelled to break out GURPS Vehicles and start drawing it up, but the only discussion on the net I could find was at Star Destroyer dot Net.  What a bunch of wet blankets!

They've soured the experience some for me, but, overall, I remember this third book as being in line with the first two - and enjoyable.

The first book introduced the setting, and the Posleen enemy.  All the action takes place off Earth.  The second book covers the initial landing on the east coast (Virginia and DC).  The third book pulls a Dune, and skips ahead 5 years, after the Posleen have conquered much of the world.  The middle of the US is still holding out, with the Appalachians acting as a Great Wall (and army elements plugging the passes).

The power armor units have taken heavy casualties, and we get more insight into the Posleen, as some of them start to smarten up after humans have killed off all the dumb ones.

Thursday, March 22, 2012

C++ Remove Thyself!

Came up against a nasty bug recently...

What do you think the following code does? (You shouldn't need to be a programmer to guess)

std::remove(myArray.begin(), myArray.end(), "cheese");

(this looks hideously over wordy...)

Maybe, remove all the items matching "cheese" between the beginning to the end of the container 'myArray'?

Good guess!  And if you read the docs, you might think that...

What it actually does is shuffle the elements so that there are no items matching "cheese" near the front of the container.  It returns a pointer to the last valid element.

This means you have to do:
std::erase(std::remove(myArray.begin(), myArray.end(), "cheese"), myArray.end());

(wow! they found an even more hideous way to write code!)

There's even a Wikipedia page! Erase-remove idiom
Sounds kind of ominous...

So, if you ever used std::remove, check all your code for this bug!
Enjoy!

Tuesday, March 13, 2012

Gust Front

"Gust Front" (John Ringo) - The second Posleen book.  I often imagine how movies might be made of books I am reading.  I think this one has real potential to be something memorable (of course, it could be done as another forgettable version of "Independence Day").

There is a lot character and "big ideas" (sacrifice, etc).