Go as a programmer-friendly language

At my job, I’ve been using a lot of Go lately, and it’s a bit of a mixed bag. Here are my thoughts so far.

Type system

Most languages have either a rich type system or a weak type system. Java attempts to have a rich type system: it’s on the strict side, and it gives you generics and type constraints to deal with it. It also lets you cast things between unrelated interfaces if you think you know better than the compiler. Haskell has a much more advanced type system where you don’t need to specify types on pretty much anything as long as you use types consistently. C++ gives you templates, and template instantiation conveniently uses duck typing.

On the other end of the spectrum, we have dynamic languages that don’t worry about types at all. Lua, Python, Ruby — they have no facility for specifying what type a value must be. And in the middle, Dart has optional typing — you can specify all the type information you want or none at all.

Go does not have any type system advancements like in C++ and Java. It has no facility in its type system for coding without knowing in advance what types you are working with. And there’s no way to escape its strict type system.

Today I was trying to write a series of protocol buffers to a set of files. Each file had a different type of protobuf, and I had a list of protobufs that had to go in each file. In Java, that would have been easy — I have a method that takes a List<? extends Message> and writes each element to a file. How do you do this in Go? Well, the most straightforward way is to copy your array of *foo.MyProtoMessage into an array of proto.Message and — dear god, I just used O(N) extra memory and time to work around a type system, what am I doing with my life? And you investigate a method to method object refactoring just so you can pull a bloody for loop out of a method that can’t handle two types that it should be able to treat identically, and finally, just before you cry yourself to sleep, you remember that you can write a custom iterator and pass in an iterator factory and a length.

2 January 2006

Perhaps the world would have been a better place if we’d originally standardized on date formatting based on a prototypical date. Regardless, that’s not what happened forty years ago. We’ve been using strftime syntax for bloody ages. Diverging from that isn’t doing anyone any favors. The choice of ordering depends on a non-standard time format; they’d have been better off using 2001-02-03T16:05:06-0700.

All warnings are errors

In Go, it is an error, not a warning, to have an unused variable or import. I wanted to comment out one line of code today as a quick test. In order to get that to compile, I had to remove two imports and comment out four other lines of code scattered around the function. Warnings are helpful; making them errors is hostile.

Errors as explicit return values

Go uses multiple return values for error propagation. C does the same, usually. With C, it’s not so bad — you pass in a pointer to the function, and it puts its output in that pointer. If you encounter an error, you return the error value and you’re done.

In Go, you return a default value plus an error value, or the actual return value plus a nil error value. This gets annoying fast, especially since there doesn’t seem to be a convenient way to specify the default value for a type. The problem is that errors aren’t a first-class entity in Go, with proper support. You pretty much never want to return an error plus another value; you want to return an error xor a valid value. But that isn’t a general use case; it’s a use case that’s rather specific to errors. So the designers of Go chose instead to implement a general thing that makes the special case of errors awkward to use.

All in all, Go is an okay language, but it grates on me. It has some nice syntactic ideas, but overall it’s not fun to work with.

Character development in RPGs

By “character development”, I of course mean the process of making your character more powerful or developed. In early Mario games, this doesn’t happen at all. In Deus Ex, you found weapon mods, improved skills, and installed nano-augmentations in your own body as the story progressed. In Final Fantasy IX, you got four coral rings and went to the cliff outside Gizmaluke’s Grotto and killed dragons for a while. In Diablo III, you hurried the fuck up to get to level 70, then ground on forever to get high level equipment drops.

In one of my favorite games, NoX, progression is controlled by limiting the supply of enemies, money, and equipment. You can be extra thorough and reach maximum level several maps early. You can use as few resources as possible for most of the game in order to purchase the best sword in the game at the last vendor — or you can spend every gold piece as soon as you get it, always trying to stay ahead of the game. Except the game doesn’t have enough useful purchaseable items, so if you want to be terribly resource constrained near the end of the game, you’ve probably bought pretty badass equipment recently or just avoided any semblance of exploration.

This is a relatively controlled type of leveling. It tends to result in only one option for difficulty. Better players will complete the game with ease while worse ones will struggle. Rewarding exploration with items and experience can help to make up for low skill levels. Like grinding, it’s the optimal strategy. Unlike grinding, exploration produces finite benefits, which means you have to put more effort into tuning the difficulty and will still end up excluding some players.

