A weblog by Will Fitzgerald

Monthly Archives: March 2012

A tiny rant about ‘tr’

The tr program converts a string of characters into another string of characters, using a very simple rule system. The tr [A-Z] [a-z].  But this works for simple “ASCII” strings only. tr, at least on many systems, understands Unicode, and so the standard example fails for converting, say, Russian or Czech. But tr also understands character classes, so the standard example should be written tr [:upper:] [:lower:].

File under “boring post.”

Nearly buried in the This American Life retraction

This American Life released a retraction today about it story reporting on working conditions at Apple suppliers in China. Kudos to This American Life for spending an entire show on this.

I’m afraid that This American Life’s focus on its own errors might overshadow the truths about working conditions in China. To their credit, they spend some time trying to get at the facts.

In the final minutes, Ira Glass interviews Charles Duhigg of the New York Times, who has done his own investigation of working conditions at Apple. Duhigg makes the following claims, which I have little reason to doubt:

  • Actual labor costs are not a major component of the cost of creating Apples products; Apple products could be made in the US for roughly the same cost.
  • It is the ability to quickly and flexibly adjust its supplier chain that in the real benefit to sourcing to China (actually, I’m a bit skeptical of Duhigg’s story here — I wonder if he is exaggerating a bit — but I don’t doubt at all that China is very much more flexible than the US).
  • The biggest violations in working conditions are overwork (24 hour back-to-back shifts, 60+ hour work weeks, people pressured into working over time) and unsafe conditions (for example, flamable industrial dust).
  • Apple lacks the will to insist on better working conditions in China.
  • If consumers put pressure on Apple, Apple would insist on better working conditions. (In an interview Duhigg did with Terry Gross, he compared this to the changes that occurred at Nike suppliers).
Duhigg finished with this:

You’re not only the direct beneficiary; you are actually one of the  reasons why it exists. If you made different choices, if you demanded different conditions, if you demanded that other people enjoy the same work protections that you yourself enjoy, then, then those conditions would be different overseas.

This is worth pondering. I think it might be time to stop buying from Apple until things are vastly improved. If Apple, the leading tech producer, corrects its course, I am sure most of the the other hardware companies will follow suit.

Questions — what is Microsoft’s current record with respect to working conditions overseas? Are there hardware companies who are more ethical?

Scala filters

A random Scala note.

Today, I wanted to apply a list of filters to each item in a list, and return just those that pass each of the filters.

For example, given a range of integers, return just those that are divisible by 2 and by 3.

Let’s start by defining a boolean function divides:

def divides(d:Int,i:Int) = if (i%d==0) true else false

Note that divides(2,_:Int) defines the (partial) function for division by 2.

(divides(2,_:Int))(2) => true
(divides(2,_:Int))(3) => false

So we can create our filters so:

val filters = divides(2,_:Int) :: divides(3,_:Int) :: Nil


val filters = List(divides(2,_:Int),divides(3,_:Int))

Now, we can simply use Scala’s filter and forall functions to filter a range of integers:

scala> Range(1,50).filter(x => filters.forall(f => f(x)))
res45: scala.collection.immutable.IndexedSeq[Int] =
  Vector(6, 12, 18, 24, 30, 36, 42, 48)

The filters could also be defined as a Set, but by creating them as a List, one can put the less expensive filters first.

Amish forgiveness and Amish shunning

Last night, I watched the American Experience documentary on the Amish, which I thought very well done. They treated the Amish with respect, neither nostalgically nor scornfully, with beautiful camera work, well-crafted stories, and good expert commentary. Personally, I especially enjoyed hearing some Amish singing, especially O Gott Vater, which I have never heard sung.

They told the story of the 2006 Nickel Mines tragedy, in which a man shot ten Amish girls in a schoolhouse, killing five of them, and of the amazing forgiveness the Amish showed the killer (who died in the attack) and the killer’s family. They also told stories of former Amish who were placed under the ban and shunned by their Amish communities. The documentarians did not draw any connections between these two, but the stories seem to prompt the following question: how can such peace-loving, forgiving people place others under a strict ban of total non-contact?

The Amish do not need me to defend them, but I have some thoughts. The first is a historical one. When the early Anabaptists began to practice the ban, it is important to remember what the typical punishment was for those who disagreed with a community was in their day. Basically, in most communities, deep theological and civil disagreements would lead to a death sentence for the rebellious one. The Anabaptists themselves were hunted down, and thousands were cruelly murdered for their disagreement. Over against this, the Anabaptists (and the Amish is particular) came up with a non-capital punishment for disagreement: the ban. Compared to death, being shunned is a light sentence.

It is important to remember that the ban is applied only to Amish who have been baptized in the community. Adults who were never baptized as Amish Christians are not subject to the ban; only those who, having committed their lives to God and to the Amish community   through baptism are subject to shunning. Adults who grew up Amish, but decided against baptism, are not shunned — they are treated as any other member of the world.

The documentary makes a point of saying that, in the Amish view, the community is more important than the individual. God is obey as a community, not as a bunch of people who happen to believe the same thing and act in concert. One outworking of this is that the Amish act to preserve and protect and nourish the community more than their individual members. Shnning is but the most drastic example of this: it is more important to protect the community than it is to maintain family and friendship ties, no matter how tender.

Finally, the Amish also believe that shunning is the best thing for the person being shunned; a radical kind of tough love to bring the rebel back (and then, the famous Amish forgiveness should kick in). By servering all of a person’s contact with the community (where one has learned to speak, to love, where ones friends and family are),  the community hopes to instill the deep cost of  rebellion. There are few half-way steps.

As a Mennonite, I admire the consistency and faithfulness of my Anabaptist cousins, and I think about this topic a lot, in fact: how to uphold standards as the world goes to hell in a handbasket. I don’t really have the power to place people under a ban, but it’s good to be reminded that people need to accept responsibility for their actions, that the community is important, and a commitment to following Jesus is a very serious one.

God grant us wisdom to know the differences between how to treat people who fail you, who fail the church though their inidividual actions.