Tuesday, August 2, 2016

A Close Reading of Heinlein's The Menace from Earth (part 3)

This essay begins with part 1

Para 3, launch the action

In the third paragraph we finish up exposition, introduce a second main character, and kick-start the plot.

Mornings I attend Tech High and afternoons I study or go flying with Jeff Hardesty--he's my partner--or whenever a tourist ship is in I guide groundhogs. This day the Gripsholm grounded at noon so I went straight from school to American Express.

This wastes no time, does it? My name's Holly, I live in Luna City, there's some guy Jeff, and bam I am off to guide tourists! He feeds you just enough exposition to get you oriented and a bit intrigued ("flying"? on the Moon?), and then he starts the action.

But on a close reading, some things need mention. First, the use of "partner". Today, "partner" has some different connotations than it did when this was published 60 years ago. A millenial reader might suppose that she means a sexual partner, which would be a complete misreading. In 1957, the word connoted only a professional or business partner. The reader might suspect that Holly is inflating some juvenile pastime to adult status, and in the next paragraph she mentions, "Guiding is just temporary (I'm really a spaceship designer)." Clearly she's not actually a spaceship designer at age 15, so this confirms that she's inflating a hobby to adult status. The alert reader will connect that with "partner" reference.

Another reference that falls flat is "American Express". The modern reader's only association with American Express is of a credit card with more restrictions than most. In the 1950s, the American Express office was the traveler's oasis, providing all kinds of services including money transfers from home. Heinlein extrapolated this to the future, so it would be natural for tourists, fresh off the ship, to go first to the American Express office to get money, maps, and hire guides or porters. Sixty years on, if you want cash in a foreign city, you go to an ATM.

Meet The Menace.

Holly is assigned to guide "Miss Brentwood".

"'Holly,'" she repeated. "What a quaint name. Are you really a guide, dear?"

Holly spends a couple of paragraphs mentally dissing "groundhogs" for their ignorance, then

"My license says so," I said briskly and looked her over the way she was looking me over.

So far, so good. But now I think Heinlein loses Holly's voice.

Her face was sort of familiar and I thought perhaps I had seen her picture in one of those society things you see in Earthside magazines--one of the rich playgirls we get too many of. She was almost loathsomely lovely ... nylon skin, soft, wavy silver-blond hair, basic specs about 35-24-34 and enough this and that to make me feel like a matchstick drawing, a low intimate voice and everything necessary to make plainer females think about pacts with the Devil. But I did not feel apprehensive; she was a groundhog and groundhogs don't count.

Sorry, this doesn't sound like the Holly I've already come to know and parts just don't make sense.

First, I literally don't know what Heinlein meant by "society things ... in ... magazines". Articles? Why is Holly reading magazines? She's a busy, active student; the doings of Earthside socialites is about as far from Holly's interests as you can get. Indeed, would anybody be reading "Earthside magazines" in Luna City? Surely it couldn't be economical to ship bales of Vogue or Elle to the Moon? It would be much more credible if Holly remembered this face from a TV show, not from print. This is the first (but not the last) place where the absence of electronic media harms a modern reading. TV was hugely popular in 1957, why didn't Heinlein extrapolate that to Luna?

Next, the remark about "rich playgirls" doesn't fit. It just isn't credible that there would be enough of those for Luna City as a whole, let alone Holly, to have experienced "too many" of them. Plus, "rich playgirls" don't travel alone, they have entourages of agents and gofers, and usually handsome boy-toys. I think this remark is some personal irritation of Heinlein's that he let leak into Holly's voice.

I also don't think Holly would say "loathsomely lovely". Holly is more distanced than that, especially regarding a groundhog. She would use some word to suggest she saw Miss Brentwood as a specimen; or, being a confident youngster, she might be frankly admiring: "she was quite lovely, in a grown-up way".

The phrase "basic specs about 35-24-34" was probably meant to show Holly's engineering bent, but to me it is the kind of joke a male engineer would make. Plus, describing women by their bust-waist-hip measurements has a 1950's ring. I remember it as a commonplace sexism of my youth (in Playboy maybe?), but I don't think people use it any more.