I remember in Final Fantasy IX, my party went from level 25 to level 65 in about half an hour, at which point random encounters became an annoyance — my party could crush everything it found. I would have been happy with them if they were rarer, and even happier if the battle intro animation made it clear that I was so much stronger. When I go into boss battles, the bosses get their own groovy intro sequences; when the odds are even more in my favor, why don’t I? And destroying your enemies with extreme overkill is fun sometimes. But when it gets to be every encounter, and you only get to travel fifteen or twenty seconds on the world map between random encounters, something’s wrong. It’s rather realistic, but it throws annoyances at you constantly.

Diablo III takes a much different approach to grinding. Final Fantasy allows it; Diablo III demands it. You replay levels and gain more experience, but the game doesn’t become easier simply because you’re level 60 rather than level 10. Rather, you have access to a wider array of abilities, and the enemies that gave you trouble before are just as tough as they were, kill you in the same number of hits, take the same number of shots to die.

You defeated the Prime Evil! You killed the seven greatest demons and Diablo himself! You did what the assembled hosts of heaven couldn’t! And then you go back to New Tristram and nearly get killed by a pack of shambling corpses. It’s grinding without the satisfaction. The only thing worth grinding for is legendary items that give you special buffs, and even that is boring.

And conversely, if you managed to get to Diablo at level 1, you could take him out. Apparently the correct thing to do when faced with the most fearsome foe of all time is to identify roving adventurers with murky pasts, sit them in a cellar, and keep them there while your assembled armies take care of the problem. Otherwise your problems will just grow uncontrollably. It’s absurd and unsatisfying.

That’s two bad examples of grinding and one example of not grinding. I’ll speculate about how to implement grinding properly next post.

Zelda, sexism, and narrative explanation

Zelda, the princess of Hyrule and the wielder of the Tri-force of Wisdom, is notable for several things. One of the foremost of these is how often she is kidnapped. Some people argue that the frequency of her kidnapping is not indicative of sexism. She rules a country and holds a powerful magic object, both of which are reasons for people to kidnap her.

This sounds reasonable on the surface — she’s kidnapped because of her position, not because of sexism. But only the worst writers make things happen in a story without providing at least some semblance of a reason for it. The objection seems to indicate that a writer can’t include justifications for the story’s sexism. If a story is extolling the virtues of a traditional 1950’s marriage with the associated social roles, and in its universe women are less intelligent than men and naturally better cooks, that doesn’t make it non-sexist; it just means the writer spent some extra time and effort making a consistent story.

The first thing we have to ask is, would the kidnappers most reasonably get what they want by kidnapping Zelda? If not, then it’s crudely written sexism. If kidnapping Zelda would be a smart move for the kidnappers, then they’ve been written as Level 1 Intelligent Characters at least. It’s suggestive that the writers have some skill. But that alone barely starts to stave off sexism.

Our followup questions focus on differential treatment of female victims and characters in general. Are women victimized more than men in the story? Even when victimized (and even more when free and unharmed), are they treated as Level 1 Intelligent Characters rather than plot devices? Are they allowed to plan and to respond to events as any reasonable person in their position would? Or do they spend the entire game waiting for someone to rescue them?

Zelda is at least sometimes depicted as able to fight. She can turn into Sheik, who is pretty stealthy. She’s an adept magic user. She should be able to free herself of most reasonable prisons and assist in freeing herself otherwise. For instance, she seems to have some telepathic abilities; if she trained those, she could coordinate her own prison break and in the meantime continue running her kingdom.

After being kidnapped twice, she should be wise enough to invest in a skilled personal guard and keep them with her at all times. Link can be the captain of her guard. Additionally, finding a body double should be a high priority. Telepathic abilities or intensive training and hand signals would allow her to rule via body double. Or if her magic permits, she could have an illusion of herself in the throne. Body doubles and guards are standard techniques to secure a ruler; someone with the Triforce of Wisdom should come up with the idea in half a second.

Making all your characters Level 1 Intelligent Characters saves you from some types of sexism. It doesn’t save you from all of it. A fictional world might itself be sexist. A Level 1 Intelligent 1950’s Ideal Housewife is not automatically a feminist ideal. Every aspect of the world was put into it by the author. The Clockwork Rocket is a book that contains a fair bit of sexism — but that sexism was placed deliberately, and the author makes sexism and dealing with sexism a central aspect of the story.

