2012-05-26

SS2Tool and SHTUP

I would like to point out that SS2Tool is a very real thing, and that it makes System Shock 2 playable on modern Windows platforms (Windows 7 for example). Also pay attention to SHTUP, the Shock Texture Upgrade Project, which revamps the admittedly a little dated SS2 graphics and makes them a little sharper.

Even now, the original SS2 graphics look good, but they are clearly from an era when polygons were haute couture. Compared to SHTUP, the un-retouched cutscenes are almost laughable.

Except nothing in System Shock 2 is worth laughing at.

Nothing.

2012-05-11

Moose Types

After a while, you'll find that Perl's builtin data types, though useful, are limited. You will seek to expand them with a vast array of new data types and CPAN modules that add some kind of additional value to your program's logic: instead of open()'ing a file handle directly, you can abstract it objectively with IO::File.

Base Perl:

open(FILE_H, '< text.txt') or die($!);
print <FILE_H>;
close(FILE_H);

Object-oriented:

use IO::File;
defined(my $fh = IO::File->new('text.txt')) or die($!);
print <$fh>;
$fh->close;

There's some extensibility to the OO technique. For instance, you can still treat the IO::File object like a filehandle with <$fh> instead of explicitly using any of its available methods, like $fh->getline. In turn, IO::File gets a lot of its form and function by inheriting from IO::Handle, which gives a nice, mostly-consistent syntax between IO::File, IO::Dir, IO::Socket, and whatever else falls under the perview of input/output actions.

Then there's Moose. Moose is great and wonderful and is a holy, blameless creature. Problem is, Moose can be a little rough around the edges. This isn't entirely unexpected considering that it's a project whose purpose is to retrofit pieces of Perl6 on top of Perl5 because, damn it, Larry, we just can't wait that long. To be honest, object-orientation wasn't something with which Perl was designed or even, perhaps, intended. One can only imagine how hectic it would be to teach Perl5 Perl6-style OO.

It turns out that some intrepid folks have been extending Moose, which is something Moose is made to do. There are nearly as many MooseX extensions as there are stars in the sky and they all have really Linnaean taxonomic nomenclature: "MooseX::Types::This::That::Other" would not look out of place in a CPAN query for "MooseX". I found the whole thing a little daunting at first. In many ways I still do because these extensions are meant to take Moose — the extensible Perl6 OO of tomorrow, today — and extend it in obvious and not-so-obvious ways that are, themselves, Moosily extensible. The possibilities are endless, as is the potential for confusion and error.

Sometimes, it seems you can be too clever for your own good.

So how hard is it to read a file the Moosey way? There's more than one way to do it. We could wrap up any of our old techniques into an object and they will still work so long as we remember how to handle moving data around inside the class and pushing things through its celluar wall. Another option is to rely on MooseX type extensions and help make someone else's library do the heavy lifting. Doing it this way makes the code considerably longer since you have to account for the fact that before you open and read a file, you have to build the entire object around it. It's a little like Carl Sagan's apple pie recipe. ("If you wish to make an apple pie from scratch, you must first invent the Universe.") We don't want to make anything from scratch, though. Instead we want to leverage the MooseX types to wrap up a Path::Class object for us that is built directly into our object in a Moosey way.

package MyReadfile;
use Moose;
use MooseX::Types::Path::Class qw/File/;
has 'file' => (
  is       => 'ro',
  isa      => File,
  required => 1,
  coerce   => 1,
);

sub doit {
  my ($self) = @_;
  print $self->file->slurp;
}
1;
MyReadfile->new( file => 'text.txt' )->doit;

Is that sixy or what? In truth, Perl6 supports the easy way of doing this, too. It seems like a lot of extra typing relative to a simple open(), but compared to the effort we would need to commit to building a similar class from scratch in the base Perl syntax — making a constructor, blessing our referents, and writing our own read accessor all before worrying about actually getting and reading a file — it's relatively concise considering what we now have under the hood.

(If you are a masochist, you can still roll your own IO::File subtype and use it like so:)

package MyReadfile;
use Moose;
use IO::File;
use Moose::Util::TypeConstraints;

subtype 'MyFile' => as class_type('IO::File');
coerce 'MyFile'
  => from 'Str'
    => via { IO::File->new($_) };

has 'file' => (
  is       => 'ro',
  isa      => 'MyFile',
  required => 1,
  coerce   => 1,
);

sub doit {
  my ($self) = @_;
  print $self->file->getlines;
}
1;
MyReadfile->new( file => 'text.txt' )->doit;

