Monday, July 30, 2012

Watchmen prequels

If you read comics at all, you have read Alan Moore's "Watchmen" series. Or maybe you saw the 2009 film.

If you loved either one, you'll be happy to know that DC is publishing prequels featuring the same characters: Nite Owl, The Minutemen, Silk Spectre, Ozymandias, Dr. Manhattan, Rorschach, and the Comedian. It's not a single unified series, but rather seven co-themed series of four or six issues each, 34 total. They've published seven so far, and you can still find the early ones in shops if you want to start from the beginning.

I'm not usually a fan of comics, but this series, like its predecessor, impresses me. It's written for distinctly adult tastes, and that makes a real difference. The Silk Spectre series, with a teenage SS breaking away from her very demanding mother (the original Silk Spectre) and making her way into the San Francisco counterculture, is particularly appealing.

Recommended.

Saturday, July 28, 2012

Akin to blasphemy

From Programming in Scala by Odersky/Spoon/Venners:
If you're coming from an imperative background, such as Java, C++, or C#, you may think of VAR as a regular variable and VAL as a special kind of variable. On the other hand, if you're coming from a functional background such as Haskell, OCaml, or Erlang, you might think of VAL as a regular variable and VAR as akin to blasphemy.
TRVTH.

Friday, July 27, 2012

Three months in a raft

While on vacation I had a chance to read Thor Heyerdahl's Kon-Tiki: Across the Pacific by Raft. If you grew up on PBS as I did, you've heard the story: in 1947 five Norwegians and a Swede built a balsa-wood raft in Peru and sailed west in order to support Heyerdahl's theory that the islands of Polynesia were populated from South America. They sailed for 101 days, finally reaching Raroia in French Polynesia.


The book was published a year later. It's a distinctive piece of work, written by Heyerdahl himself. The book is at its best when describing the obstacles overcome by the expedition: obtaining supplies from the US Army Quartermaster Corps, looking for balsa-wood logs in Equador, braving a storm at sea, and finally surviving the disastrous landfall on Raroia, which wrecked the raft on a coral reef. It becomes very clear that the author was either very well connected or very persuasive, since he managed wrangle the assistance of lofty figures most people would never even get to meet: a high official in the Army, the "balsa king of Equador", and the president of Peru.

The voyage could also very easily have ended badly. A worse storm might have toppled the raft. Slightly different construction techniques could have caused the raft to break apart. And the expedition did not have much margin for error: the raft was alone in the ocean far from shipping lanes, weeks from any possibility of rescue.

Passing years have not been kind to the science Heyerdahl and his crew crossed the Pacific to prove. It is clear now that Polynesia was settled from the west, not the east. But then, this is not a book that should be read for its science, but rather as a tale of great adventure long ago.

Recommended.

FP languages are expressive

I've spent this week learning functional programming using two languages from opposite ends of the FP space: Haskell, an uncompromisingly functional language, and Scala, which mixes in some OO concepts with an eye to inter-operation with Java.

The central argument for FP is expressivity. Because of the power of the tools FP languages offer, you are supposed to be able to get a lot done with only a few lines of code.

To test this claim, I used both languages to implement a program from The Practice of Programming by Kernighan and Pike. The program reads in a file of text, generates a Markov-chain transition map from it, and then uses the map to produce random text. The authors implemented this program in several major languages, and found that the amount of code needed varied significantly: the C program was 150 lines, the Java was 105, and C++ clocked in at 70 lines.

Both Haskell and Scala did better than this. The Haskell program was 45 lines, and Scala did even better, at 41(!).

As far as I can tell, the FP enthusiasts' claim of greater expressivity is right on the money.