In the Dragon Age series, soldiers rape women. This happens in the real world. However, the choice to include this in the Dragon Age world was deliberate. It is not a central point of the plot, as far as I can tell; it merely underlines how callous the soldiers are. It’s an afterthought, no more essential than a villain’s goatee.

What’s even worse is when the sexism built into the world is a pure reflection of the writer’s unthinking biases. Lara Croft being traumatized and nearly raped so we can sympathize with her pain, for instance. Amita in Far Cry 4 has an appearance befitting a model or an actress — I’m sure her long hair never gets in the way when she’s fighting in a storm and never gets caught on brambles she’s sneaking through. Her carefully plucked eyebrows, full lips painted pink, and radiant skin speak of pure practicality. And her lack of scarring shows us clearly how much time she’s spent fighting for her people. This is another type of casual sexism inserted into a game: aside from attire, nearly every woman must look like she just stepped off a runway at a fashion show.

It’s quite difficult for one individual to avoid sexism in one work of appreciable size. It’s much harder for a team to do so, if they’re not coordinating and checking each other’s work. We expect some to leak through. But oftentimes, it feels like nobody even began to try.

“I’m not sexist, I’m an asshole”

I saw a post over at the Daily Dot about a Computer Engineer Barbie book, one that’s totally sexist and doesn’t even pretend to be empowering or to portray Barbie as a capable being.

That’s horrible enough. The comments were another source of grief. In the story, Barbie enlists the help of more experienced developers, who are both male and who insist that they can do the work Barbie is trying to do faster. The story’s reviewer said that that smacked of every time one of her male colleagues talked over her or was otherwise dismissive of her abilities. One commenter, Brandon DuBois, responded:

This part shouldn’t be considered sexism, get over yourself and realize that programmers in general are conceited assholes who think their code is always better than yours (because honestly, after the fact anyone can write something better – if they can’t then nobody learned anything). This happens to all of us :p We also make fun of each others weights, joke about sexual preferences, and ridicule each other in plenty of other ways like making memes or photoshopping pictures each other posts on facebook – doesn’t matter if you’re a man or a woman in this industry, that’s just how most of us act.

Well. DuBois is certainly a conceited asshole. If I were his manager, I’d be sending him to HR on a weekly basis.

This is a common defense. My behavior’s not sexist/racist/classist/ableist; I’m equally shitty to everyone! Except that’s probably not true. DuBois probably treats his female colleagues as if they were less capable and less experienced than his male colleagues. That’s beyond consensual mockery. The fact that his verbal assholery extends to men doesn’t make the content less sexist, homophobic, or fat-phobic, and it doesn’t reassure his colleagues that are female, homosexual, or overweight that he really doesn’t care about those attributes. Quite the opposite.

This is a problem in tech. These people are the problem. They don’t think they’re a problem. They probably don’t care if they are a problem as long as they aren’t getting flak about it. And we need them gone.

My ideal society

I often spend time thinking about how I’d like to have the world arranged — what sort of utopia I might consider acceptable or better. There are many failed utopias and visions of earthly societies that are entirely unworkable, and I’d like to avoid those. But I have some vague ideas that I think might work, assuming we have automation available for pretty much everything. If we get a massive AI construct to run the planet, this is what society we build on top of it.

Living stipend

The first component of my utopia is limiting the domain of capitalism. Today, people must have a job in order to live, to a first approximation. Those who don’t are called lazy, indigent, or shiftless; they live on the sufferance of others, and their lifespans are much shorter than if they had good access to shelter, food, and health care. Basic necessities should not be bought and sold. They should be freely available.

But capitalism gives people directions and goals. It tells people not to stay home all day playing video games and watching television. So luxuries and upgraded versions of basic necessities will require money earned by working. You can get all the food you can eat for free, and it’s of normal quality — better than soylent, certainly. But if you have a hankering for black krims from your favorite vendor at the farmers’ market, that will take money.


So we’ve stated our purpose for keeping capitalism (to keep people doing something productive), and we’ve said how we’re going to accomplish that (all luxuries require money). But what sorts of jobs will people need to go into? I want it to be, pretty much, whatever the hell you want, so long as it’s productive. You need a manager, and you’re expected to be someone else’s manager — your managerial chain will likely be a cycle. Your manager is there to encourage you to stay on track and stay productive. Ideally you’re working on the same or similar projects, but you can switch projects at times, so that’s not guaranteed over time.

