Monday, May 05, 2008

Rails Development for iPhone with rails_iui

iphone_sim.jpg

I've been doing some web development for iPhone and Mobile Safari lately, not least because of a series of articles that will be showing up in IBM DeveloperWorks soon.

I was using the iUI toolkit, which contains a number of CSS styles and JavaScript event handlers to make iPhone Web apps look and feel somewhat like native iPhone applications. As I was working with iUI, I realized I was building up a library, so I converted everything to a Rails plugin: rails_iui.

Get the plugin from github: git://github.com/noelrappin/rails-iui.git

Right now the plugin is primarily interested in doing a few things:

It contains a rake task to download iUI, move it's files to the Rails public directories, and change the CSS image URL's accordingly.

There's a controller class method acts_as_iphone_controller, calling that sets up a before filter that captures the Mobile Safari user agent string and sets the request format to iphone for use in respond_to blocks. For testing purposes you can call the method as acts_as_iphone_controller(true), and all calls will be treated as iPhone requests.

There is a module of helper methods that are wrapper methods or combinations of iUI CSS classes. Included are:

  • A method for creating the iPhone toolbar at the top of the view.

  • Methods for creating the iPhone list structures from a list of elements that know their associated URLs, including a grouped list in the style of the iPod application

  • Rounded rectangle classes

  • A form helper for the iPhone toggle button, as seen in the settings page.

  • A method to specify an Ajax callback when the phone changes orientation

The short term goals for the project are to tighten the code a bit and improve documentation and testing. Longer term goals are to augment iUI's JavaScript handlers with something a bit friendlier with Rails, particularly in handling history and back behavior.

So take it for a spin, let me know what you think. Hope you find it useful.


Please check out my book, Professional Ruby on Rails.

Thursday, April 24, 2008

Bind is actually rather an understatement...

Battlestar Galactica 403 (or 405) "Ties that Bind"

That was dark even by the really, really high standards this show has set for being dark and unsettling. It was an unrelenting parade of deeply screwed up people in torment, and the relationships that torment them. Naturally, I loved it, but if it wasn't so well written and acted, it'd be insufferably gloomy.

Bullet points -- if you haven't seen it, and plan to, look away.

  • The directing in this show was very overt, a lot of very artistic effects -- Starbuck only being shown from the back, a lot of blurred backgrounds and voice in Cally's point-of-view shots, the rotating star design motif. Most of it worked -- I thought that keeping us from seeing Starbuck's face was very effective. I could have done without the kind of druggy shots of the kid's mobile or whatever the heck that was.

  • I was spoiled on Cally's death, but the spoiler note implied it was a suicide, so I was surprised by both the addition of the baby in the scene (which made it about 100 times darker), and by Tory's involvement. I guess we'll find out next week whether Tory told Chief what she did.

  • I realize this is an odd place to make a stand on plausibility but... let me get this straight. Kara's crew has her, presumably pretty widely known in the fleet even before she died and came back; Helo, notorious as "the guy who married the toaster", plus he ran the refugees for a while, and he was Galactica's XO; and Anders, world famous athlete. All three of these people can just disappear for three weeks without anybody noticing?

  • This is true: at the beginning of the episode I was thinking, hmm... on a spaceship it's never warm enough for people to get uncomfortable and sweaty. Then they cut to the Starbuck ship, which made Cool Hand Luke look like Ice Age (Cool Hand Luke = sweatiest movie ever in the pilot for Cheers... so it's a joke. Get it?).

  • Haven't even covered: They made clear some things about Cally that were almost subliminal, about how she feels about Chief and all... thought that was nice to see. Also, Lee remains the easiest person to manipulate in the entire history of the Galaxy. Presumably Zarek nominated him to the council so he could always have one person he could con into doing goofy things.

Wednesday, April 23, 2008

Quick Program Notes

A couple of updates on book and article news...

  1. It looks like the screencast/video thing is going to happen, thanks to Jim Minatel. The main constraint is that they'd like the videos to be about five minutes long. I think the first one will be setting up a Rails project in Subversion (chapter 2 of the book, essentially), and I'd do a remix of that chapter using Git if there's interest. Wiley would like several of these, so I'm open to any topic ideas.

  2. At one point, I think I mentioned here that a .pdf version of the book would be available about six weeks after initial launch. Obviously that hasn't happened yet, and I'm not sure when that might come together.

  3. I'm going to have another series up at IBM Developerworks sometime in the relatively near future on developing iPhone web applications in Rails. More on that as it gets closer.

  4. I'll be attending (but not, alas, presenting at) RailsConf this year in Portland. Since it's an O'Reilly run conference, there won't be an official Wiley presence, but I'm hoping to have some book-related activity there.

Monday, April 21, 2008

Two Parter on Hide And Seek

Two articles on the Pathfinder blog on adding show and hide toggles to a Rails application:

http://blogs.pathf.com/agileajax/2008/04/hide-and-go-see.html

http://blogs.pathf.com/agileajax/2008/04/hide-seek-and-s.html

Sunday, April 20, 2008

You Say Tomato, I Say To-Mato

In the last week, I've had two separate editors at two separate companies make a bulk change in something I was working on. Specifically, they changed "plugin" to "plug-in". This is driving me a little bit crazy. Which is right? Should I care?

Quick research, designed to shore up my point of view...

Wikipdia has it as "plugin", with "plug-in" as an alternate. Dictionary.com has it as "plug-in", although that's clearly an antiquated reference based on the definition ("capable of or designed for being connected to an electrical power source by plugging in or inserting"). Presumably this is where the editors are getting their style guides. The Pro Rails editors let me keep it as "plugin" -- I don't remember that being an issue.

More importantly, "plugin" is 100% preferred in the Rails community, I've never seen it go the other way. See here, here, or here. This is also mostly true in the Eclipse community.

