Then something only vaguely like a human face filled the screens, its features stretched across asymmetrical expanses of bone like some obscene Mercator projection

(Department of “You were promised an oppressive cyberpunk dystopia”)

Still officially offline, but: while I was off in East Thrace the server that hosted chrononaut.org was hit by something, for the second time in a few weeks, and to save ongoing headaches for myself and for Brandon, who gets the complaints from the hosting company when people complain that chrononaut.org/discontent.com is attacking them with zombie botnets, I decided it was time after fifteen years to get out of the business of being my own webmaster and move this site to WordPress.com.

As you can see it’s still a work in progress—moving all the posts from my most recent WordPress installation (ca. 5 years ago) was pretty quick but the links and images are still mostly broken and there’s still the archives from my two earlier blog incarnations that need to be converted from flat files into something WordPress can import, but I hope to have that done in a week or two. I’m afraid the permalinks I went to so much trouble to preserve when I went off MoveableType are no longer perma-, but at least all the posts should be there.

We now return you to your regularly scheduled no programming.

 

Won’t someone think of the insensitives?

Every time sexual harassment at conventions comes up, somebody trots out the red herring that it’s just too hard for certain persons to know when they’re being polite and when they’re being rude, and it’s just unfair to ask these poor insensitive people to read the fickle minds of the lovely mysterious creatures they’re attracted to.

To which I say, with as much respect as I can muster: Please fuck off.

Sensitivity can be learned. Manners can be learned. Manners in fandom are not, much as some fans like to pretend otherwise, significantly different from manners outside it. Erring on the side of being a shy violet because you’re afraid of giving offense may cause you to miss out on a sexual opportunity or two over the years, but if it also causes you to miss out on even one occasion of putting some other person (who, we hope, you’re well-disposed toward, right?) in fear and ruining their convention, then it’s a public service and well worth the sacrifice.

There are people in the world who are physically and mentally incapable of learning to tell the difference between courtesy and rudeness but as a proportion their number is vanishingly small, even in fandom, despite what some self-serving fans like to pretend. And even if it weren’t, their right to hit on people does not come close to trumping the right of other people not to be sexually harrassed.

(Please don’t anyone say “What about the Aspies?” which is usually where this goes next. The autistics and the folks with Asperger’s syndrome that I know are too polite to punch you but that won’t stop me wanting to and my blood pressure doesn’t need it this week, for reasons completely unrelated to SFWA.)

(I know this isn’t a new sentiment and I’m sure it’s been put better by other folks, and recently, but it wasn’t being said in certain venues. So I posted there, and I’m reposting here.)

More on Builders, or, favor immutability

A while back I posted a basic Builder example on Stack Overflow. User Marcel Stör complained:

Problem with this approach is that you need to define all the members twice, once in the builder and once in the actual class. [This answer] shows how this can be avoided. With that other approach, however, you cannot have final members although the object itself is still immutable.

Marcel Stör

Well, I looked at that answer, from user Yishai, and I didn’t like it.

I don’t know, I’m not a fan of that approach — the builder’s not reusable, it’s not thread-safe, and you can’t design the build product class to guarantee it’s fully initialized at construction. If I was really worried about DRY, I’d probably use an immutable (copy-on-write) builder and make the last builder instance double as the build product’s immutable data.

David Moles

After I wrote that, I thought I should put some code where my mouth was. So: here’s the original version (more or less), with the fields declared in both the Builder and its product, the Widget:

public class Widget implements IWidget
{
    public static class Builder implements IWidgetBuilder<Widget>
    {
        private String name;
        private String model;
        private String upc;
        private double price;
        private Manufacturer manufacturer;

        public Builder ( String name, double price )
        {
            this.name = name;
            this.price = price;
        }

        @Override
        public Widget build ()
        {
            Widget product = new Widget( this );
            validate( product );
            return product;
        }

        @Override
        public Builder manufacturer ( Manufacturer value )
        {
            this.manufacturer = value;
            return this;
        }