Your manager okays projects for you to work on. They have your best interests in mind — you’ll feel more fulfilled if you are making progress on that novel you always wanted to write than if you just stayed home watching Seinfeld reruns for the hundredth day in a row. They won’t knock you for doing anything productive. They’re just there to make sure you aren’t choosing bullshit assignments and ideally to keep you somewhat consistent.

You can switch projects after the first month, if you have come to hate that line of work. You can abandon a project when your manager agrees it’s not going to work out. If you have a compelling new idea that you want to start going after instead of what you’ve been doing, your manager talks to you to make sure that you’re not going to get three months in and then have another idea that leaves this one in the dust, uncompleted — they don’t want you to end up with a series of half-completed projects when you could finish a smaller number and write the ideas down for later.

Walking down the street, you’d likely see a coffee shop with a dozen people working on laptops: it’s the local chapter of the Dystopian Sci-fi/Fantasy Writers Co-op. Above them there’s an office where half the people are working on standing desks and everyone has dual monitors; a trio are working on a sequel to NoX with the help of a couple graphic designers half a continent away, and a team of six are trying to make a third person RPG a bit like a cross between Thief and Wastelands 2. Across the street is a pottery club, and a few blocks away there’s a tailor workshop specializing in SCA garb. Every one of these people is working to make money.

We’ve just largely redefined “work”. Let’s tackle a related concept: the work week. Right now, a “standard” work week is forty hours. Typically, breaks are removed from that number, so you’ve got a nine-hour span, plus travel time, when you’re at work. That takes up five days each week. I would shorten that by one day or shorten each day. You get full wages for working a thirty hour week. I suspect most people would work more than that.


Retirement is a period during which you stop working at a job and wait to die. That has no place in my world. I have nothing against a time in your life when you don’t need to work — technically, I’ve already said that should be your entire life. But there’s a difference between not dying and having a reasonable standard of living.

I’m not sure of the exact ratios, but I would give everyone a pension. Everyone earns X weeks of pension per year of work. Maybe you get to spend half your adult life on pension. Maybe 80%. Maybe a quarter. And you can go on pension at any time, leave it at any time. You’re in control.

Oh, and as for waiting to die? Nope. Death is not appropriate to my world. Suicide should be an option, but aging and dying? No. That’s cruel and inhumane. So a pension is essentially a long paid vacation; you go to work afterward.

There are other reasons to stop working. Pregnancy is a big one. Injury, illness, disability — those entitle a person to an appropriate period of paid leave. I don’t want to allow disabilities in my world, but insofar as they exist, I’m not going to force someone with one to play by the same rules as more able people. Similarly, I’d rather make pregnancy non-invasive, but if I failed at that somehow, nobody will have to work while heavily gravid. And new parent bonding time won’t be optional.

Obvious issues

People can make a good living in my world by being productive. This productivity doesn’t need to supply the products that people are consuming. Who creates those products? That has to be left to a non-human entity capable of high quality manufacturing and farming. Similarly for service jobs — some people might want to be baristas, and I imagine there will be no few chefs, but who wants to haul trash? Even for jobs where some people want to do them, there’s no guarantee that there will be enough workers. This also needs to be automated.

The economic situation is unsustainable. A person can get a full salary for producing the most loathsome sophomoric poetry in my world, and nobody’s going to buy it. We need a source for people’s salaries, and if we want to avoid runaway inflation, we need a money sink of some sort.

Land is a scarce resource, and housing and work space consumes land mass. While this isn’t an issue in the near future, it’s still an eventual problem.

I’m sure there are many other problems, but these are the immediately obvious ones.

Traditional medicine for First Nations people

People from aboriginal American cultures get shat on heavily. To start with, they’re minorities, and not one of those with the dubious luck to be seen as hard-working or intelligent. There is a stereotype of them as indigent drunkards. To make matters worse, they’ve been shoved into narrow tracts of land, and then they’ve been separated legally from the surrounding nations. So they’ve got the worst land around and they can’t even get the same government benefits that neighboring counties do. And recently, there has been a spate of killings targeting these people.