To continue the boring nit-pickery, "everything necessary" is vague. She's already listed pretty much "everything" except—and here is a key exception—Miss Brentwood's clothes! If Holly has any girly-girl genes she would notice clothes. A teenager, realizing she is in the Luna City equivalent of flip-flops and a hoodie next to someone in expensive fashion wear, would feel instant mortification. Holly should have noticed the disparity of clothing even ahead of that in body shapes.

And also, "make plainer females think about pacts with the Devil"—is this something Holly would think? I don't think Holly lumps herself with "females", nor has the deep need to be admired for her looks that would motivate selling one's soul to get them. Her father might have this wry thought (or Heinlein might); but not our 15-year-old nerd.

continue in part 4

A Close Reading of Heinlein's The Menace from Earth (part 2)

This essay begins with part 1

For quoting the story text I use a paragraph style that looks like a typescript. In that text, where Heinlein used an ellipsis, I spell it out as three spaced dots, so: . . . ; then where I've omitted text, I use an ellipsis character,

Opening Paragraph: Meet Holly Jones

Right, then. Let's read the opening paragraph.

My name is Holly Jones and I'm fifteen. I'm very intelligent but it doesn't show, because I look like an underdone angel. Insipid.

First let's talk about what that brief paragraph accomplishes. The words give us some facts, and the tone tells us about the character: she is self-confident and plain-spoken. The phrase "underdone angel" perfectly forms the image of young, pale, blonde person, probably of slight build (certainly not voluptuous, like the swimsuit model on the cover of the book); but the phrase also has a self-deprecatory tone. She doesn't look like an angel, but like an underdone, insipid angel: pale, unfinished, childish. We suspect she has spent time looking in a mirror, feeling sarcastic about nice things her mother said. "An angel, right..."

In short, that's a model of an opening paragraph: It establishes the protagonist's looks and personality. Also, it establishes what Jeff Smith calls the bond of trust between writer and reader: we believe the author knows what he's about, and it will be worth our time to keep reading.

Let's talk about first-person narrative. Beginning writers are advised to avoid it, for a number of good reasons. Here is Heinlein, an experienced writer, using it in the most direct way imaginable. We don't know why Holly has chosen to tell this story. Is she talking to someone? Writing a diary? That's a flaw, according to many editors. "You need to be clear whom the narrator is addressing," says Julie Ann Dawson. Think of Andy Weir's The Martian: he makes it clear just a few lines in that Mark Watney is recording his notes because he expects to die and wants to leave a record.

On the other hand, Heinlein is in pretty good company when he jumps into a first-person narrative with no apology or explanation:

  • Daniel Defoe, Robinson Crusoe: "I was born in the year 1632, in the CIty of York, of a good family, though not of that country, my father being a foreigner of Bremen, who settled first at Hull."
  • Marcel Proust, Swann's Way: "For a long time I used to go to bed early."
  • Gene Wolfe, The Shadow of the Torturer: "It is possible I already had some presentiment of my future."

We never know why those people chose to tell their stories, and we are never told why Holly is telling hers.

Paragraph two: high-density exposition

The second paragraph establishes Holly's milieu.

I was born right here in Luna City, which seems to surprise Earthside types. Actually, I'm third generation; my grandparents pioneered in Site One, where the Memorial is. I live with my parents in Artemis Apartments, the new co-op in Pressure Five, eight hundred feet down near City Hall. But I'm not there much; I'm too busy.