Am I putting too much effort into this argument? Does this make any difference to anybody, or am I just crazy? To me, "plug-in" looks old timey and weird, like "base ball" or "e-mail", or something John Hodgman would throw in to make his writing seem off-kilter. If I see a Rails article that uses "plug-in", I assume that either the writer is off-the-charts persnickety or that the writer is not really in touch with Rails developers. (Perhaps not coincidentally, I'm always a little worried that I'll have some writing quirk that won't match the expectations of my audience.)

So? Which spelling do you prefer? And does it even matter to you?

Thursday, April 17, 2008

Boxcars

Battlestar Galactica 402ish "Six of One"

Some quick bullet points before the next one comes down the pike.

Very pleased with the first two episodes of the season -- I think it's encouraging that this episode, credited to a writer whose last couple were not that strong, was arguably better than the first.

  • Katee Sackhoff had an amazing week -- Starbuck was all over the place, on the very edge of hysteria of not past it, a lot of great scenes. The Adama/Roslin scenes were also very good.

  • If you are looking for a line to take a something other than face value, I'd recommend "I'm no more a Cylon then you are"

  • How long can Tigh, Anders, Tory, and Tyrol meet together before somebody gets suspicious? It's not like they travel in the same social circles or that anybody is going to believe they've got a bridge game going...

  • Loved the Cylon civil war idea -- it's very consistent with what Moore has said in a number of interviews about Cylon society being young and under it's first real stress. (This is actually where I thought they were going to go at the end of Season Two, after "Downloaded" first hinted at pro and anti human politics among the Cylons. Plus it's always nice to see Dean Stockwell. (The actual confrontation scene was capped by Tricia Helfer's look of shock at the end.)

  • Okay, having two farewell ceremonies for Lee was a bit much, especially since you'd think that there would be some resentment over an able-bodied person leaving the military. That said, both scenes worked on their own, and I thought the aside in the bar scene of the group presumably strip poker was weird and funny.

  • There are many reasons I like this show. One is that Baltar, after the events of last episode, still had a visible scar in this episode -- a point that many shows would ignore. Watching Callis play against himself was also fun.

Wednesday, April 16, 2008

Video Still Working On Killing The Radio Star

Annnddd... This, of course, is what I get for posting anything about Wiley late at night without checking. Jim Minatel from Wiley added the following comment:

Noel: I'm interested in getting Wrox authors to to videos related to their books.... I can tell you what's involved and see what we can do.

So, contacting in progress. Further bulletins as events warrant. Or as events don't warrant, I think further bulletins are inevitable.

Thanks, random blog commenter, for pushing me forward on this.

Tuesday, April 15, 2008

Video Killed the Radio Star

When you have a blog with as few comments as this one, you can give every comment the kind of personal attention it deserves. This one came through from an anonymous commenter:

Noel, have you considred making a DVD video tutorial of your book? This will really help those who learn by watching videos.

So what do you say?

The short answer is not as any kind of official adjunct to the book. The longer answer is that it's not impossible that I'd be involved in online video or screencast training at some point in the future.

There are several issues here: logistical, legal, whether anybody would even be interested in such a thing, whether having my face on the cover is enough "me" for most people... all kinds of issues.

Logistically, the problem is that doing video well requires a lot of planning, equipment, and effort. I don't know much about it, but I know enough to say that it's probably more complicated than than I expect. Even a simple screencast involves scripting, time for filming, and editing.

Legally, Wiley/Wrox owns the copyright on the book, and while they might be okay with a short video clip that was clearly promotional, I'm not sure they'd be ok with me repurposing the book's content in bulk. On the other hand, I've never asked -- it's possible they'd see it as a marketing possibility. I don't remember the specific details of my contract, but I'm pretty sure that Wiley retains rights for any alternate media versions of the book. Which would be kind of a bummer for me if Spielberg called for the film rights.

All that said, the idea of some kind of screen cast, webinar, or video coming out of Pathfinder is not out of the question, although I don't see it happening in the near future.

Thanks for the question, Anon!

Sunday, April 13, 2008

Doctor, Doctor, Give Me The News

5 Things About: Doogie Howser, M.D.

Why Doogie? Because the parody at the end of How I Met Your Mother a while back, plus a desire to wander through hulu.com. So I watched the Doogie pilot from 1989. And now I'm writing about it.

  1. I was really not expecting the show to hold up at all. It's actually a pretty solid piece of late 80's TV, despite the cheesy theme music and classic 80's opening sequence.

  2. It's still possibly the most absurd premise that a TV show ever expected the public to take seriously. In the pilot, they work around that through an exceptionally well-crafted script combined with Neil Patrick Harris' talent and likability as Doogie.

  3. I remembered it as just a Stephen Bochco show, but it's actually Bochco and David E. Kelley. Kelley's name wouldn't have meant anything to me at the time, but in retrospect his involvement makes so much sense, it's exactly the kind of quirky drama he would become known for.

  4. Let's take this as a writing challenge. You have one opening scene to make this ridiculous premise believable. Your hero needs to be smart enough for the audience to buy him as a doctor, but not so nerdy or arrogant that it's off-putting. Again, you have one scene. First scene of the pilot: Doogie is taking his driving road test, his mom is in the back seat, and he's clearly nervous and tentative. Until they see an accident on the roadside -- Doogie suddenly is in total control, parking, running up to the accident, ordering cops around and saving a guy's leg. That's the whole show, right there. Corny? A little bit, although Harris' performance blunts that. Effective? Yep.

  5. Another nicely done bit: later, Doogie has the inevitable conflict with an older doctor who thinks he's a smart-ass young whippersnapper. My eyes rolled in anticipation of some scenery chewing, but actually the scene ends pretty quickly from there. The dilemma at this point is: if Doogie is right, then he comes off as kind of an insufferable know-it-all, if he's wrong, it's harder to take him seriously as a doctor. The writers opt for door number three -- events overtake the patient without proving Doogie right or wrong, he has a brief, nice scene with the older doctor, and the potential conflicts about his age are established without being nailed into our heads.

I'm about 100% sure, based on my own memory, that the scripts weren't always this good, but still, the pilot is pretty good.

Sunday, April 06, 2008

I Believeth, I Believeth, Don't Die Tinkerbell...

Battlestar Galactica 4-1 "He That Believeth In Me"

I'm relieved, frankly. Not surprised, exactly. I liked Season 3 more than a lot of people seemed to, and I'm optimistic that Ron Moore and his crew understand what the problems were and how to avoid them. Still, it's good to see the show starting out it's final season with a strong episode.

This was basically the episode I was hoping for, with two extra plusses, and one kind-of minus.

Spoilers Ahead, I suppose

I really liked where they took the Final Four Cylon story. After three seasons of asking "What does it mean to be a human", they inverted it -- what does it mean to be a Cylon? What does it mean if your spouse, or best friend, or your whatever the heck Lee and Kara are, turns out to be Cylon? Does it matter? Should it? Great questions, and I can't think of a previous SF work that's attacked the basic what-is-human question from this angle.

The specific pieces of the storyline were well-done. Anders' nerves about going into combat, Tigh's general Tigh-ness. The bit where the Cylon Raider scans Anders and get's the blip response was very cool.

But what really made the episode was the way that Starbuck's return integrated with the Final Four. Of course everybody would think Starbuck is a Cylon trick -- half the audience thinks so too. In the show, this allowed the characters to all talk about what it would mean to be a Cylon over the uncomfortable glances of the Fantastic Four. A really clever piece of writing structure.

The negative is the Baltar storyline. Not only does this put Baltar back in another situation where he's separated from the rest of the crew and in a place with creepy customs, but the whole thing is way too much like the telepath underground from the final season of Babylon 5 for comfort. (Personally, I wouldn't be surprised if the attack on Baltar was staged to make him stay with the cultists. But then, I'm cynical.)

  • Some great acting work all around -- watch how much of the episode is carried by the reactions of the Fab Four. And James Callis' facial expressions were the most bearable part of the Baltar story.

  • I thought that the tension between Lee and Adama was maybe resolved too quickly given how intense their argument was. I'm assuming the writers have bigger fish to fry.

  • I watched this one on hulu.com, since I don't get Sci-Fi on my cable system, and they pulled out of iTunes. Overall, it wasn't bad. The video quality was worse than the iTunes files but still watchable. The biggest problem was the interspersed commercials -- not that I'm inherently against the commercials, just that they aren't synched right. Two of the breaks came about a second after the actual episode act break and one of them came right in the middle of Baltar being attacked. Annoying.

Friday, April 04, 2008

BDD: Book Driven Development

recipes.jpg(This one is also on the Pathfinder blog, but since it fits in here, I wanted the full text here...)

Jay Fields, who has been posting a very nice sequence of nuts-and-bolts Ruby and Rails guidelines, pauses to talk about creating examples. It's a topic I've wanted to write about here for a while, and this is as good a lead-in as any. Plus, I'm generally interested in how principles of software development apply or don't apply in odd cases, and software being developed specifically for example purposes certainly qualifies as an odd case.

For Professional Ruby On Rails, I knew that I wanted to run a single example application through the book. I had some grand visions of it being a "real" application or at least a real example of coding best practices. For best practices, I think it's pretty good on a method-by-method bases, but has some weaknesses as an entire app, for reasons that I think will become clear.

The first question was exactly what I wanted the sample application to do. On some level, this is a superficial question -- who really cares what the fake app in the book does? At the same time, certain application structures would make it easier or more plausible to discuss certain features. And I had a list of features I wanted to cover -- legacy databases, users and roles, navigation, and graphics. Ideally, the sample app would have some kind of consistency that would make it reasonable to have these features.

In addition, I didn't want it to be a thinly-veiled version of a site that everybody would recognize, and I wanted it to be something that I could type every day for six months without going crazy.

One of my first ideas was to resurrect an old Web 1.0 joke for my killer e-commerce plan: a web-based store for selling and delivering gasoline. But I decided that the gag was a lot less funny with gas in the $3 per gallon range, and I also decided that I didn't want the fake site to be primarily an e-commerce site.

Brainstorming ensued. I almost did a social networking site for pets, but I decided that was too silly, subsequently discovering that there are already a zillion pet social networking sites...

Eventually, I settled on Soups OnLine, a soup recipe-sharing site. It had the advantages of:

  1. Having a data model that could plausibly handle RESTful nested resources (recipe and ingredients)

  2. Having an actual user model.

  3. Being a plausible site, while still being silly enough to keep anybody from taking the whole thing too seriously.

The first problem came up almost immediately -- site design. I felt that a site that was just dull HTML would not be credible or interesting, but at the same time, I didn't really have the time or resources to create a full site design from scratch, nor did I want the book to become about site design. My solution, which I'm not prepared to defend to the death, was to integrate a template from freewebtemplates.com. This kind of sideswipes the whole issue, providing reasonably good-looking site without having to get into the weeds debating CSS minutia.

Over time, the example mutated away from a normal application development process in a few interesting ways.

The nature of the book-writing itself was a strong anti-agile push, in much the same way that any large body of documentation is. Changes in code structure affect the tests, which is fine, but also affect some amount of text in the previous 300 pages, which there's no easy way to find. (As you can read in this post, the issue affected not just me, but also the editors on the book). At least once, a late change in Rails invalidated a helper method I used in an early chapter. Not a big deal, except I also used that helper method to demonstrate a test structure later in the book -- I wound up keeping a shell of the original method redirecting to the new Rails method.

Also, some features that I had hoped to get in, didn't quite get there -- because I ran out of time or because they didn't with the chapter structure. (If you read the book, you'll see some early structures that imply that the app will eventually convert between English and Metric, which I never quite got to.) Again, this is the kind of thing that happens in all the time in real projects, but is hard to smoothly redirect when there's all that pre-existing text describing the earlier plans.

Sometimes, the sample app has more features than a real app would, rather than less. Since the book tries to cover multiple plugins or ways to accomplish things, Soups OnLine wound up with far more plugin load than a normal app would -- a regular app wouldn't normally have RSpec and Shoulda and Dust, or RMagick and MiniMagick and ImageScience. Inevitably some conflicts happened between multiple plugins trying to cover the same space, making the final code somewhat wilder than I'd really like. (If you've read the book and want to experiment with the outstanding code, it's probably easiest to work with around chapter 9, before Globalize and the image plugins are added...)

Ultimately, of course, as Fields concludes, it's the author's fault if the example doesn't help the user understand the issues at hand. It's my job to understand the constraints of the form and still try to present as realistic an application as possible while explaining how to to build similar applications.

Tuesday, April 01, 2008

Book Recommendations

I've been meaning to do this sooner, but, wow time flies...

Here are some brief comments about books I've read so far this year and would recommend. I think I'll pass on doing negative reviews here at the moment, unless I can make a larger point somehow.

Captain's Fury, by Jim Butcher

Book four in the Codex Alera series continues pretty much everything that's enjoyable about the series. I particularly like the way Butcher continues to move the story along, as well as how he's resisted the easy way to manage the hero and his lack of fury powers.

The Dragons of Babel, by Michael Swanwick

So about fourteen years ago, Swanwick published The Iron Dragon's Daughter, which was, I think, the first prominent example of a crossover between common fantasy icons and dystopian SF icons. If I remember correctly (always a dubious assumption) a lot of people (meaning me) weren't quite sure what to make of the weirdness. I don't think The Iron Dragon's Daughter is a great novel -- it's very episodic, for one thing -- but it is one of the most inventive and memorable novels you'll ever read.

The Dragons of Babel is marketed as a sequel, although I don't think there's any particular crossover beyond tone and some place or character names -- I don't remember Iron Dragon's Daughter having much plot to continue. It does however, continue the same tone as the original, a world that freely mixes fantasy elements with ideas from "the real world", and with a certain, say, lack of reverence toward High Fantasy.

The title Babel is a city, somewhat loosely based on the biblical and Mesopotamian myth, but populated with all kinds of fey, including ghouls and their corrupt city alderman leader, underground horse keepers, a mysterious throne with an absent king, guns, spells, and con men.

It's still fairly episodic, but I think it holds together as a coherent story better than Iron Dragon's Daughter, and it'll certainly mess with your head. In a good way. Mostly.

God Save The Fan by Will Leach

Leach is the editor and proprietor of Deadspin, which is the pre-eminent sports blog if you are a certain kind of fan -- irreverent? immature? Dunno, but it's one of my favorite sports web sites, serving up sports news and analysis while not stinting on pictures of drunken, partying quarterbacks.

The book is essentially Leach's attempt to make the Deadspin worldview explicit. (Although only one piece in the book is taken directly from Deadspin, regular readers will recognize many of the running jokes...) It's a collection of essays with the common goal of recovering sports from the people who take them too seriously. It's kind of hit and miss, but the best pieces are worth your time, and Leach has probably my favorite take on the steroid issue -- which is we're sick of it, please stop moralizing over it.

The Invention of Hugo Cabret, by Brian Selznick

I think this book is the longest work to ever win the Caldecott Medal for children's book illustration. Most Caldecott winners are your basic short kids picture books. Selznick has written a 500 page novel, about half of which is told through words, and about half through wordless pictures.

The story takes place in Paris in the 1930s. Hugo Cabret lives alone in the Paris Metro station, winding the clocks through a series of out of sight tunnels, and repairing a mechanical automaton rescued from a fire by his late father. Eventually, he comes to the attention of an elderly man who runs a mechanical toy shop in the station. The early history of French silent film is involved, along with an image you've surely seen of a rocket ship hitting the man in the moon square in the eye.

The pictures carry a lot of the story load, and they are moody and atmospheric without losing clarity -- it's never hard to follow the story, and you can't easily do things like slow zooms in pure text. There's a nice meta twist at the end, too. Definitely track down this unique and interesting book.

Lincoln and Douglas by Allen C. Guelzo

Somehow The Daily Show and The Colbert Report became my main sources for new non-fiction book recommendations (Stewart has almost completely stopped having actors as guests in favor of non-fiction authors, Colbert never really had many actor guests to begin with...). Guelzo was on The Daily Show, since books on the buildup to the Civil War really pack in the ratings.

The book is interesting, if not as dazzling in prose style as your super top-notch non-fiction books. It certainly focused on some areas that were relatively new to me. Notably, how the feud between Douglas and James Buchanan affected the race, and how East Coast Republican leaders didn't really support Lincoln out of the probably-vain hope that Douglas would reveal himself as a Republican. Guelzo also covers the various political pressures that affected Lincoln's message as well.

The interesting "what-if" scenario here is what would have happened had Douglas not chosen to debate Lincoln -- he had not much to gain from the debates as the prohibitive favorite. Absent the fame from the debates, there's no way Lincoln is the nominee in 1860. But absent the questions he had to answer in the debates, Douglas is much more likely to have cobbled together the Southern states into a coalition that could have elected him (adding a Southern VP, possibly). Where it goes from there is anybody's guess, especially since Douglas would have died months after taking office (although absent the debates, his health might have been better...)

The Mirador, by Sarah Monette

Book three in a series. One of those cases where the author settles character situations at the end of a book, then in order to write the next book in the series, she has to roll back some of the plot and character gains. That's what this book feels like -- the three main characters, acting mostly in harmony at the end of the second book, spend a lot of this book rehashing the arguments and conflicts from the last book.

That said, there's a lot in the book that does work. Monette does a nice piece of writers indirection, hiding the identity of an important character for a while. The characters and plot all move forward, maybe reaching new understandings in the end. Still looking forward to the next book.

New Amsterdam, by Elizabeth Bear

I read Bear's first novel (Hammered), thought it was okay, but never went back to the series. Since then, she's jumped her way around several genres, and the description of this one was compelling enough for me to check back in. It's alternate history, the difference point not quite spelled out, but America is still a British colony, and New Amsterdam remained a Dutch colony until the early 19th century when it was given to the British.

Our two lead characters are Sebastian de Ulloa, a centuries old vampire (the book favors "wampyr") and Abigail Irene Garret, a forensic sorcerer. Together they fight crime. Really.

The book is a series of connected short stories that eventually connect enough to roughly form a novel (some, if not all, of the stories were published separately). The early stories are mostly standalone, and have a certain Agatha Christie meets Bram Stoker kind of feel. Later stories build on each other, as both Sebastian and the British Crown find their positions in America become increasingly untenable.

I liked this book for it's atmosphere and for the main characters, I think it would have been even better fully structured as a novel -- I think it might have drawn out the supporting characters a bit more. The mystery elements give the story some texture, but the magical background behind the crimes is a little opaque to the reader... not a problem exactly, just a comment on what kind of mystery story this is. Plus, I'm an easy mark for any novel with the British Crown still ruling America. (If I met Richard Dreyfuss, I'd probably ask him what it was like to work with Harry Turtledove.) I'm hoping for a continuation to this story, and I'll check out some of Bear's other fantasy work in the meantime.

T is for Tresspass by Sue Grafton

Grafton is one of the few really best-selling authors that I read, and one of the things I like about her recent work is that she's been able to avoid having Kinsey Milhone solve the same case over and over again. In this case, the point of view goes back and forth between Kinsey and a sociopathic predator posing as a home nurse, the better to steal large sums of money from the neighborhood elderly recluse.

The mouse in this game sees Kinsey coming from a mile away, and manages to manipulate her into losing her temper and seeming unhinged to any authority figure Kinsey is inclined to consult. That's frustrating for Kinsey, but interesting for me -- I generally like watching the hero have their strengths used against them judo-style. The book is tense, although the actual ending struck me as a bit too easy.

It's also kind of interesting to watch Kinsey's stories, which take place a few months after each other and are therefore still in 1988, increasingly become period pieces. I think Grafton is increasingly referencing current events to make it easy for the reader to remember the time frame, and not wonder why Kinsey doesn't use a cell phone or the internet.

Coming soon: Matthew Hughes Magestrum series. New Lois McMaster Bujold. The third book in John Varley's Mars series. Jim Butcher's latest Dresden novel...

Friday, March 21, 2008

My Favorite Monkeys

New post at Pathfinder on monkey patching.

Monday, March 17, 2008

Beep Repaired

I don't know what this says about me, or anybody else for that matter...

I've been a huge Tom Lehrer fan ever since my 8th Grade Social Studies teacher decided to warp all our minds by playing "That Was the Year That Was" during a reading period. (It was 1985, so it's not like the recording was current or anything...) I was pretty instantly hooked, and a few years later when his albums were re-released on CD, bought them instantly, and have more-or-less memorized them.

I also became aware of the existence of the musical Tom Foolery, a review of Lehrer's songs that had apparently even recorded a cast album somewhere along the line, but not anywhere that coincided with a record shop I ever saw. I had always kind of wondered about it, and about a week ago, sort of randomly popped it into an iTunes search, and was really, really surprised to see the album actually show up. In DRM free iTunes plus, no less.

The album also has 24 reviews of which break down into: a) this isn't Tom Lehrer, b) Tom sings all these songs better, c) when is iTunes going to get real Tom Lehrer, and d) they don't even use the real lyrics, and e) who are these whiney English people pretending to be Tom Lehrer. People seem to be genuinely angered that anybody else would even bother to record Lehrer's songs (in addition to being somewhat confused as to what this recording actually is -- for example, the "wrong" lyrics were actually written by Lehrer for the production...). Oy.