(Coercions are global, meaning every Moose class in a given Perl instance shares them whether you want them to or not, so if you're not using the MooseX types you will have to keep your namespaces clean yourself. Hence why you want to define your own subtype "MyFile" and use that instead of IO::File directly.)

2012-04-10

I Write Like

Submitting my last few blog posts to I Write Like revealed that I write like Cory Doctorow, H. P. Lovecraft, and David Foster Wallace.

I'm not entirely sure why.

2012-03-26

Quick and Easy Sysinternals Synchronization

If you've ever touched a Microsoft Windows box, you are probably aware of Sysinternals, a large suite of tools co-developed by Mark Russinovich before he joined the company in 2006. There is a staggering surfeit of utilities that the Sysinternals team created, everything from simple command-line tools for securely deleting a file to profoundly powerful GUI diagnostic software like Process Explorer.

These tools are periodically updated from time to time, and it's handy to have the latest and the greatest versions because they are always adding new features and fixing esoteric bugs in several of these programs. You can hunt and peck your way through the site looking for updates, but here's a quicker way to stay up-to-date. Subscribe to Sysinternals Site Discussion. They have an RSS feed. When the blog tells you there's an update, do the following:

  1. Fetch and install wget for Windows if you don't already have it.
  2. wget -Nqr -nd -l 1 -P C:\sysinternals -R chm,html http://live.sysinternals.com/Tools
  3. Put C:\sysinternals in your %PATH%.

When the site posts updated utilities every month or so, just run the wget command again. It should skip the binaries that haven't been updated and save everybody a little bandwidth. Be cautious if you happen to be using any of these tools, since wget can't overwrite a file if it's open.

I used to run robocopy to sync these files, but robocopy has a terrible time doing accurate timestamping with the \\live.sysinternals.com\Tools share. wget is much more intelligent when handling the HTTP Last-Modified header. I presume this is because the Windows fileshare has FAT32-style 2-second mtime granularity. I haven't bothered to verify this.

For the curious, the long-format version of the wget argument-list is thus:

wget --timestamping --quiet --recursive --no-directories --level=1 --directory-prefix=C:\sysinternals --reject=chm,html http://live.sysinternals.com/Tools

2012-02-07

A "review" of Inherent Vice

Maybe this novel should have been called The Big Lot-49-ski. Or Dude, Where's My Noir?

I deeply enjoy the writing style of Thomas Pynchon, and even his wordily absurd and haltingly unapproachable works are still fun to read, right up until the point I put them down because I have lost track of plot, characters, and motivations.

Sometimes it really is the journey that's the worthier part.

Maybe it's me, but Tommy — oh, I call him Tommy by the way. We hang out a lot. Try to prove me wrong, I dare you. Anyway, Tommy said just about all that needed to be said about southern California in the late 1960s in The Crying of Lot 49, a short novel on the subject of how the past haunts us, forces us to act as executor to its will, and gets us involved in an age-old conspiracy surrounding an underground postal service. It was a vibrant snapshot of some of the psychotic cultural aspects of the era, of a time and a place where people had psychiatrists to medicate them into higher planes of existence, where nagging persistent paranoia was commonplace, and where love was not just free but plentiful, paranoia be damned.

Agree or disagree, he had his say in the matter. This somehow makes Inherent Vice seem, well, redundant. It's Oedipa's kid brother back to hit the same keys on his big sister's piano.

I really enjoyed the book, don't get me wrong. I don't care so much for what Tommy is saying so much as how he goes about saying it. The Library of Congress categorizes this book as "Private investigators—Fiction", "Los Angeles (Calif.)—History—20th century—Fiction", and "Experimental fiction". I take offense at that last one.

I can't tell you what Inherent Vice is. As is typical with a Pynchon novel, it's a funhouse mirror that reflects a wonderfully weird and distorted vision of what you choose to show it. In many ways, he's a modern-day Lewis Carroll. Thus, it's far more complex than any simple synopsis could impart. What Inherent Vice initially purports to resemble on the surface is a classic, almost derivative gumshoe story that if the Coen Brothers ever got wind of it, would make them feel an odd mixture of pride and copyright infringement.

The year in which the novel is set is not completely clear, but it's pinned down as occurring between 1969 and 1971. The protagonist is a lazy, clumsy, unrepentant marijuanaphiliac who is asked to take on a case that becomes much more complex than initially suspected involving a wealthy businessman, a mysterious schooner, and a cryptic organization that may or may not be involved with everything or nothing good and/or bad that is/is not happening.

Think Fletch. The book, genius, not the movie. Think The Big Lebowski. Think of how Lot 49 would have looked if it was written by Raymond Chandler. Think of a dozen noir story clichés — excuse me, staples — now stir them into SoCal in 1960-something or other and make it all... Pynchonic. It should smell like reefer and petroleum and have that bizarre yet wholly self-consistent logic to its worldview where fact and farce blur together but it all still makes sense at the time, like how I imagine dreams must be like. Like where it's OK to have characters named Trillium Fortnight and Puck Beaverton because, yeah, sure, why not have that as a real name here? I don't judge. Reality has seen fit to impart us with Dweezils and Moon Units, and lest you think I'm just hating on Frank Zappa, I'm pretty sure he had nothing to do with the Daphne Zunigas and the Blue Ivy Carters of the world. Suddenly, a sax player named Coy Harlingen isn't so quirky after all.

Unlike some of his earlier work, this novel has been slimmed down and most, but happily not all, of the absurdity has been streamlined to help the plot. It wouldn't be a noir novel worth anything if the plot didn't meander, but entire chapters dedicated to dream sequences and drug trips and trainspotting are mostly whittled down to the heart of what Tommy is really trying to convey: the time, the place, the visceral experience of being there and revealing only as much detail of the scene as you'd remember of it after you've woken up. It's only about 369 pages and he even manages to pack a trip to Las Vegas in there somewhere.

On top of everything, he is trying once again to capture the moment, the spirit of the place that is Los Angeles at the end of an era, when the summer of love is giving way to the autumn of no-one-knows-what-yet and there is uncertainty and confusion and doubt and the only thing everyone is completely sure of is that they cannot, and will not be permitted to keep doing what they've been doing. Like the twinge of sadness you feel when you realize your favorite band is playing their last song of their last encore and that any second now the lights will come up and it will all be over soon, the guts of Inherent Vice are much more substantial than the crime it dissects. It quietly whispers its fear of the unknown, not impending doom per se but impending force to change, the aching realization that you cannot remain where you are even though you haven't figured out where to go next, where the protagonist finds himself at times literally and figuratively in a fog.

Having read Inherent Vice, I know now how the caterpillar feels just before it begins to spin its cocoon, completely unsure of why it has to make one in the first place.