Heinlein's Luna is familiar territory to anyone who's read The Rolling Stones or The Moon Is a Harsh Mistress, but let's read this as if we were new to it. Look at all the information that is conveyed, or clearly implied, by these four sentences.

  • We're on the Moon.
  • The Moon is populated and developed enough to have a "City".
  • The people there have enough of a local culture to hold themselves distinct from "Earthside" types.
  • People have been on the Moon for some decades, based on "third generation"—and "the Memorial" implies something with age to it.
  • The city is expanding: Holly lives in a "new co-op", and "Pressure Five" suggests there are also older Pressures One to Four.
  • The city is organized vertically: City Hall is 800 feet underground.
  • Holly is free to move around (she's not home much) which says a lot about her relationship to her parents.

That's a lot of exposition disposed of very quickly, tossed off in a breathless rush in Holly's voice.

It doesn't really matter, but how old is Luna City? Holly's "third generation" is ambiguous. If it means she's in the third generation of people living on the moon, then we have:

  • Her grandparents come from Earth aged ~20.
  • Her parents are born in Luna and have Holly about age 20.
  • She's 15; thus 35 years since her grandparents began "pioneering".

But it could mean the third generation of people born in Luna. Then her grandparents grew up on the Moon and when they reached adulthood, moved out (from some unspecified first colony) to pioneer Site One. That would add another 20 years, making the total 55. Thirty-five to fifty-five years doesn't seem like a lot of time to build a large, complex underground city. Even if there are natural caverns (which Heinlein mentions later in this story and in other stories in the series), it isn't as simple to grow as a surface city. San Francisco could mushroom in a few years of the Gold Rush, or Oak Ridge could mushroom in a few years of WWII atomic work, because people could create streets just by laying out rows of flags, and throw up frame houses on any bit of flat ground. Creating a multi-level city even in an existing cave means extensive work in pressure suits. Vertical organization needs more sturdy architecture than a framed cottage. Even at Lunar gravity, an 800-foot stack of dwelling layers needs solid support!

Oh well; again, it doesn't affect the at-speed reading experience. The "third generation" reference is enough to establish a feeling of history and Holly's pride in it. On to the next paragraph, where we learn a bit more about our girl protagonist.

continue in part 3

A Close Reading of Heinlein's The Menace from Earth (part 1)

I was looking over a shelf of old paperbacks and pulled out the chunky bulk of Robert Heinlein's The Past Through Tomorrow (subtitled "Future History Stories Complete in One Volume"), an 830-page brick put out by Berkeley Medallion in 1967 (cover price $1.95).

If this tome were in good condition it might be worth a bit on the used market, but it began to fall apart as soon as I opened it. I read most of the stories in it—stories I hadn't looked at or thought about in years—and soon a third of the brittle, browning pages were loose and falling out. So it will have to go in the recycle tub as soon as I have finished this essay.

All of the stories in the collection had the usual Heinlein virtues: tight, clean prose; characters with clear motives; fast-moving linear plots that come to definite conclusions. Some of the stories have dated badly. It should not surprise, really, when a 50-year-old vision of the future can't sustain our credibility today. The Roads Must Roll described a technology that wasn't credible even when fresh. Blowups Happen tried to predict what a failure at atomic power plant would be like before any such plants existed, and Heinlein's guesses were nothing at all like the actuality of Chernobyl or Fukushima. The plot of one of his most famous stories, Requiem, depends on an unbelievable background of rocket pilots flying from one county fair to the next, like the barnstorming pilots of the 1920s. We understand all too well that rockets that can reach Earth orbit will never be small enough or cheap enough for individual ownership, or safe enough to land or take off casually from a suburb, and I couldn't make myself suspend disbelief long enough to enter these stories.

On the other hand, The Black Pits of Luna paints a quite credible picture of a search for a lost child on the Moon's surface. Heinlein worked out what it would be like to walk on the Moon in a space-suit, what the lighting conditions would be, the constraints of limited time and air—in 1947. Nothing we saw broadcast from the Moon by an Apollo mission contradicts this story. Then there's Delilah and the Space Rigger, about the struggle of a competent woman to be accepted by a male work crew, and all the dialog and the attitudes seem depressingly modern.

For me, one story stood out: The Menace from Earth (hereafter, TMFE). It is a classic because it first gave us the unforgettable image of people in a low-gravity world flying like birds. Besides that, it has charming characters, clever dialogue, and gives us a virtual clinic on how to handle the SF-writer's bane, exposition.

When I read TMFE this time, it might as well have been the first time. I could remember having read it before and knew where the plot was going, but all the details were fresh. It was a delightful reading experience; I even got a little sniffly at the ending. "What a fun, warm-hearted, story," I said to myself, and the intention to write an appreciation of it was already half-formed.

I thought to find an online etext of the story so I could link to it and copy from it. However, Heinlein's estate guards its copyrights carefully, and I have not found a free copy. The story is still available in print on the used market, bundled in a collection of the same title. Of course that had to have a cover image of a voluptuous 20-year-old, even though the protagonist says she's 15 in the first sentence.

At the Amazon page for that collection, the "most helpful" review says,

...the title story features annoying teenagers in an annoying romantic plot. The teenagers annoy with their brilliance, and the plot annoys with its story of the girl narrator discovering, after the introduction of a beautiful Earth woman, that her boy friend is really her boyfriend.

What a curmudgeon! Well, it is a rom-com, and this reviewer clearly doesn't like that genre. If you don't like the rom-com genre, you probably won't enjoy deconstructing TMFE either.

The Heinlein Archives

While searching for an etext that I could link to, I made a surprising discovery. If you visit The Heinlein Archives, you can buy, for a very reasonable fee, PDF copies of Heinlein's original manuscripts!

Yup, for $3 I bought Opus 126, described correctly as 'numerous drafts of “Menace From Earth” all with extensive hand-edits and cuts'. Who'd have thunk it! For three bucks, I could browse Robert Heinlein's MSS pages, complete with hand-edits, which were indeed very extensive. There's a place in, I think, Grumbles from the Grave where Heinlein claimed that once he got the idea for a story, his only problem was "typing fast enough to keep up with what the characters are doing", or words to that effect. Well, maybe that's how he wrote a first draft, but look at this:

Look fast and casual to you? No, me neither. I probably edit my work that much, too, but on-screen editing doesn't leave a trace. This is what a professional's work looked like in the days of typewriter MSS. And every word clearly was considered multiple times.

Reading The Menace from Earth

My first, fast read of TMFE was a pleasure. However, now I have begun to reread the story critically, I have noticed a number of things that are not perfect: dated usages that a modern reader (i.e. one half my age or less) would not catch, or might even misunderstand; as well as some dated attitudes. So the rest of this essay does not consist of unalloyed RAH! RAH! fanboyism. (See what I did there?) (All right, never mind.)

Shortly I will begin to read this story carefully. I mean to quote quite a lot of it—looking over my shoulder for the Heinlein copyright wardens, but I think I've stayed in fair-use bounds—just the same, if you can find a copy and read it straight through first, that would be a good idea.

continue in part 2

Friday, July 1, 2016

OK Maybe I Was A Little Bit Premature

"And now for something completely different..." I said, and then...

Coming.

Real Soon Now.

Tuesday, June 14, 2016

And Now For Something Completely Different

For a couple of years, this blog has been totally focused on my adventures with Python, Qt, and PyQt as I developed a major-ish app, PPQT2.

Well, with the latest round of fixes (see two prior posts) I believe that PPQT2 is about as done as it can be. I will leave the distribution files up indefinitely. But I don't intend to add any function, and I don't believe it contains any bugs serious enough to prevent its productive use. A couple of people are using PPQT2, and I wish them well. I am not among them, because I no longer spend any of my own time editing books for Distributed Proofreaders. The first PPQT was done to meet my own requirements for a book editor. The second one was done, really, to do the job right from a software engineering standpoint, and to meet the evolving needs of the Distributed Proofreading community. It succeeded in the first goal, but, based on limited uptake, failed to meet the second. So it goes.

Back to Authorship

A decade ago I wrote a book. Well, I've written several books over the years, mostly software. But that latest book was not about software. It was in a way, an extended answer to a question my mother asked me a few months before she died. I wrote the book and self-published it.

You can read about the book at its home website. In fact, you can read the whole book online there if you wish. Or you can follow links from there to buy your very own hard-copy for a very reasonable fee.

Don't do that!

Well, you can read it if you really want to. But don't order a copy (not that you were likely to do so, but still).

Why? Because I've embarked on a major revision, is why.

Adam Osborne is famous for killing his company by pre-announcing a better model before it was ready to ship. Sales of the existing Osborne computer dried up, choking off the cash flow that he needed to finish development. I'm not afraid of killing sales for my existing book because mostly, it has none to kill.

But why am I doing a revision? What improvements do I mean to make? How am I going about it?

Such questions will be the focus of forthcoming posts in this blog. In the meantime, if you want to get an early look, go to the new publishing site, slide the "You Pay" slider all the way to the left, to a cost of $0.00, and "buy" a copy of the book as it stands. If you give leanpub your email in that process, you'll get a notification as new versions are published, which is about monthly as I add chapters.

Friday, June 10, 2016

Fixing the Edit Menu Fix

A year and a half ago, I wrote an incomplete description of my solution for separate edit menus. While using PPQT2 in Windows 7 to test the logging/dictionary bug, I noticed a problem with this system and fixed it.

To review, under Qt there is a single menu bar that is owned by the main window. (The main window is a parentless widget based on the QMainWindow class.) In the menu bar there can be just one Edit menu.

In the Qt system, any menu is populated by QAction objects. In the Edit menu, if there is, say, a "Cut" item, it is installed in the menu by adding a QAction('Cut'). Any QAction has four properties:

  • A name string, like 'Cut'
  • An optional icon
  • An optional accelerator keystroke, like control-x
  • A "slot", which is an executable

The slot is the important item. It is a function that receives the "triggered" signal when the user selects that menu item or keys that accelerator.

This is a fine system, provided that there is no ambiguity about which slot to call. In an app with a simple UI, the one main window perhaps, the slot for File:Save or Edit:Cut is a method of the QMainWindow object, or of some sub-widget that it owns, and that never changes.

In PPQT2, there are multiple different widgets that can implement Edit actions. In the simplest case, the user has a single book open. But there is an Edit panel with the book text, a Notes panel with a separate simple document to edit, and a Words panel which supports copying selected words from a table. If the focus is in the Edit panel, we want the Edit:Cut action to be implemented by the cut() method of the QPlainTextEdit object that is part of that panel. But if the focus is in the Notes panel, we want Edit:Cut to be implemented by the cut() method that is part of the QPlainTextEdit object that is part of that panel. And if the focus is in the Words panel, we don't want to implement Edit:Cut at all, but we do want to support Edit:Copy via a method of the QTableView that implements the vocabulary table.

Worse: if the user has two or three books open, each book has its own Edit, Notes and Words panels. When the user hits control-x, it is important that the cut be implemented by the Edit or Notes panel for the book that is in front -- not by some panel containing the text of a different book that isn't visible.

The only solution is to continually change out the actions in the one-and-only Edit menu whenever the focus changes. When the Notes panel gets focus, it loads the Edit menu with the set of actions it supports, including slots that are methods of that unique Notes widget (distinguished by the "self" parameter). The code to do this, before this week, was as follows:

def set_up_edit_menu( action_list ) :
    global _EDIT_MENU, _LAST_MENU

    _EDIT_MENU.setEnabled(True)
    if id( action_list ) != _LAST_MENU :
        _LAST_MENU = id( action_list )
        _EDIT_MENU.clear()
        for (title, slot, key) in action_list :
            if title is None :
                _EDIT_MENU.addSeparator()
            else :
                _EDIT_MENU.addAction(title, slot, key)
def hide_edit_menu():
    global _EDIT_MENU
    _EDIT_MENU.setEnabled(False)

Any widget that wanted to support the edit menu had to do three things. It had to set up a list of Edit menu actions it supported, including the title, the slot, and a key code for each. It had to catch the focus-in event and call set_up_edit_menu() with that list. It had to catch the focus-out event and call hide_edit_menu(). As a result the Edit menu would be disabled (grayed-out) whenever focus was in a widget that didn't support it. When focus entered a widget that did support the Edit menu, it would be enabled and populated with that widget's actions, including references to that widget's slots.

I observed that it was quite frequent for a widget to get a focus-out followed by a focus-in, with no intervening visit to another widget. That's why the work of changing the menu is only done if the id() of the list is different. The Python id() of an object is basically its memory address. In my first description of this code, I was requiring the caller to pass a unique key, but I soon figured out that was not needed; id() did the job.

This all worked fine under Mac OS. Unfortunately I'd never really checked that it worked under Windows or Linux. This week I noticed that it did not. (imagine a blushing embarrassed emoji here)

In Windows and under Ubuntu Unity at least, the Edit menu was disabled, grayed-out, all the time! Why?!? The contents of the menu were changing properly, for example when focus was in the Edit panel, the menu contained the to-Upper and to-Lower actions that only the Edit panel supports. They went away when the focus moved to the Notes panel. So set_up_edit_menu() was being called. Which meant _Edit_MENU.setEnabled(True) was being executed.

It took a good half-hour of swearing and inserting print() statements before I realized that hide_edit_menu() was being called when I clicked on the word Edit in the menu bar. (imagine an open-mouth amazed emoji)

It seems that in Windows (and in Ubuntu, I later found out), a click anywhere in the menu bar causes a change of focus! You click in the Edit panel; the focus-in event calls set_up_edit_menu(). You click on the word Edit in the menu bar and the Edit panel gets a focus-out event and immediately calls hide_edit_menu(). It's a beautiful catch-22: the menu is enabled all the time until you try to use the menu, then it is disabled.

It took some pondering to figure out how to fix this. My solution was to ask, in hide_edit_menu(), if the current mouse location was within the global menu bar. If so, do not disable the menu. Here's the new code:

def hide_edit_menu():
    global _EDIT_MENU, _MENU_BAR
    
    if not C.PLATFORM_IS_MAC :
        relative_cursor_pos = _MENU_BAR.mapFromGlobal( QCursor.pos() )
        if _MENU_BAR.geometry().contains( relative_cursor_pos ) :
            return
    # either this is Mac OS, or the cursor is not over the menu bar
    _EDIT_MENU.setEnabled(False)

That made the Edit menu behave the way I wanted in all three systems.

A Logging problem in Windows -- and a pivot!

This is the first of a few posts about PPQT2, the hobby software project that's been the focus of the blog for two years. Then there will be a post announcing a turn to something completely different.

This week I had to deal with a reported bug in PPQT -- note, the first one in six months or more, which is more a reflection of its very low usage than on its code quality -- and found a couple other things that needed work.

Dictionary bug

The bug was present on all platforms, but was only visible on Windows. Here's the problem. The user opens a file that contains some non-Latin-1 characters, maybe some words in Greek. The default dictionary is set to en_US and the Greek words are not tagged for an alternate dict. So when the user refreshes the Words panel, every Greek word gets presented to a Hunspell object initialized with the en_US dict.

The encoding of any dict is specified in its name.aff file. The en_US dict is encoded ISO8859-1, and Hunspell expects any word checked against it to be encoded the same. Obviously a Greek word will have non-Latin characters, and Hunspell will correctly suffer an encoding error.

Not a problem! I was ready for this:

            try :
                return dict_to_use.spell(word)
            except UnicodeError as UE :
                dictionaries_logger.error("error encoding spelling word {}".format(word))
                return False

However, in Windows the call to the logger .error() itself raised an encoding error! Because the logged string contained the offending Greek word, and the log file had been opened using the default encoding which in Windows, was some wonky code page that couldn't encode Greek.

So there was an exception raised in the Except block, and the return False to indicate misspelling was never executed. But that did not cause a problem! Because the caller used the return value in an if statement, if check(word):. After Python displayed the traceback in the console window, it resumed execution in the calling function with the conventional default return value of None. None is just as False as False is, so everything worked, except for a ton of error messages in the console window.

The fix was to go back to the top-level module where I set up the logging handler for the whole program, and add encoding='UTF-8' to that call. A one-line fix and the error messages disappeared.