Well, I wasn't about to let 20 some-odd random strangers dissuade me from an album I've been looking for for almost twenty years. Although I did pause for a microsecond or two.

Preparing for disappointment, I downloaded the album.

And you know what, it isn't Tom Lehrer. It's also actually pretty good. All in all, I like Lehrer's syncopated, ironic style better on most of the songs, but it's not true that the English cast sings the songs with no bite. It is true that they have better-trained voices than he does, and that works in favor of some songs and against others. Still, it's nice to hear some songs in character -- "Poisoning Pigeons in the Park" is cute as a duet, and I liked most of the adult lyric additions to "Silent E".

The really dark ballads don't all do as well, but the uptempo songs are great. There are a couple of cases where the accents invalidate a rhyme or two, but overall, I had no problem with these people singing Lehrer's songs. (It was a little weird to hear them using so much of his monologues to introduce the songs...) So, I guess it's Random English Singers 1, Random Internet Commenters 0, at least as I keep score.

One last geeky thing... like a lot of live recordings made for vinyl, the tracks begin with the actual start of the song and end with the introduction to the next song. This is fine in a record album, where you would use the track breaks to find the beginning of the musics, but it's really irritating in an iPod, mix-and-match world, since any song that comes up ends with the introduction to then next song that isn't going to be played. This really bothered me for this album, since the introductions really do need to be tied to their actual songs.