        @Override
        public Builder upc ( String value )
        {
            this.upc = value;
            return this;
        }

        @Override
        public Builder model ( String value )
        {
            this.model = value;
            return this;
        }

        private static void validate ( Widget product )
        {
            assert product.getName() != null : "Product must have a name";
            assert product.getPrice() >= 0 : "Product price cannot be negative";
            Manufacturer mfgr = product.getManufacturer();
            if ( mfgr != null )
            {
                String upc = product.getUpc();
                assert upc != null;
                assert upc.startsWith( mfgr.getCode() ) : "Product UPC does not match manufacturer";
            }
        }
    }

    private final String name;
    private final String model;
    private final String upc;
    private final double price;
    private final Manufacturer manufacturer;

    /**
     * Creates an immutable widget instance.
     */
    private Widget ( Builder b )
    {
        this.name = b.name;
        this.price = b.price;
        this.model = b.model;
        this.upc = b.upc;
        this.manufacturer = b.manufacturer;
    }

    public Manufacturer getManufacturer ()
    {
        return manufacturer;
    }

    public String getModel ()
    {
        return model;
    }

    public String getName ()
    {
        return name;
    }

    public double getPrice ()
    {
        return price;
    }

    public String getUpc ()
    {
        return upc;
    }
}

And here’s the new version: the fields are only declared in the Builder, and they’re always final. The Builder itself is immutable, using a copy-on-write pattern, and the last Builder instance becomes the state of the Widget it produces.

public class Widget2 implements IWidget
{
    public static class Builder implements IWidgetBuilder<Widget2>
    {
        private final String name;
        private final String model;
        private final String upc;
        private final double price;
        private final Manufacturer manufacturer;

        public Builder ( String name, double price )
        {
            this( name, null, null, price, null );
        }

        private Builder ( String name, String model, String upc, double price, Manufacturer manufacturer )
        {
            this.manufacturer = manufacturer;
            this.model = model;
            this.name = name;
            this.price = price;
            this.upc = upc;
        }

        public Widget2 build ()
        {
            Widget2 product = new Widget2( this );
            validate( product );
            return product;
        }

        public Builder manufacturer ( Manufacturer value )
        {
            return new Builder( this.name, this.model, this.upc, this.price, value );
        }

        public Builder upc ( String value )
        {
            return new Builder( this.name, this.model, value, this.price, this.manufacturer );
        }

        public Builder model ( String value )
        {
            return new Builder( this.name, value, this.upc, this.price, this.manufacturer );
        }

        private static void validate ( Widget2 product )
        {
            assert product.getName() != null : "Product must have a name";
            assert product.getPrice() >= 0 : "Product price cannot be negative";
            Manufacturer mfgr = product.getManufacturer();
            if ( mfgr != null )
            {
                String upc = product.getUpc();
                assert upc != null;
                assert upc.startsWith( mfgr.getCode() ) : "Product UPC does not match manufacturer";
            }
        }

    }

    private final Builder b;

    /**
     * Creates an immutable widget instance.
     */
    private Widget2 ( Builder b )
    {
        this.b = b;
    }

    @Override
    public Manufacturer getManufacturer ()
    {
        return b.manufacturer;
    }

    @Override
    public String getModel ()
    {
        return b.model;
    }

    @Override
    public String getName ()
    {
        return b.name;
    }

    @Override
    public double getPrice ()
    {
        return b.price;
    }

    @Override
    public String getUpc ()
    {
        return b.upc;
    }
}

Voilà, DRY. Sadly, it only ends up one line shorter (thanks to the extra Builder constructor), but at least it doesn’t define anything twice!

Subclassing with Bloch’s Builder pattern, revised

So last year I posted about using Joshua Bloch’s Builder pattern to create objects from a hierarchy of subclasses.

I realized later that while I did have something like this completely working at one point, I had it working in C#, which has deceptively different generic semantics. (It also has named parameters, which makes the Builder pattern a fair bit less necessary.) As Zdenek Henek demonstrated (several weeks ago, sorry Zdenek!), in Java, the original version I posted doesn’t allow you to call the arguments in any order.