All told, there’s no reason for any aboriginal American to trust any of the white people around.

Recently a story has been popping up in my news feed about an aboriginal American family in Ontario who decided to remove their daughter from leukemia treatments. Leukemia isn’t quite a cured disease, but the kid had very good prospects, something like a 90% chance of long-term remission and survival, with modern medicine. At first, they turned to their culture’s traditional techniques. A court upheld their decision.

When I heard this, I was initially dismayed that a family would kill their daughter this way, and further dismayed that a judge would let them. If they were killing her more directly, surely the judge would intervene. But after talking it over, I realized that this cure would require trusting and depending on white people. I acknowledge that not all white people are actively harming aboriginal Americans, but some are and the rest are mostly not trying to help. In that situation, I would be reluctant to get that assistance for my daughter, even if it meant her death.

But I can’t go before a judge and say that I’d sooner see my child die than rely on a white person to heal her. Conscripting teenagers to get shot to maintain your nation’s autonomy is fine, but giving them a peaceful death for the same goal is somehow beyond the pale. It would get me imprisoned and the child sent off to a set of white foster parents. I could, however, point at “alternative medicine” and say I’m using that. I have no dependency on outside people, and my tribe would have at least some palliatives to ease her passing. Depending on my political goals and mistrust of outsiders who had traditionally and recently had my worst interests in mind, that might be a reasonable course of action.

That was when I first heard what was happening. Indeed, the family was turning to their tribe’s traditional techniques. And I reserved judgment.

Today, it came to light that the family is now using another set of techniques administered by white people in Florida. They’re using vitamin C injections and “cold laser therapy”. This is not a matter of valuing tribal autonomy over the life of one member of the tribe. The same amount of tribal autonomy would be maintained if they had chosen another clinic using real, scientific techniques far from their homeland and traditional oppressors. No, this was a triumph of snake oil over science.

PhDs and publications

I ran across a post from Tim Chevalier of Heroku about grad school. I’m not arguing with most of his points; I agree on opportunity costs, working conditions, and privilege, and we’ve all seen how universities react to accusations of sexual assault. For job prospects, the typical route is to use internships with large companies that do work in the general vein of your research to secure a position before graduating — something he seems not to have understood.

But one thing he said seemed rather off:

In grad school, I never wanted to spend all my waking hours on research, which meant that if I’d graduated, I would have had at most 2 or 3 publications; when I read CVs for tenure-track faculty candidates who were coming to meet with grad students, they had as many as 20 publications straight out of grad school.

Three publications in six years. Three. PhD coursework takes about two years to finish. Assuming he didn’t want to do any research while taking classes, that still leaves four years of grad school in which he would only manage to publish one paper every fifteen months.

If he were working a typical work week, he should be able to produce a publication at least twice a year while not taking classes. That would be eight publications, not three. Apparently, insofar as research is concerned, Chevalier is a solid underachiever. Twenty publications in five to six years is about one every three months — a fair bit of work, and even a bit grueling if you add on classes, but not “a monomaniacal focus on work”. Certainly it would be hard to get that number of publications on algorithms and data structures, but with a focus on engineering instead, that is achievable.

In short, Chevalier left grad school, felt bitter about it — with good reason — and is now determined to find every aspect of it problematic, even though part of the problem was him.

Reversing pronouns as a test for sexism

I recently saw a post deriding the practice of determining whether something is sexist by swapping the gender of all the pronouns — and by extension naively switching genders of everyone involved. I had an immediate negative response to this post — I do use that technique rather frequently and it serves me reasonably well. Then I stopped to think a bit more.

I use gender reversal as a test for how I portray people in media I create. When I’m writing, when I’m blogging, when I’m creating games, I stop every once in a while and think: is this character acting in a way that would be horribly odd if she were a guy? If this had the same gender ratio, but flipped the other way around, would that seem unusual? And those are valuable checks. It’s just a start — I then have to go through the giant set of gendered tropes and ensure I’m avoiding all of the worst and most of the rest — but it’s a useful and fast tool.

How else could you use gender reversal? You can try to apply it to real world decisions. This is immediately problematic because you’re severing the context and replacing it with a much different one. You come up with silly results, like thinking that housing projects for the poor are unfair because rich people don’t need them, or that affirmative action is racist because white people already have good access to education and jobs. These judgments are obviously idiotic once you put them that way, but somehow people never take that simple extra step of talking about context.