But these were DRM-free songs, and I can be an own-your-media type on occasions, so I took them all into GarageBand and re-split the tracks so that the introductions are on the same tracks as the actual song. Took under an hour, and only that long because I didn't know that GarageBand had a global preference for export quality that was set too low. Much better that way.

Speaking of iPod, mix-and-match worlds, someday I really must introduce my iTunes random playlist generator...

Monday, March 10, 2008

The Average Programming Book

One weird aspect of being a published writer is that you get very little information about sales. You see your own numbers (several months after the fact), but there's no larger context, and no sense of what a reasonable expectation of sales might be.

Which is why I love it when O'Reilly Radar puts up one of their periodic looks at the computer book market. I haven't pored over stat line like this since I collected baseball cards when I was ten.

I'm going to assume you've gone and followed the link, and post some further thoughts, rather than rehash the points already made.

So, the average programming book sold about 1100 copies in 2007. Given the probable distribution, I'd imagine the median is significantly lower, probably under 1000, although I have no way of knowing for sure. Obviously that conflates a lot of things, new books/old books, general books/specific books, but it seems to be a reasonable baseline.

It's not clear what that means for total sales, since I don't have a good sense of how long a particular book is viable. Jython Essentials, which is nobody's idea of a best-seller, is still selling the odd few copies a month, and 2007 was it's sixth calendar year of sales, (it probably just slipped below the 1100/year figure based on 2007).