This one does:

class Shape
{
    private final double opacity;

    public double getOpacity ()
    {
        return opacity;
    }

    public static abstract class ShapeBuilder<S extends Shape, B extends ShapeBuilder<S, B>>
    {

        private double opacity;

        @SuppressWarnings( "unchecked" )
        public B opacity ( double opacity )
        {
            this.opacity = opacity;
            return (B) this;
        }

        public abstract S build ();
    }

    private static class DefaultShapeBuilder extends ShapeBuilder<Shape, DefaultShapeBuilder>
    {
        @Override
        public Shape build ()
        {
            return new Shape( this );
        }
    }

    public static ShapeBuilder<?, ?> builder ()
    {
        return new DefaultShapeBuilder();
    }

    protected Shape ( ShapeBuilder<?, ?> builder )
    {
        this.opacity = builder.opacity;
    }
}

class Rectangle extends Shape
{

    private final double height;
    private final double width;

    public double getHeight ()
    {
        return height;
    }

    public double getWidth ()
    {
        return width;
    }

    public static abstract class RectangleBuilder<S extends Rectangle, B extends RectangleBuilder<S, B>> extends ShapeBuilder<S, B>
    {
        private double height;
        private double width;

        @SuppressWarnings( "unchecked" )
        public B height ( double height )
        {
            this.height = height;
            return (B) this;
        }

        @SuppressWarnings( "unchecked" )
        public B width ( double width )
        {
            this.width = width;
            return (B) this;
        }
    }

    public static RectangleBuilder<?, ?> builder ()
    {
        return new DefaultRectangleBuilder();
    }

    protected Rectangle ( RectangleBuilder<?, ?> builder )
    {
        super( builder );
        this.height = builder.height;
        this.width = builder.width;
    }

    private static class DefaultRectangleBuilder extends RectangleBuilder<Rectangle, DefaultRectangleBuilder>
    {
        @Override
        public Rectangle build ()
        {
            return new Rectangle( this );
        }
    }
}

class RotatedRectangle extends Rectangle
{
    private final double theta;

    public double getTheta ()
    {
        return theta;
    }

    public static abstract class RotatedRectangleBuilder<S extends RotatedRectangle, B extends RotatedRectangleBuilder<S, B>> extends Rectangle.RectangleBuilder<S, B>
    {
        private double theta;

        @SuppressWarnings( "Unchecked" )
        public B theta ( double theta )
        {
            this.theta = theta;
            return (B) this;
        }
    }

    public static RotatedRectangleBuilder<?, ?> builder ()
    {
        return new DefaultRotatedRectangleBuilder();
    }

    protected RotatedRectangle ( RotatedRectangleBuilder<?, ?> builder )
    {
        super( builder );
        this.theta = builder.theta;
    }

    private static class DefaultRotatedRectangleBuilder extends RotatedRectangleBuilder<RotatedRectangle, DefaultRotatedRectangleBuilder>
    {
        @Override
        public RotatedRectangle build ()
        {
            return new RotatedRectangle( this );
        }
    }
}

class BuilderTest
{
    public static void main ( String[] args )
    {
        RotatedRectangle rotatedRectangle = RotatedRectangle.builder()
                .theta( Math.PI / 2 )
                .width( 640 )
                .height( 400 )
                .height( 400 )
                .opacity( 0.5d )
                .width( 111 )
                .opacity( 0.5d )
                .width( 222 )
                .height( 400 )
                .width( 640 )
                .width( 640 )
                .build();
        System.out.println( rotatedRectangle.getTheta() );
        System.out.println( rotatedRectangle.getWidth() );
        System.out.println( rotatedRectangle.getHeight() );
        System.out.println( rotatedRectangle.getOpacity() );
    }
}

Note though it requires some unchecked casts, and depends on the convention that each Builder’s generics are self-referential, which could present some risk if it’s extended further. Test early, test often.

