District 9

“District 9” (2009) movie poster Very well-made little film. Dissolves into a fire-fight/action-movie at the end, but very worth watching.

Notably, the effects (aliens, space-ship) are handled very naturalistically. You forget that they’re effects. (All the ‘prawn’ aliens were CGI, apparently, except the dead ones being dissected in the lab.)

Some of the characters seemed less than convincing, especially a couple of the vox-pop talking heads which top and tail the movie. I think it’s particularly noticeable because most of the performances are very natural, particularly newcomer Sharlto Copley as lead Wikus van de Merwe. I also wasn’t terribly convinced by the violently insane mercenary Koobus (David James). He seemed awfully one-dimensional. Yeah, and some of the dialogue seems a little stilted (though apparently it was largely improvised…)

Also, they could have ditched the subtitles when the Nigerians are speaking English. Their accents are pretty heavy, but the subtitles are kind of patronising.

Something about the movie I felt was a little off. Perhaps I didn’t quite buy the conspiracies of the Nasty Corporation. Maybe it seemed strange that the aliens had all that futuristic weaponry and had never used it to gain power for themselves (or else had more of it confiscated). Or that the fuel for the spaceship was also some kind of biological/genetic agent.

These seem mean charges to level at a scifi movie, but this one sets itself up with such a high degree of verisimilitude and down-to-earth-ness, that the slightly less-real-seeming elements really stand out.

I enjoyed it, anyway. And it was thought-provoking. I wouldn’t rate it at 89%, but very worth watching.

Moon

“Moon” (2009) movie poster I wanted to applaud this film when the credits rolled at the end because it’s so intelligent, and self-contained and well-made and… elegant. Like a clever little short-story of a film which fired off all sorts of ideas in my head when I left the theatre.

Too many other reviewers have tried to make strained David-Bowie connections when discussing it. Instead I will make a strained Douglas-Adams connection:

The last time I saw Sam Rockwell in a film; in this one he has two heads too (and four arms).

He plays (rather well), two of himself. As you might have already gathered from the trailer, the story is that he’s working alone on an isolated Moon base, suffers an accident and wakes up to find that there’s two of him. And then, not wanting to give the plot away, Stuff Happens.

I really don’t want to give the plot away. I mean, it’s not like The Mousetrap or anything, but it’s quite a clever little story, and worth watching in ignorance, I feel.

Kevin Spacey voices the Moon-base computer, Gerty. It almost seems like he’s trying to copy HAL’s intonation from 2001: A Space Odyssey, and there’s the camera-eye with the expressive iris, and Kevin Spacey does ‘unsettling’ quite well, and Gerty’s always going on about how his only desire is to keep Sam safe… so I’m spoiling nothing by telling you that Gerty is entirely benign. (It’s exactly the old Bishop gambit: why the android in Aliens turns out to not a murderous psychopath like you were expecting.) You’ll like the computer. I did. Makes you feel good about Tomorrow’s artificial brains. Some of them are actually quite decent sorts.

Sam Rockwell (playing a character also called Sam, Sam Bell), is fantastic. The two Sams are nicely distinguished and—odd as this may sound—play off each other very well. They play table tennis at one point, which is a bit show-offy of the special effects people but for most of the film, (and this is saying a lot), I didn’t really think about the effects trickery and just enjoyed the performance(s).

The desolate landscape of the Moon is beautiful, (though, due to the almost exclusive use of miniatures rather than CGI, the vehicles look a little like they came out of a Gerry Anderson show—probably CGI dust and dirt would have looked more to scale).

In fact, my only real criticism of the film is the pacing towards the end. They seem to zip back and forth across the lunar landscape awfully quickly. Could have slowed the pace a bit. Also, as another reviewer mentions, the script introduces a Scary Countdown Timer at the end “because we need one dramatically, not because the driving idea has made it urgent or inevitable”.

Also, there are a couple of plot holes, but the whole package is so well executed that I didn’t really mind them.

All in all, I’d give it a 9/10.

Incidentally, When I was leaving the cinema, they must have been playing the trailer for the film on the screens in the lobby, so the music over the credits seemed to follow me out of the cinema. Very strange sensation. Rather appropriate to the film, actually.

Terminator Salvation

“Terminator Salvation” (2009) movie poster Disappointing. But go see it if you can sucessfully lower your expectations and smirk at the awful plot holes.

In a way this is a dreadful, dreadful movie. But in another way, composed as it is from the scavenged flesh of previous Terminator movies (and WWII action movies) laid over a mechanical script, and executed by soulless, unstoppable actors, it’s quite impressive to watch from an (emotional) distance.

The biggest question this movie raised for me was: how come Terminator robots are so rubbish at fighting? Their basic martial arts technique is throwing people into stuff. To some extent that can work, in that: if you throw Michael Baen/Christian Bale into enough filing cabinets/walls/windows, you will eventually wear them down, but if you were a huge, mechanical Arnold Schwartzenegger with superhuman strength, why not just take the easy route and crush their puny human heads, or rip their arms off. (The one in this movie even grabs the gun from the hands of a human at one point and chucks the gun away, before proceding to throw the human against more metal cabinets. Arnie in the first movie was smarter than that.)

