Tuesday, November 22, 2011

"Count it all joy" -- no, really

At this weekend's services at MPPC , USC philosophy professor Dallas Willard addressed several questions on the topic of pain and suffering. One was, "How do we find God in the midst of suffering?"

The answer was a call to something proactive: to be turned toward God before suffering comes, so that you're not in a position to have to go looking for him when it comes. This is also a clue to following James’s command to "Count it all joy" when you meet various trials (James 1:2 NKJV). Now the text says that since trials test our faith, and this produces perseverance and maturity, therefore we can rejoice in the trials. Paul also writes something similar but it seems to me that this perspective itself requires wisdom most of us lack. Perhaps this is why James tells us immediately afterward to pray: "But if any of you needs wisdom, you should ask God for it. He is generous to everyone and will give you wisdom without criticizing you." (James 1:5 NCV)

Dallas shared some of his wisdom: that if my life is oriented toward God, if I have faith in God—who's big enough to take care of things—then trials give me an opportunity to see him in action; I'll even greet them with anticipation! (I confess I'm not writing this from first-hand experience, but I can appreciate the theory.)

And what is joy? How can we have it in the midst of sorrow and pain? Joy, Dallas said, is a pervasive sense of well-being. It's like peace, not an action but something in the background.

Well-being in the midst of pain and suffering—how does that work? Dallas said we need to have a big vision of a big God. Two illustrations come to my mind: the first is from Anne Lamott's book Operating Instructions, where she writes about feeling vulnerable in a new way, shortly after her son is born. Before this, she says, she felt she could survive anything. She writes something like, "I could die, and somehow survive even that"—which is not logical, but it made emotional sense to me: a sense of strength and well-being beyond any circumstance.

Another example that came to mind is due to Larry Crabb, Jr., who talked about deep longings that we all have, and the wrong strategies we often use to fulfill them. Depending on our perspective, he said, painful events can be to us like a five-foot fall from a platform (something that will hurt, may cause injuries, but probably won't kill us), or a five-mile fall from an airplane (which probably will).

With that background, here's the example I was thinking of, which I think was presented in a 1987 lecture. There was a guy who often spoke of wanting to ride in a hot-air balloon; his wife bought him tickets for his birthday, and early one morning, she watched the balloon take off with her husband and I think one of their kids. But in a freak accident, the balloon met some power-lines; it literally crashed and burned, killing all aboard. Because she was deeply connected to Jesus, this tragedy was a five-foot fall; she had that pervasive sense of well-being in the midst of terrible tragedy.

Now there's an inner strength to admire—not an inner strength of the "self-made" tough-guy, but the strength of one who knows their own weakness and clings to Jesus. May the Lord so strengthen us, that we have the power to count it all joy when we meet various trials, and to rejoice in our tribulations.

Wednesday, November 16, 2011

A useful exercise

This morning the lovely Carol and I talked briefly about thankfulness. Psalm 65 has some things, and I neglected a whole lot of things in the list below, but here are a few things I'm thankful for anyway...
  • that I can walk without straining, limping, or lurching
  • that the VTA stops close by the office
  • a car in case I need to drive to the office
  • a job (i.e., an office to go to)
    -- though I complain sometimes about having a day job,
  • the lovely Carol to come home to
  • a house with a roof and walls and locking doors
  • healthy parents -- not to be taken for granted at their age, or mine
  • loving children (though they're not kids any more)
  • the knowledge that I'm forgiven
  • the promise of eternal life
  • a place of worship
  • the freedom to worship there
    -- though I sometimes complain about meetings...
  • circuit breakers (rather than fuses) for the power in our house
  • Long's and Safeway at the Caltrain station
  • money to buy stuff there
  • Friday bagels
  • a great team at work
  • the ability to enjoy reading/writing code
  • big windows near my cubicle
  • enough clothes to protect me from the air chilled by those windows
  • a functioning clothes washer
  • the ability to fix it (again) when it overflows
  • hanging things to dry the laundry on
  • a working clothes dryer for when laundry can't (or shouldn't be) hung
  • a seat on the train
  • mobile wifi

Saturday, November 12, 2011

Collin writes a program*

(* Title borrowed from Ron Carlson Writes a Story)
A few times in the past months, someone's commented that they have no idea what it's like to write a computer program, so I've been thinking about a sort of gentle introduction to the fun ("joy" seems a bit overstated) of programming. Then it happened—the puzzler from Car Talk was announced, and I thought it was perfect. So in the next 45 minutes I want to write a program to solve last week's puzzler. It goes more or less like this:
Imagine a very long hall with 20,000 lights hanging from the ceiling, all off. These lights are controlled by a pull-chain: pull it once, the light turns on; pull it again and the light turns off.

Now someone comes through the hall and pulls every single chain. The lights are now all on. Person #2 comes through and pulls every 2nd chain, so that now lights 2, 4, 6, 8 and so on are now off. Person #3 comes through and pulls every 3rd chain, thus changing the state of lights 3, 6, 9, 12 and so on; they turn some lights on and some off. Person #4 comes through and flips lights 4, 8, 12, 16 and so on.

And so on, until person #20,000 comes through and only tugs on the chain of the 20,000th light.

Can you predict which lights will be on, and which will be off?

Now with a pencil and paper you might be able to figure this out in five or ten minutes, but like my first math professor, who spent ten minutes figuring out how to avoid a five-minute calculation, we'll go through the process of writing a little program to show how at least some programmers think.

We'll use the programming language Python here. I briefly considered using something like Ruby or OCaml, so we could go through the experience of learning a new programming language together, but I'm long-winded enough that...

Right. So Python. Here's what we're going to do: We'll create a list representing the state of each light fixture. And rather than forcing the program to do exactly 20,000 hanging lights, we'll provide a parameter to say how many lights there are. The pattern will be obvious with as few as 100 lights, so let's start with that. Here's a first partial whack at it.

# Adjust the following line to be however many lights you want
howevermanylights = 38

# "light_states" represents the states of howevermanylights
# Initialize it to have just some junk in element 0
light_states = ['junk']

# Add the states of however many lights
for a_light in range(howevermanylights):
    light_states.append(True)

# We'll add code here to manipulate the lights' states

# Now show the state of each light

for a_light in light_states[1:]:
    if a_light:
        print '*',
    else:
        print ' ',

print
for a_light in range(howevermanylights):
    # print last digit of a_light
    print (a_light % 10),

print
and if I run the program (which I imaginatively called "ceiling") it does this:
$ python ceiling
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
$ 
(The bold blue text is what I typed in response to my computer's prompt.)

This shows that light #0 is, oops... do you see that? I wanted to show the state of light #1, #2, #3 etc., but for some reason the numbers are 0, 1, 2, etc. I need to fix the digit printed. That last part will now read:

for a_light in range(howevermanylights):
    # print last digit of a_light
    print (a_light+1) % 10,

print
OK, that worked. Why did I have that "bug", or error? (Programmers call their mistakes "bugs"; it sounds so much better to say "I had 5 bugs in my code" than "I made 5 mistakes (or more) in my code.")

Well, actually I put it in on purpose. No, really; I wanted to mention that Python, like Perl, starts its lists with index 0 rather than 1. This is why I wrote above

# Initialize it to have just some junk in element 0
light_states = ['junk']
if light_states has howevermanylights elements in it, they will be numbered 0 up to howevermanylights-1.

Why do Python and Perl (and C and java too) start numbering lists/arrays at 0 rather than 1? Well, it's for convenience. The first ten elements (or "decade" of elements) in an array are numbered 0-9; the second ten are numbered 10-19. So you can tell which "decade" we're in by looking at the tens digit.

This stands in contrast to our system of years, where the first century is years 1-100; the second century is years 101-200... the 20th century is 1901-2000, and so on. See how inconvenient this is? The 21st century started in 2001 (not 2000) so you can't tell just by looking at the top digit. A computer scientist didn't come up with this system for numbering years.

So a list of 5 elements (for example) has its elements numbered 0,1,2,3,4. Similarly range(5) gives 5 numbers -- also numbered 0,1,2,3,4. To wit:

$ python 
Python 2.6.5 (r265:79063, Jul  5 2010, 11:47:21) 
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> range(5)
[0, 1, 2, 3, 4]
>>> 

Anyway, light_states starts at 0, and we number the ceiling lights starting at 1, so I put some junk into element 0 of the list so element 1 could correspond to ceiling light #1, etc.

OK, now let's put some more code in to deal with persons #2–howevermanylights.

# Adjust the following line to be however many lights you want
howevermanylights = 38

# "light_states" represents the states of howevermanylights
# Initialize it to have just some junk in element 0
light_states = ['junk']

# Add the states of however many lights
for a_light in range(howevermanylights):
    light_states.append(True)

# Code to manipulate the lights' states
# We have person#2 upto and including howevermanylights.

for a_person in range(2, howevermanylights+1):
    # Flip every "a_person"th light:
    for a_light in range(a_person, howevermanylights+1, a_person):
        light_states[a_light] = not light_states[a_light]


# Now show the state of each light

for a_light in light_states[1:]:
    if a_light:
        print '*',
    else:
        print ' ',

print
for a_light in range(howevermanylights):
    # print last digit of a_light
    print (a_light+1) % 10,

print
The new code is shown in this color and basically, um, does what it says -- assigns the variable "a_person" all values from 2 upto and including howevermanylights. And for each such person, flips every "a_person"th light.

When I run the program, it does this:

$ python ceiling
*     *         *             *                 *                     *    
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
$ 
Right, that's not 100 lights, and I've only printed the last digit of the light number, but lights #1, 4, 9, 16, 25, 36 are left on. (If I make howevermanylights much bigger than 38, then you won't be able to see the result on a single line.)

Time's up and you got the basic idea

OK, the above was 45 minutes' worth, but let me take a little more time to do two things:
  • First, let's change this line to say 1000 instead:
    howevermanylights = 1000
  • And let's just list out which lights are on, rather than printing out the state of all the lights:
    # Now show the state of each light
    # Don't do that; just list out number of each light that's on
    for a_num in range(1, howevermanylights+1):
        if light_states[a_num]:
            print 'On:', a_num
And when we run it?
$ python ceiling 
On: 1
On: 4
On: 9
On: 16
On: 25
On: 36
On: 49
On: 64
On: 81
On: 100
On: 121
On: 144
On: 169
On: 196
On: 225
On: 256
On: 289
On: 324
On: 361
On: 400
On: 441
On: 484
On: 529
On: 576
On: 625
On: 676
On: 729
On: 784
On: 841
On: 900
On: 961
$ 
Do you see the pattern there? Every number that's a perfect square is left on, but composite numbers are off. Why perfect squares? That's an exercise left to the reader.

Anyway I hope that gives an idea of some of what it means to write a program. Most of what "real programmers" do is quite a bit more complicated, but that ought to give a flavor for at least some of the tasks. I hope that was fun reading for you; it certainly was enjoyable for me to write.

Finishing(??) touches

OK, it's now the next morning and I wanted to sort of finish the program off, and to give you the whole program in one snarf'n'barf-able blob so you can tweak it yourself, if you've got the interest.
#!/usr/bin/python -utt
'''Program to solve cartalk puzzler
http://www.cartalk.com/content/puzzler/transcripts/201144/index.html

Basically this:
    Imagine a very long hall with 20,000 lights hanging from the
    ceiling, all off.  These lights are controlled by a pull-chain:
    pull it once, the light turns on; pull it again and the light
    turns off.

    Now someone comes through the hall and pulls every single chain.
    The lights are now all on.  Person #2 comes through and pulls
    every 2nd chain, so that now lights 2, 4, 6, 8 and so on are
    now off.  Person #3 comes through and pulls every 3rd chain,
    thus changing the state of lights 3, 6, 9, 12 and so on; they
    turn some lights on and some off.  Person #4 comes through and
    flips lights 4, 8, 12, 16 and so on.

    And so on, until person #20,000 comes through and only tugs on
    the chain of the 20,000th light.

    Can you predict which lights will be on, and which will be off?

The program calculates (not predicts) which lights will be on.

Provide the number of lights in a parameter (default 100)'''

import sys

def main(howevermanylights):

    # "light_states" represents the states of howevermanylights
    # Initialize it to have just some junk in element 0
    light_states = ['junk']

    # Add the states of however many lights
    for a_light in range(howevermanylights):
        light_states.append(True)

    # Code to manipulate the lights' states
    # We have person#2 upto and including howevermanylights.

    for a_person in range(2, howevermanylights+1):
        # Flip every "a_person"th light:
        for a_light in range(a_person, howevermanylights+1, a_person):
            light_states[a_light] = not light_states[a_light]


    # Now show the state of each light
    # Don't do that; just list out number of each light that's on
    for a_num in range(1, howevermanylights+1):
        if light_states[a_num]:
            print 'On:', a_num
    sys.exit(0)

if __name__ == '__main__':
    try:
        num_lights = int(sys.argv[1])
    except:
        num_lights = 100
    main(num_lights)
So this does a few things beyond what I had last night:
  1. You can give a parameter and it'll do the calculation for the number of lights provided
    % ./ceiling.py 38
    On: 1
    On: 4
    On: 9
    On: 16
    On: 25
    On: 36
    % ./ceiling.py 100
    On: 1
    On: 4
    On: 9
    On: 16
    On: 25
    On: 36
    On: 49
    On: 64
    On: 81
    On: 100
  2. It's got documentation:
    % pydoc ceiling | cat
    Help on module ceiling:
    
    NAME
        ceiling
    
    FILE
        /Users/collin/to-mail/ceiling.py
    
    DESCRIPTION
        Program to solve cartalk puzzler
        http://www.cartalk.com/content/puzzler/transcripts/201144/index.html
        
        Basically this:
            Imagine a very long hall with 20,000 lights hanging from the
            ceiling, all off.  These lights are controlled by a pull-chain:
    (etc.)
  3. It's easier to debug (google "python debugger" for more info).
  4. It returns a "success!" code so the system thinks the program worked.

Can I mess up God's plan for me?

Suppose someone says, "I know God has a good plan for me (Jeremiah 29:11), but what if I mess it up? Will it then become his plan for someone else?" How do we answer them?

I certainly understand this sort of thinking; it comes from the old performance mentality, the same old lies that say, "you're OK only until you mess up; then you're irredeemable." We think we can pass the audition but if we miss our cue or flub our lines, an understudy will take over and we'll be thrust out the backstage door into the outer darkness, where there is weeping and gnashing of teeth.

But wait, you say, that's true, isn't it? If the star of the show shows up drunk or something and can't perform, the understudy takes over, yes?

Let's have a look at where this verse comes from to see why I think God's plan is not like a play or concert or opera performance. The passage is in Jeremiah 29; it's part of a letter to Israelites living in Babylon. These people are in Babylon because the nation has not obeyed the Lord -- Israel was full of violence and greed and idolatry. In other words, the plans to prosper the Israelites, to give them hope and a future, were announced after they disobeyed the Lord for generations—hundreds of years of disobedience! And yet he says, "I know the plans I have for you," declares the Lord, "plans to prosper you and not to harm you, plans to give you a hope and a future. Then you will call upon me and come and pray to me, and I will listen to you. You will seek me and find me when you seek me with all your heart." (Jeremiah 29:11-13)

Hundreds of years of disobedience by millions of Israelites didn't thwart God's plans for their nation, and yet we worry that a few decades of disobedience by one individual might lead him to break his promise. As if we could disappoint him so much in a way he didn't already know!

I mean, did God say "Before a word was on your tongue, I knew it completely (Psalm 139) but then you came out with that??" Or "Before I formed you in the womb I knew you (Jeremiah 1) but then you went and did something else." Or "I chose you in Christ before the foundation of the earth to be holy and blameless (Ephesians 1) but then you went and messed it all up."

I don't think so. As I wrote last month, God already knows (Isaiah 44:6-7, 46:10) what will happen; there is no way that we can surprise or disappoint him, and there is no way that he will change his mind about his plans. He doesn't do that.

And isn't that good news?

Thursday, November 03, 2011

Mistakes

I hate making mistakes, which is really a pain because I do it all the time. When I read the gospels, though, I don't feel so bad, because I see that the disciples made mistakes all the time, too. Peter was forever putting his foot in his mouth—In Mark 9:5 he's having this dazzling experience with Jesus, James, John, Moses and Elijah, and he has to blurt something out. Right afterward, a cloud appears and a voice tells Peter (and the rest) "This is my beloved Son; listen to him!"

In Mark 16, we see Mary and Mary and Salome going to visit Jesus’ tomb. They have no idea how they're going to get in there (Mark 16:3)—planning's not so good. Once they do get in, they receive instructions (Mark 16:7 "But go, tell his disciples..."). They don't obey the instructions (Mark 16:8)—execution's not so good.

There are lots more like this, and as I said, this gives me hope because... well, no need to go into details.

Today I also read some of Merton's words about mistakes, which mean so much more to me now that I know he struggled with these things himself. He is like one of the high priests spoken of in Hebrews 5:2, who "can deal gently with the ignorant and wayward, since he himself is beset with weakness."

As long as we are on Earth our vocation is precisely to be imperfect, incomplete, insufficient in ourselves, changing, hapless, destitute and weak, hastening toward the grave. But the power of God and His eternity and His peace and His completeness and His glory must somehow find their way into our lives, secretly, while we are here, in order that we may be found in Him eternally as He has meant us to be.

The relative perfection which we must attain to in this life if we are to live as sons of God is not the twenty-four-hour-a-day production of perfect acts of virtue, but a life from which practically all the obstacles to God's love have been removed or overcome.

No Man Is an Island 7.10 (pp. 129-130)
Doesn't that sound good? To know that mistakes are part of life, nothing to be surprised about, to have God's power and peace &c finding their way into our lives, and to have nothing between God's love and us... sign me up! What's stopping me from getting there? Merton tells us in the next sentence:
One of the chief obstacles to this perfection of selfless charity is the selfish anxiety to get the most out of everything, to be a brilliant success in our own eyes and in the eyes of other men.
I resemble this remark too! Thanks be to God; he knows all this and chose us and called us anyway. And that's good news.