You might expect that the per-unit total is larger for the larger language markets, but that doesn't seem to be the case. In fact, three of the top ten languages have much lower per-unit figures (Java, C, Visual Basic). Presumably, this is because the larger markets encourage specialized books in a way that, say, the Groovy market doesn't. Yet.

It does seem to be the case that markets whose share is growing have high per-unit sales and vice-versa. This makes sense, especially when you factor in the lag time that publishers operate under. Growth markets result in high sales for the relatively few titles available, then the average gets driven down later on as more players enter the market. (The most interesting counter example is PHP, which maintained a pretty good per-unit sales rate despite an overall drop.)

Quick thoughts:

  • Ruby has the highest per-unit sales rate in 2006 and 2007 (books are placed based on what language the examples are in, so this includes all Rails books). It's still a very strong growth market, though. (But I wonder what the average is if you subtract the two Dave Thomas books...)

  • Python passed Perl, for presumably the first time since ever. That's really weird sounding. If you'd told me when I bought the Pickaxe book in 2001 that six years later Python would outsell Perl, and Ruby would outsell both of them combined... It's weird.

  • If the trendlines come even close to continuing, C# will be the biggest language market in 2008. That seems strange too... but I guess the Microsoft Bubble of Tools is pretty big.

Saturday, March 08, 2008