To commit a war crime, press one. To commit a crime against humanity, press two. To be uncharacteristically gullible, press three.

From the earliest Mass Effect marketing to the latest attempts to pour oil on the waters of fan-anger, Bioware has made a big deal out of the game’s supposed hard choices. And they did a good job of making those choices feel hard, in the moment; or anyway risky. But they weren’t, really. If you played the game conscientiously and made sure your options were open you could make the right choice, every time, be sure that you were doing the right thing — or if not sure you were doing the right thing, at least sure you’d rather be wrong your way than the way of the people arguing against you; that you’d happily roll the dice, take your chances, and if it turned out you’d made the wrong choice, deal with the consequences.

You never did, though. The game always let you have your Krogan birthday cake and eat it, too.

So I can see why fans haven’t been entirely happy with the three choices Bioware gives you at the end of Mass Effect 3.

  • To kill an innocent friend, commit genocide against a loyal ally, save the galaxy, and live happily ever after, turn to page 63.
  • To die heroically achieving the goals you’ve shot your greatest enemies for trying to achieve, on the word of another enemy that it’ll save the galaxy and not play into that enemy’s hands in any way at all, we promise, turn to page 57.
  • To die heroically committing the worst crime imaginable against freedom of choice, bodily autonomy, and a good six or seven out of ten of Martha Nussbaum’s ten central capabilities, again on the word of an enemy that it’ll save the galaxy, and that achieving that enemy’s goals is what you really want — honest — despite having proven by your own actions earlier in the game that the enemy’s central thesis is bullshit — turn to page 60.

I chose page 63, as the least out of character of the three options. And since it turns out the murders you’re committing by making that choice don’t actually appear on the screen, you’re free to believe they never happened, and the enemy who told you the consequences of your choice was lying. But I suspect that, canonically, we’ll find out that they did happen. Or — more likely, since it’s harder to get — that page 60 was supposed to be the happy ending. Either way, I don’t really see playing any more Mass Effect games.

Which is a shame, because there was some good stuff in there, on a small scale. But the large scale never really made a lot of sense, and increasingly less (ME2 final boss fight, anyone?) as the series went on; and by the end it was all about the large scale.

I’m not saying none of these endings could be done, and done well, even the bleakest — see The Centauri Device, or Blood Music, or The Urth of the New Sun. But as talented as the Bioware team is, they’re not M. John Harrison nor Greg Bear nor Gene Wolfe, and what they do well isn’t cosmic consequence, it’s character. So I’m not surprised they wrote themselves into a corner they couldn’t gracefully get out of; it was clear early on (“You cannot grasp the nature of our existence!”) that the ending was never going to be all that intellectually satisfying. But I don’t think it was inevitable that the last ten minutes be a different game — and a different genre — from the previous hundred hours of the series.

المترجم

The bad news is I still default to writing about depressive loners. The good news is I can now write about depressive loners in multiple languages.

المترجم

قد أصبح المترجم وحيد ببطء. خدع وحده. قد فضل المترجم دائما الفلسفة على الترجمة، ولكن الآن فضل حقا التلفزة أكثر من كلهما. كان عندهم زورق صغير وأزرق الذي لم يستخدمه. قد تمتعوا المترجم وزوجتهم بالتزلج على الماء. الأن دهب نادرا قريب من البحر. في الصباح تفرج على كرة اليد وبعد الضهر تفرج على تنس الطاولة. نام كثيرا. كان المترجم سعيد رسميا.

The Translator

The translator had become alone slowly. He deceived himself. The translator had always preferred philosophy to translation but now, in truth, he preferred television over either. He had a small blue boat that he never used. The translator and his wife had enjoyed water-skiing. Now he rarely went near the ocean. In the morning he watched handball and in the evening he watched table-tennis. He slept a lot. Officially, the translator was happy.

(Fifty extra points if you can guess what part of speech we’re learning this chapter. Two hundred and fifty if you can guess the subject of this chapter’s text.)