Of course, when people do think about context, they typically assume whatever makes them feel good — specifically that equality has already been reached. But that’s a separate issue.

TotalBiscuit and death threats

Prominent youtuber John Bain (aka TotalBiscuit) said recently that the death threats against Anita Sarkeesian are not credible because, and I quote, “she’s still breathing”. That is, he isn’t going to trust that someone intends to kill someone else until they’ve done so. He goes on to say there’s a difference between someone posting on Twitter that they want you dead, and actual murder. My complaints here are about factuality, context, intent, and tone, in that order.

First, factuality. Is it true that death threats are not credible unless the threatened individual is dead? Obviously not. If someone is pointing a gun at you and has just murdered another person, and the gunman is threatening to kill you, that is a credible threat. If someone proves that they have weapons and they know where to find you, and they claim to want to kill you, that threat has less credibility than it would if they also proved that they’ve already killed someone, but it’s still at least somewhat credible. So as a matter of principle, Bain’s statement is incorrect. However, we can take it as hyperbolic.

Bain is, however, ignoring context. Sarkeesian has been getting death threats of the variety Bain disparages for months or years. She is intimately familiar with them. She only recently got a death threat significant enough for her to leave her home. There is obviously a difference in the death threat that motivated that move and the thousands she’s received in the past. This brings us to intent.

Why is Bain talking about this in this manner? Does he honestly believe that someone who has received thousands of death threats in the past without being forced from her home cannot distinguish between something that is a risk to her life and mere (if one can call it that) toxic vitriol? No. Has Bain has studiously avoided investigating the public death threats against Sarkeesian, maintaining a level of ignorance that would be unconscionable in any journalist speaking about this topic? Or is he familiar with them and the level of reaction that they have solicited from Sarkeesian — which consists of lectures, jokes, videos, and reports to Twitter — noticed that this new death threat resulted in a much different reaction, and simply not reached the obvious conclusion that there must be something different about this new death threat? Perhaps Bain is simply convinced that gamers are good people and can’t send credible death threats to anyone, no matter how many Twitter death threats are tossed around. Perhaps he can’t accept the cognitive dissonance between this and the evidence before his eyes and so edits his reality in accordance with his desires and not with reason.

Perhaps he thinks that it’s so rare for someone to make a credible death threat against another, even when that person is one of the more reviled people for a large group, that it’s more likely that Sarkeesian is lying. But as far as I know, Bain has no training in criminal psychology, has not studied the literature, and has no statistical knowledge of the topic. He is a lay person making statements from ignorance and broadcasting them to a hundred thousand followers. This is grossly irresponsible at best.

The other side of intent is the goals he had in mind. What was he trying to do when he made that statement? Quite possibly he hadn’t thought enough about it to have an explicit goal in mind. If he did have a goal, what might it be? The most obvious possibility is simply silencing and discrediting Sarkeesian. After that, his words serve to reassure people who are telling Sarkeesian and other women that they should die. These people are being told that they aren’t hurting anyone, or at least that their actions are having only a minor effect. Adding that to the discrediting effect, it means that people will be even more enthusiastic about harassing Sarkeesian. I don’t think Bain intended to increase harassment, but he did mean to express contempt and incredulity. His word choice reflects that.

At the very least, Bain is guilty of incautious communication and a level of ignorance he wouldn’t accept from anyone else in a similar position. He allows himself this level of ignorance, even with the size of his audience, simply by denying that he’s a journalist. I’m sure that’s an immense comfort to the victims of gamergate.

PSA: Google Inbox can alter your filters

Not sure if you’re going to stick with Google Inbox? Check your filters after switching back.

A common pattern I use in my filters is “to:mailing-list” -> Archive it, Apply label. When I tried out Inbox, I noticed that my labels were a lot less visible than before. I started including those labels (or “bundles”, as they’re calling them) in my inbox. But eventually I decided I didn’t like that — the bundled messages were in arbitrary locations, and I had no indication of which labels had messages and how many. I switched back to GMail.

After a bit, I noticed that a number of messages to a particular mailing list were getting into my inbox. I double-checked my filter and, lo and behold, the relevant filter had been changed! The “Archive it” portion was gone.

So if you’re switching back from Inbox, you may want to double-check your filter options.