iPhone SDK

I'm trying to figure out exactly why I'm so psyched by the Apple iPhone SDK announcement. The basic announcement wasn't a surprise, and I don't even own an iPhone. I did, however, dig out my Cocoa programming book and start studying.

Further thoughts:

  • The tools themselves seemed somewhat slicker than what was expected -- a lot of Mac developers were pleasantly surprised that Interface Builder was included (although apparently it's not in the first beta). There was a lot of speculation that the SDK release was delayed over security issues, but it also looks like polishing the tools took some time.

  • The demos were exceptionally well done, a very nice range of choices, and the continual push of how easy it was to make them. The quality of the demo is clearly one of the reasons that I'm excited.

  • As an aside.. say your boss came up to you and said you're going to fly to Cupertino for two weeks to build something in the super-secret iPhone SDK, which you will get to present in a full-on Steve Jobs media event. How many nanoseconds would you need to wait before accepting?

  • Let's see, the iPhone 2.0 comes out the end of June. So... by August 1, it should be the top mobile gaming platform going, right? Those were some seriously cool looking games...

  • The terms were more open than I expected. It's particularly nice that Apple is allowing the developers to set the price. It's particularly nice that they specifically included "free" as a price. They seemed to emphasize that Apple was going to try and get as many apps in front of developers as possible -- I'd take the inclusion of AIM as a demo as a sign that even things that AT&T might not be thrilled with will be allowed.

  • The general sense of the existing indy Mac community is that the 70/30 split is reasonable given what Apple is offering. It'll be interesting to see how the price points play out. (As pointed out by Jens Alfke, the App store model enables an entirely new class of micropayment software)

  • Still a number of questions: how will developers manage limited betas? Will developers be allowed to have the download be free, but have a separate license authorization? What about free but add supported (like Twitteriffic)?

Early line, here's a short list of people or apps off the top of my head I expect greatness from:

  • MobileTwitteriffic, already essentially announced. The trick here will be improving on the web UI.

  • Red Sweater, apparently Daniel is considering porting Black Ink, and maybe MarsEdit.

  • Ambrosia Software. For a really great game -- Sketch Fighter would work...

  • The Desktop Tower Defense guy. The UI would be tricky, though...

  • Somebody to do the killer To-Do list or GTD app. Omni?

  • A really cool doodle/draw program.

I think this is going to be a very fun ride...

Thursday, March 06, 2008

Pathfinder Post: Using Null Objects with ActiveRecord

Enjoy:

http://blogs.pathf.com/agileajax/2008/03/using-the-null.html

Wednesday, March 05, 2008

Cuts Like A Knife

SF Movie Review: Battlestar Galactica: Razor

(Continuing the enlargement of things I write about on this site, and I think this will be the last post containing a disclaimer about topics...)

I'm not sure what this says about me or my relationship to this show, but the following is all true:

  • I bought this DVD the day it came out (I don't get Sci-Fi at the moment...)
  • I then let it sit for three entire months while waiting for the right time to watch it in one sitting.
  • I finally decided that I'd watch it in pieces, so I started it at about 10:45 at night.
  • Got so caught up in it that I watched it all the way through, then read Jacob's incredible TWoP recap before sleep.

The movie is made up of several nested flashback stories (don't even try to use this movie as an introduction to the Galactica universe...), mostly unified by the person of Kendra Shaw, whose official title might be "Highest Ranking Pegasus Officer We Never Saw Before". Shaw arrives on Pegasus about fifteen minutes before the original Cylon attack, and has a front row seat for the craziness hinted at during the first time through the Pegasus story. Later, she becomes Lee Adama's XO, and leads a mission to a mysterious Cylon outpost dating from the first Cylon war. Add in a couple of flashbacks as to what the elder Adama and Cain were doing on the last day of the first war, and you've about got it.

The basic issue with a this movie, which is designed specifically not to be necessary to understand the main story, is for the show to justify it's existence as more than a way to move DVD's at Best Buy. I think it does, not so much at a plot level, but in the way that it deepens the Pegasus story, already one of the show's best storylines.

The Galactica story has always revolved around about three questions, how do you deal with overwhelming loss, how are you supposed to act in the name of survival, and how are you supposed to treat a mortal enemy. Razor encompasses all three. The earlier Pegasus arc was, in some ways, a little too easy -- Cain fits very neatly into the model of Crazy Commanding Officer Who Goes Too Far. By taking us through the all the steps from beginning to end, Razor makes it harder to dismiss Cain as a lunatic -- it explains her actions without excusing them. Kendra Shaw, who pretty much wears a sign at the beginning saying "I'm Not Crazy" gets drawn straight into the heart of it all. As a result, Razor ends up being a very dark story even by Galactica standards.

  • My list of bedrock Galactica questions doesn't include the question of whether the Cylons are human. While that's frequently a topic of discussion on the show, it's clear to me that the creators of the show know the answer to that question... they use the human/robot question as a way of getting at the deeper issues.

  • I liked the subtle ways in which the movie placed itself in the Galactica timeline, the exact number of survivors in the credits places it, plus there were a couple of background references to major events in the last half of season 2.

  • Have they ever mentioned on the show exactly what caused the first Cylon war to end so abruptly? That's a possible plot issue to be dealt with in season 4. Or, I suppose, the on-again, off-again Caprica miniseries.

  • Moore's commentary is very interesting -- as with many other Galactica episodes, this one changed dramatically in editing. Essentially, they turned the entire movie inside out, and what was originally the framing sequence became the ending mission, and the original meat of the movie became the framing sequence.

Monday, March 03, 2008

Using Active Record For Migrations

New post on the pathfinder blog:

Using ActiveRecord to Migrate Legacy Data

Enjoy!

Tuesday, February 26, 2008

Buy My Book! (Please?)

223888 cover_df.pdf (3 pages).jpgThis week, my book Professional Ruby on Rails will be officially released. You can see sample chapters here, and you can buy the book at Amazon (affiliate link).

This book is designed to meet the needs of an intermediate to advanced Ruby on Rails user. The first wave of Rails books could not assume that the user had any pre-existing knowledge of Rails. As a result, they spent a lot of time covering the basics. The target reader for this book is somebody who has already read one of the basic books and now has to apply this knowledge to building a complete web site all the way from conception to deployment.

Written over the summer and fall, all the sample code in the book uses Rails 2.x, specifically including RESTful structures, respond_to, new migrations, cookie-based sessions, and other new features.

The book covers the kinds of tasks that nearly every site needs to handle -- user models, database performance, time zones and internationalization, creating common JavaScript navigation elements, REST web services, and graphics. Where there are commonly used plugins to support those features, the book covers those as well.

In addition to the application itself, there are other parts of the Rails life cycle. The book covers many of these issues including how to manage a Subversion repository, how to use Rake to simplify common tasks, Capistrano for deployment, RailsBench and profiling tools, generators, and plugins.

I wanted to include comprehensive and integrated coverage of automated testing. In addition to a chapter dedicated to advanced testing tools, nearly all of the sample code in the book is presented with its associated tests first. I believe this promotes the use of test-driven development and gives examples of how to test complex Rails code.

I had a lot of fun writing this book. If you are a Rails programmer, this book will improve your programs, and hopefully save you time and effort. If you're interested, please check out the samples, and buy the book. Thanks.

Technorati Tags:,

Sunday, February 24, 2008

10 Print "Favorite Books, 2007"

For my first real non-techy post on this site (I'm a little nervous about that....), here's one of my favorite things to write about -- a list of favorite books that I read in 2007.

All the books on this list were published recently enough to qualify as "new". I also group books in the same series more or less on whim. My tastes... well, they tend toward Fantasy and SF, beyond that, you'll just have to infer from the list.

First up, the honorable mention, all these books are definitely recommended. All links are to Amazon affiliate pages.

Honorable Mention

  • Cursor's Fury, Jim Butcher. This is book three of the Codex Alera series (book four came out in January '08). The series is notable for likable characters, tight plotting, and a very interesting fantasy world based on the Roman empire. This particular book has a well handled reveal of secrets, including clues that had been staring the reader in the face since page one of the first book.

  • Extras, Scott Westerfeld. Book four of Westerfeld's exceptional YA Uglies series. Maybe down a slight notch from the first three, but still an interesting and fun book. Westerfeld has a knack for aligning his SF worlds with the concerns of his YA readers, but the book is also worth reading for adults.

  • First Among Sequels, Jasper Fforde. This one is book five in a series, in this case Fforde's funny and off-the-wall Thursday Next books. It's about fifteen years later, Thursday is still fighting bad guys in and out of books, in this case, she's assisted by two different fictional versions of herself. This series is kind of like what Douglas Adams might have come up with if he had decided to parody the English Lit canon. Only with more croquet, dodoes, vampires, and neanderthals. This book also has a great (read: clever and silly) time travel paradox.

  • Ha'penny, Jo Walton. Much less funny, this is a sequel to Farthing, Walton's alternate history world where the British made peace with Nazi Germany in 1940, ceding the rest of the continent to German control. Like the first book, this is chilling in it's matter-of-factness as Britain increasingly becomes a police state. (There aren't many more disturbing phrases in an alternate history than "President Lindburgh"...).

  • Halting State, Charles Stross. The only non-series book in the entire Honorable Mention list. That's really odd. Near fiction SF that takes off from a daring bank robbery inside a World of Warcraft like virtual game. Moving forward from there, the stakes get much higher, since anybody who can crack the encryption used in the game can do... well, pretty much anything. This was the last book to fall off the final nominee list, it's an excellent, mind-warping SF book. Stross is kind of hit-and-miss, this is one of his hits.

  • The Lies of Locke Lamora & Red Seas Under Red Skies, Scott Lynch. Right up until the actual last book I read in 2007, this was my favorite new author of the year. It's a dark series (projected to seven books) about elaborate con games in an urban fantasy environment. The first one reads like a violent cross between The Sting and China Mieville, the second one start that way, but veers off into a long pirate digression. The first book, on it's own, would probably have squeaked in the nominee list, the second one is a little weaker, but still has its moments.

  • Melusine & The Virtu, Sarah Monette. One novel, published in two parts. Another dark fantasy, an extremely well written mood and character piece about two half-brothers, one a wizard gone insane, the other an assassin turned cat burglar. (Boy, that makes it sound kind of goofy -- it's not.) The book oozes atmosphere.

  • Ragamuffin, Tobias Buckell. Sequel to Crystal Rain, this book opens up the universe and has a much more space-opera feel. Includes a fantastic SF set piece that takes place down the axis line of a cylindrical space-station, involving Newton's second law and machine guns.

Also recommended, to one degree or another:

Always by Nicola Griffith, Heart Shaped Box by Joe Hill, Kusheil's Justice by Jaqueline Carey (last book off the above list), Magic's Child by Justine Larbalestier, The Merchant's War by Charles Stross, Precious Dragon by Liz Williams, The Sharing Knife: Legacy by Lois McMaster Bujold, Sixty Days and Counting by Kim Stanley Robinson, Spook Countryby WIlliam Gibson, The Sons of Heaven by Kage Baker, Soon I Will Be Invincible by Austin Grossman, The Sword Edged Blonde by Alex Bledsoe, and White Night by Jim Butcher

The following books are the actual nominees for whatever mythical award I give out -- my favorite books of the year. This was an excellent year, all of these books are highly recommended.

  • Blindsight, Peter Watts. The essential quote about Watts is from James Nicoll, "Whenever I find my will to live becoming too strong, I read Peter Watts." This is a grim book about the limitations of the human mind -- if you think your mind is actually good at stuff, be prepared to have that idea debunked forcefully. This is a first contact book with a very alien race, but it's completely subversive to the normal ideas of a first contact book. And it has SF vampires.

  • Harry Potter and the Deathly Hallows, J.K, Rowling. Odds are that you've already read this if you have even the slightest interest, either way you're probably not interested in what I have to say about this one. I just wanted to point out that, as a longtime Potter fan and Rowling supporter, I was a little worried that she wouldn't stick the landing. She did -- the book is a very satisfying end to the story.

  • The Last Colony, John Scalzi. Book three of the Old Man's War series, paying off on a series of hints in the earlier books that the surrounding universe is much more complex then originally let on. This book has more of an intrigue/spy feel than the earlier two, which were more military. Scalzi is trying very hard to write SF novels that are accessible to people who don't normally read SF. This does not mean the books are dumbed-down or uninteresting, just that you're actually going to be able to recommend them to more people who will enjoy them.

  • The Name of the Wind, Patrick Rothfuss. This was my favorite new novelist of the year. The funny thing is that I could come up with a list of plot elements that would make this sound like the most derivative thing ever -- it's got a magical university, the kid from nowhere who's the most talented wizard anybody's ever seen, dark forces afoot, the older hero being dragged into the game one more time, takes place in an inn. All that said, the execution of the book is outstanding. The characters are far more interesting then the plain list would suggest, and the sentence by sentence writing is very good.

  • The Queen of Candesce Karl Schroeder. Book Two of Schroeder's Virga series, which takes place on maybe the best SF big object since Ringworld -- a giant, hollow planet, filled inside with atmosphere, and dozens upon dozens of smaller worldlets, the size of small towns and smaller, that spin to create their own gravity. It's a space opera if space had air. This book takes place on a very small, but strange, part of the larger world (the first book was basically an end-to-end tour of the place). The world building is amazingly good, the worldlet that the story takes place on is covered with countries the size of mansions that spend all their time in deep intrigue over centuries-old grudges.

  • Un Lun Dun China Mieville. It seems like this one kind of slipped past a lot of people, maybe they thought it was just another adult writer trying YA because it's a big market. In fact, it's a funny and clever subversive take on Narnia-style other worlds, and it has enough wordplay to qualify it as The Phantom Tollbooth for the 21st century. This is the kind of book where The Chosen One is out of action on page 35, where a character is told that there is a long list of Trials That Must Be Done and says, in effect "I don't have that kind of time, just tell me where the last one is..." You'll never think about fantasy quests in the same way again.

  • The Yiddish Policeman's Union, Michael Chabon. Alternate history novel on the premise that the US saved 4 million European Jews in World War II and housed them in a protected reserve in Sitka, Alaska. Where they settled in and created a unique, Yiddish-based culture. Only now its 2007, and the lease is running out. On top of all that, it's a murder mystery. I was ready to love this book on premise alone, and the book more than lives up to the premise. As an Ashkenazi Jew, Sitka, Alaska is my lost culture, and Chabon makes it seem absolutely real -- I want to see this place as much as I've ever wanted to visit a fictional book. This just became the first novel ever to be nominated for best novel for both the Mystery Writers of America's Edgar Award, and the SF Writers of America's Nebula award. Hands down, my favorite book of the year. Update: My source for the Edgar/Nebula has made a partial correction, pointing out that "Jeffrey Ford's The Girl in the Glass was nominated for the best novel Nebula and won the best paperback original Edgar in 2006". Still, Best Paperback Original is not, I suppose, Best Novel...

Friday, February 22, 2008

Shipping!?

Amazon is now saying that Professional Ruby On Rails is in stock! I haven't seen my copies yet, and I suspect Amazon purchases will actually go out next week, but it's a real page and everything.

The link to purchase is right here.

I've also added a running list of errata and updates. Check back on that every now and then.

Much more on the book over the next week.

Tuesday, February 19, 2008

Lesser Known Test Processes

New post on the Pathfinder site. I had fun writing this one. It's on some lesser known variants of test-driven development.

http://blogs.pathf.com/agileajax/2008/02/lesser-known-te.html

Monday, February 18, 2008

State of the Blog

This is for any intrepid readers out there who have been following this blog for any length of time. Executive summary: this blog should be getting more content (and more varied content) in the future. Really.

Here's the thing. At the moment, I'm trying to maintain the following:

  • This blog
  • Entries on the Pathfinder Agile Ajax Blog.
  • A private blog where I review books and the like.
  • Two Twitter accounts (one for book updates, one for me)
  • Two del.icio.us tags published to blog sidebars.

All of which got neglected during the big book push.

That's clearly an insane amount of stuff to manage, and it was all suffering for it. On top which, dividing blogs between professional and personal/geeky content was not turning out to be pleasant.

That said, I obviously need to continue posting to the Pathfinder blog, what with them paying me and all. So the plan is this:

  • The private blog will no longer be updated. Since it is actually private, I'm pretty much the only person this affects.
  • Some of the topics that I would have posted there will now come here. I'll try to keep a technical focus (or at least a geekfan focus), but I'll be defining that somewhat more broadly.
  • However, issues that fall under Pathfinder's purview (meaning Ruby and Agile topics) will be posted there. I'll continue to add links to those articles on this blog.
  • The twitter account with book updates will no longer be updated -- my "real" account is now the sidebar on this blog.
  • The old del.iciou.us sidebar is also gone. That content will go into the twitter stream.

The goal is 2-3 Twitter updates a day for links or other short thoughts, and 2-3 larger blog articles a week. Fingers crossed on that last one. Stay tuned.

Monday, February 11, 2008

Hey, Free Book Samples!

As I've mentioned here a few times, I have a book coming out, "Professional Ruby on Rails", available later this month.

If you'd like a sneak peek, Wrox has put some samples online as PDF files. You can also just buy the book.

  • Chapter 1 -- This sets up the sample project used in the book, and talks about the new REST features in Rails.

  • Table of Contents -- Take a look at this to see if your favorite topic is covered.

  • Index -- A more detailed way to see if your favorite topic is covered. Also, maybe you collect indexes...

I'm not sure if the publisher plans on adding more sample content -- if so, I'll update this post.