The first movie was smarter than this one. Much smarter. It had a kind of gritty realism which made the outrageous premise (time-travelling killer robot from the future) credible. This movie is big and dumb and the woeful script is plainly just there to give an excuse for the explosions and the robots. (And the exploding robots, and the robots causing explosions.)

High points: visually it looks quite tasty. The post-apocalyptic wasteland looks lovely and cold and desaturated. In fact the whole film is art-directed to within an inch of its life.

Also, Sam Worthington, as the half-man-half-Terminator—(He has a metal endoskeleton, and a controlling microchip which appears to a) do fuck-all, and b) be embedded conveniently near enough the surface of his neck than he can just pull it out at an importantly emotional moment before saving the day)—is generally very watchable. He does proper acting and things, and his disbelief and inner conflict are all very believable.

Oh, and John Connor’s doctor girlfriend is very pretty. (Very pretty. Kind of a weird eye thing going on, but that’s quite endearing.) Anton Yeltsin is alright as a young Karl Reiss. Bale, as Connor, is, adequate. Spends all his time grumping.

Like I said, though, my main problem with the film is that it’s complete nonsense. There’s no logical, believable thread through it to make you care about the exploding robots. It feels like stitched-together other films. Very post-apocalypic-zombie-movie near the start, with Terminators that look like reanimated metal corpses; scenes and shots which appear to have been lifted wholesale from other movies in the franchise: the motorcycle/truck chase; the melting-the-robot-then-freezing-it-routine; the climactic fight in the factory. All the explosions and helecopters make it look like umpteen Vietnam movies. When Worthington first appears, reborn as a Terminator, he’s covered in mud and screaming, either like a newly-born Urak Hai in Lord of The Rings, or that guy in Apocalypse Now. Ho hum.

Then there’s the constant prompting the audience via clunky lines in the script. “Prepare medical team, stat. By the way: it’s John Connor.” Pish. The gurrilla resistance all seem like clichés, barking some orders, and bravely defying other orders, and, for some reason, amazingly well equipped and all looking like be-stubbled male models, as they cluster round their radios in a selection of apocalyptic international locations.

All in all, it’s what you should expect from the 4th film in a blockbuster Holywood franchise. Written by a committee, directed by a moron, and probably focus-grouped to within an inch of any remaining artistic life.

It was quite fun to watch a digitally-recreated naked Arnold Schwartzenegger throw Christian Bale into metal cabinets, but really it made me want to go back and watch the original The Terminator again. For all that that film’s effects don’t really stand up terribly well nowadays, it manages a wonderfully sustained tension, brilliant performances and a thoroughly engaging emotional core that Terminator Salvation doesn’t come near. The terminators in Salvation are just not as terrifying.

(Oh, and how much of a bastard is John Connor for accepting that donation at the end?!)

Hindley-Milner type inference in Scala

I’m working on a spreadsheet application at the moment. (Very exciting.) Part of the implementation obviously includes an expression language (so you can write things like total = sum(numbers) or vat = price × 17.5%).

Part of the design is to disallow things like "text" ÷ 11 or apples + oranges, and for that I need a type system.

So I’m investigating type systems, and rules for inferring types, and I’m looking at the algorithm they call Hindley-Milner type inference. I found an implementation of the algorithm in Perl by Nikita Borisov. This was in turn based on a Modula-2 implementation described in a paper by Luca Cardelli, Basic Polymorphic Typechecking (1987/’88). Given that I read maths only very painfully and slowly, it’s a very clear and readable paper.

I have reimplemented the algorithm in Scala (the language I’m using for my application).

Because Scala is itself a statically-typed language, some of the logic becomes clearer than the Perl version (for example, it is obvious where type variables are expected as opposed to type terms). Scala is also somewhat syntactically lighter than Perl, and a lot lighter and more expressive than Modula-2, so you may find it easier to read too.

The essential algorithm is elegant: given an expression in the form of an abstract syntax tree (AST), it recursively creates a tree of types in the expression, inserting placeholder ‘type variables’ for all the unknowns. It then ‘unifies’ sub-types, for example, ensuring that a function call’s result type is the same as the function definition’s result type. The final unification creates the most general type tree possible which accurately captures the expression type. The final unification may include still-unbound type variables, which would indicate that the expression is polymorphic in these type variables.

My code is available for download in the hope that others find it as useful as I found Luca Cardelli’s paper and Nikita Borisov’s Perl implementation:

http://dysphoria.net/code/hindley-milner/HindleyMilner.scala

You can run it as a script to see it analyse some example expressions: scala HindleyMilner.scala

Note: I believe that there was a mistake in the original Perl code; when unifying two variables, it tried to ensure that generic type variables were always bound to non-generic ones, not the other way about. This was in order to satisfy the requirement “In unifying a non-generic variable to a term, all the type variables contained in that term become non-generic.” However, it does not matter the order in which they are bound. Once the ‘bindee’ is further bound to a term, they both become bound to the same term. The original code omitted a call to prune in the method occursintype which (I believe) lead to a fault, for which the mistaken ‘fix’ was added.

Update 15 Sep 2013: Now compatible with Scala 2.10!