May 7, 2013

A Statement from Adria Richards

Having remained silent since PyCon, Adria Richards has now published a statement reflecting on those events, though sensibly without going into specifics. I think it's important that her retrospective view gets some air, so I am reproducing it here with my own comments.

Those who know me well in the the developer and tech community recognize that I have always tried to conduct myself in a way that builds bridges for everyone. My central aim is to do everything I can to help create new, inclusive inroads for all, no matter who they are, where they come from or what they believe. Development is about innovation, creativity, and in a grand sense, the betterment of human society through technology. So, it stands to reason that everyone should have a seat at the table, and everyone involved in this vital community should feel welcome, safe and respected. In essence, the worldwide community of developers can and should function as a reflection of what our wider society strives to be.
I don't know Adria, so I take her opening statement at face value. Those who disagree may do so elsewhere. Garann Means recently made a fairly good case that the denizens of the technology world don't act in a way that inspires respect from other communities. I think it's fair to say (and some of the comments in forums like Hacker News amply demonstrate) that there is plenty of room for improvement in what's considered acceptable conduct in the technology world.
I cannot comment at this time on the specifics of what occurred at PyCon on March 17, and the subsequent events of the following days, but I can offer some general thoughts. I don’t think anyone who was part of what happened at PyCon that day could possibly have imagined how this issue would have exploded into the public consciousness the way it has. I certainly did not, and now that the severest of consequences have manifested, all I wish to do is find the good in what has been one of the most challenging weeks of my life.
This positive attitude is to be admired. I have been through similarly shitty situations in my own life (as most of us have at one time or another) and while it's good to move on I like to extract lessons that will help me try to avoid making the same mistakes. If I can find those I can feel more positive about the experience.
And I do believe there is good to be found in this situation. Debate and recrimination can and must give way to dialog that explores the root causes of these issues in the tech industry. As developers and members of the startup community, we can welcome newcomers, women and people of color who, as of now, are under-represented in our ranks. And, all of us can learn a great deal from those who are well-established in the field. We can solidify the values of our workplaces (yes, conference spaces are workplaces!), and set new, positive and inclusive examples for other professional disciplines.
This is a good idea. PyCon was started to try and provide an inclusive space where everyone with interests in Python can come together for the betterment of all. I would be suspicious of those who don't support the above as an ideal. We surely have to accept that there's still along way to go to get there. So dialog is a good idea.
What happened at PyCon has cast a spotlight on a range of deep issues and problems in the developer world. As ugly as this situation has become, all of these issues have reasonable, and, I think, easily reached solutions that will help us cast conflict aside and construct a more cohesive and welcoming professional environment based on respect, trust and open communication. I do not, at this time, wish to concentrate on the fallout of the last several days. Instead, I want to be an integral part of a diverse, core group of individuals that comes together in a spirit of healing and openness to devise answers to the many questions that have arisen in the last week. Together, we can work to make the tech world a better place to work for everyone, and in doing so, we make the wider world a better place for all.
It's interesting that this episode happened at PyCon. When we started to talk seriously about Codes of Conduct in the Python world there was a lot of kick-back, and people said things like "but this is the Python community" (implying that we are such nice people that we won't have the same issues) and "but that's just normal behavior" (not even implying, but specifically stating, that anyone who needed a Code of Conduct to condition their behavior shouldn't be going to conferences anyway).

We pressed ahead none the less, refining the code to improve its expression of our ideals of openness and inclusivity. When issues had to be addressed (and you can read the reports in the PyCon blog if you need to refresh your memory) the code of conduct was applied, and to my mind it worked. The fact that two people lost their jobs as a result of the fall-out was nothing to do with the code of conduct, and yet there were many who felt that the blame should be laid at PyCon's door. I shudder to think what the result would have been at an event with no explicit code.

I hope that Adria can come back to PyCon without being subjected to any hostility. She expresses a great ideal, one that we should all be striving for. Now we just have to work out how to achieve it. But that's an implementation detail, right? I wish!

April 29, 2013

So Long, and Thanks for All the Fish

A notable transition point in my life, by any measure. Interesting things are happening in all directions, many of them (I am delighted to day) heavily involving Python. So this is definitely not goodbye. My time on the Foundation's board has been a wonderful and interesting ride. I hope I have lived up to Tim O'Reilly's ethic of creating more value than I extract.

April 28, 2013

Why Tuples?

A frequent question from new and even not-so-new Python programmers is "why does the language have both tuples (which, if you know Python, you will recall are immutable) and lists?" You might almost say there are two kinds of Python programmers, those who know what tuples are for and those whose mathematical education has been limited. I know this sounds like an awfully snobbish thing to say, but it isn't meant that way. The fact is that I learned most of my programming in eight years of working experience before I started my degree studies, and I am therefore of the very definite opinion that people with little mathematical background can be excellent programmers.

It's just that I myself only came across the word tuple when I started studying college-level mathematics and had to come to terms with things like
An NFA is represented formally by a 5-tuple, (Q, Σ, Δ, q0F), consisting of
  • a finite set of states Q
  • a finite set of input symbols Σ
  • a transition relation Δ : Q × Σ → P(Q).
  • an initial (or start) state q0 ∈ Q
  • a set of states F distinguished as accepting (or finalstates F ⊆ Q.
Now this has a very definite meaning. It tells us that an (ordered - i.e. positionally-identified) set of five things is sufficient to define the behavior of a specific type of object (in this case a non-deterministic finite state automaton (NFA), though for all you need to know about those I might just as well be describing a flux capacitor).

If we wanted to encapsulate an NFA as a Python data structure, then we might at some point in our code write in our Python code something like

    nfa = (states, symbols, transition, initial, accepting_states)

though in actual fact you would be more likely to want to incorporate behavior in a class and so write instead

    nfa = NFA(states, symbols, transition, initial, accepting_states)

Now even though you may not know what an NFA is, you will surely perceive that the set of its possible states is a very different thing from the function that determines how a current state and a set of inputs are mapped into new states. So there is simply no way that it would be meaningful to write

    for thing in (states, symbols, transition, initial, accepting_states):
        do_something_with(thing)

unless you were, for example, trying to save its state during a pickling operation or some more obscure book-keeping metacode.

And that, best beloved, is what tuples are for: they are ordered collections of objects, and each of the objects has, according to its position, a specific meaning (sometimes referred to as its semantics). If no behaviors are required then a tuple is "about the simplest thing that could work."

This is why you often hear people informally say tuples are for "collections of things you don't need to iterate over" or "tuples are for sequences of dissimilar objects". My advice would be to stay away from such discussions. One might reasonably argue that including them in the language discouraged people from using objects with named attributes, which are always easier to deal with.

The problem with the tuple is that once we have constructed our NFA the only way to refer to the states in code is with the rather unedifying expression

    nfa[0]

which doesn't actually tell the reader much about the programmer's intention. The sequence nature of the tuple means that our accesses to the elements are difficult to imbue with meaning in our code. This latterly became such an obvious shortcoming that it prompted Raymond Hettinger to create the namedtuple object that allows you to easily specify a tuple whose elements can also be referred to by name.

It would be interesting to see whether users of namedtuple objects actually use them as tuples at all. I would guess that the sequence behaviors are rarely used, in which case perhaps it's time to either remove namedtuple's __getitem__() and similar methods or implement a similar object without the sequence behaviors.

December 17, 2012

Gun Nuts 1

In the wake of the most recent school slaying I thought it might be relevant to revisit the writings of Eric S Raymond. Within my world he is a well-known and self-described "gun nut." His two principal writings on he right to bear arms appear to be The Parable of the Sheep and Ethics Through the Barrel of a Gun. I will look at the latter in a separate post. There is nothing I can do for the misery of the bereaved families. I can only hope to help in the longer run.

The Parable of the Sheep
This is a tale of a flock of sheep. The dog cannot keep the wolves away. Some sheep take the claws and fangs from dead wolves. They fight back, reducing the carnage. Eventually the wolves mostly leave sheep alone. They do not know which sheep are armed. Many sheep are terrified of the weapons. They ban the armed sheep from to the pasture. They post signs at the edges forbidding hidden weapons. The wolves, seeing this, return. Once again they inflict carnage on the flock. They are only beaten off by the armed sheep. The flock remain afraid of the weapons. They barely tolerate their protectors, the armed sheep. The armed sheep altruistically continue to protect the flock. Raymond describes the situation thus:
The bold sheep knew that the fangs and claws they possessed had not changed them. They still grazed like other sheep, and raised their lambs in the spring, and greeted their friend the dog as he walked among them. But they could not quell the terror of the flock, which rose in them like some ancient dark smoky spirit and could not be damped by reason, nor dispelled by the light of day.
The parable omits many refinements of the true situation. That is forgivable for expository purposes. A school shooting represents something outside the parable. There is a genuine reason for the terror of the unarmed sheep. Occasionally the armed sheep start acting like wolves. Of course the unarmed sheep are then the inevitable target.

The statistics for murder and armed robbery are quite alarming. Those for child murder are truly chilling. Almost 63% involved a firearm in 2011. Well over a thousand kids blown away each year. To suggest that we all arm to protect ourselves seems unbalanced. It's like the 1950's "defense" policy of Mutually Assured Destruction. Never was an acronym more appropriate. The terrorists aren't over there, they are among us. A school massacre is an act of terror.

Here the Japanese strategy of many approaches might be fruitful. It is unlikely there is a single switch we can turn to stop this happening. Surely it is better to try to understand these acts of atrocity. Consider them a societal ill and seek its cure. Perhaps we could try to build a world where people are better in touch with their fellows. Extremes of behavior can (most of the time) be recognized. If someone is heading in a dangerous direction, perhaps it can be deflected by sympathetic attention.

I imagine* that most mass murderers are completely in control most of the time. They are indistinguishable  from "normal" people. The classic quote after an apparently psychotic shooting episode? "He seemed like a normal guy." Let's leave the fact it's usually a man to another time. It's not like they are landmines, liable to go off at any touch. I am a pretty placid person most of the time. Occasionally some perfect storm of circumstances hits. Shortage of sleep is often involved. Physical exhaustion never helps. Emotional distress is very rarely positive. I "go off on one" in an uncharacteristic way. We all have extremes of behavior, often in response to extreme circumstances. Some people are more extreme than others.

Some people, sadly, are so extreme that they must be incarcerated to protect the rest of us. I would, in the USA, prefer it if the government invested its funding in long-term plans to make the country a better place to live than lock up predominantly black predominantly drug-offending adults.** Now private companies are running prisons, vested interests are powerful.

So while Raymond's simplified argument seems reasonable enough, that's only because it is simplified. There are inevitable outliers in a flock of over three hundred million. Mental stability and degree of moral control are two important dimensions. At that scale the sheep would appear to have a good reason for caution. Anyone proposing to use fangs and claws should surely be assessed as a responsible individual. Mistakes will still be made, but (presumably) it is not beyond the wit of sheep to concoct a scheme that reduces the number of massacre incidents.

In network parlance, the parable doesn't scale to larger flocks. Neither does it scale to bigger and better teeth and claws. The reductio ad absurdum of many gun nut arguments is that we should all carry personal tactical nuclear weapons. What's reasonable, and what's not? Why are such deadly automatic weapons allowed outside gun clubs and the armed forces? I don't mind people enjoying handling and using firearms. Hunting, preferably for food, for example, is a perfectly legitimate use. So is fun at a gun club shooting range. Mowing down kids, not so much. We have to strike a balance.

One final note: please let's not imagine there is an instant cure. All we can do is lay, and maintain to, long term plans. These should aim to reduce the availability and access to weapons, particularly those capable of facilitating mass murder.

* Admittedly if this were a Wikipedia article someone would have at least added a "citation needed" flag
** Who are then unable to vote

A Thank You to Eric Sterling

Offered for the attention of those who attended Eric's recent keynote at DjangoCon and, most especially for Eric himself. I still remember the talk and the panel session he took the time to contribute to fondly, and I particularly enjoyed the unique flavor he added to the lunch he attended.