Wednesday, April 3, 2013

Seeing concurrency

Modern computer programming makes extensive use of concurrency. Concurrency means two or more paths of code executing at the same time on the same set of resources. Ever since Windows 3.11 allowed us to Alt-Tab between windows, we have all been "multi-tasking".

Concurrency is a powerful way to maximize the use of a system. While one process or thread is waiting on data from a disk drive, the operating system automatically switches to another thread ready to process data from the Internet. A typical system runs with dozens, even hundreds, of processes or threads.

But programming concurrent systems is difficult. The interaction of these various processes and threads creates bugs including dead locks, live locks, and race conditions. Modern debugging tools can help a bit, but it usually boils down to brute force to root out these issues. I've spent countless hours figuring out why the whole system is coming unglued only to discover one synchronization lock out of place.

How is it that we can make extensive us of concurrent programming, but yet it so difficult? How can a topic which is taught in the first year of any computer science program still be baffling to a career software engineer? I believe it's because we lack the ability to see concurrency directly. We know about concurrency. We can explain what it is. But sometimes the interaction of just two threads can surprise us, let alone the interaction of hundreds.

This reminds me of Immanuel Kant's view of human perception. Now, just in case it's not obvious, I don't know squat about Kant. I've read a bit about him, and I've read a bit of him, but just enough to know that I don't actually know anything about Kant. That said, he believed that the certainty we feel in the realms of mathematics and science, in the accuracy of our perception of space and time, is due to our sense perception being space-and-time oriented. "The sensible world and its phenomena are not entirely independent of the human mind, which contributes its basic structure." (http://plato.stanford.edu/entries/kant/).

I think this is why multi-threaded and multi-process programming is difficult. We can't see it. Our natural sense perception is to see time as a single, linear stream. This is how we experience life day to day. So this is how we understand computer code: a single, simple flow of instructions starting at the top and working its way to the bottom.

But we can imagine time in multiple, cyclical streams. I've been a big fan of Doctor Who since Tom Baker days, as he careened though space and time in a British police box. You probably have your favorite time travel story. I think time travel in pop culture and concurrency in computing have a lot in common. But imagining something is not the same as really knowing it.

So how are we able to make such extensive use of concurrency? It's our ability to abstract. Abstraction is the creation of a higher-level representation which hides lower-level details. Abstraction allows us to take a oily, noisy car engine and stick it inside of a shiny, clean auto-body and drive around town with ease. Abstraction allows anyone to play music on an iPod with a touch of a finger, even thought that single touch requires millions of transistors to operate at the speed of light with logical perfection.

So it is with concurrency: we create abstractions which hide the concurrency so that the vast majority of code works in a simple, linear flow of instructions. We isolate the difficulties of synchronizing threads, solve the concurrency problems, then spend the vast majority of time programming within the abstraction of a single-threaded environment.

This understanding of how concurrency is managed reflects the humility and glory of man. We have an incredible ability to create powerful, wonderful electronics. And at the same time we lack the ability to see the interaction of two simple threads.

Monday, March 25, 2013

Marriage in the balance

This week our Supreme Court considers the constitutionality of gay marriage. I predict they will not repeat the mistake of Roe v. Wade and remove the issue from public debate prematurely. But it will fall short of a win for traditional marriage. Maybe I'm too much of a pessimist, but it seems the cultural shift in favor of normalizing homosexuality is unstoppable. The youth have decided, and they are growing up fast.

As a conservative Christian, there are many ways to see this:

First, traditional Christianity will be seen as bigotry. But this creates an opportunity to show love. If everyone has me pegged for an intolerant, hate-filled dinosaur, it creates a space to show what tolerance and love is. Jesus ate with prostitutes and sinners, but without condoning prostitution or sin. Maybe God is going to humble the church to the point where we can serve as Christ did.

The debate about the definition of marriage hides the underlying issue: is marriage definable? As a Christian, the answer is no. I received the institution of marriage. I received it from God, from tradition, from natural law, from my Mom and Dad. The Western world is blazing new ground by defining marriage. Greek and Roman men played with homosexuality, but they returned home to wives, kids, tradition and honor. They knew that another generation had to be born and raised if society would go on. It seems our modern affluence and independence has freed us from these concerns.

Or has it? Our modern welfare state, Medicare and Social Security, depends on the next generation paying for the care of the previous. And, given that everyone to date has taken out more from these programs than they have put in, it depends on the growth of that next generation. What happens when the drive for family and children is diminished? It doesn't have to be erased: what if these trends simply lower birth rates? The system collapses in on itself.

But we don't have the ability to discuss societal effects. The issue swirls around individual rights. "Don't I have the right to define marriage as I want?" But there is no absolute "I". There is both an "I" and a "we". One person's right to define marriage as he or she wills implies the duty for another to recognize that definition. Without that recognition, the definition means nothing.

Finally, this will put incredible pressure on other areas of our society. How well can Christians participate in public schooling and free markets and free speech in the context of state-sanctioned, state-promoted homosexual marriage? We've been numbed by decades of extra-marital sex in TV and movies. We know the stats about divorce rates and pornography and drug use. But redefining marriage is different. It creates a public standard of approval or disapproval by which someone can be measured, like bowing down to the statue of Darius or offering a pinch of incense to Caesar. Do you acknowledge the norms of our society, or are you on the suspicious outside?

So we will all discover what the effects of this will be. As a Christian, I need to trust in God, love my neighbor, and wait for God to make all things right. We need to show respect to all people, made in the image of God and loved by God. And, maybe most of all, I need to love my wife and, to the best of my ability, show my children what God created marriage to be.

Monday, December 31, 2012

Covenant theology terms


While the reformed doctrines of the Covenant of Grace and Covenant of Works explain good theology, they often cause confusion because they don't line up well with the Bible's own use of the term covenant. It's a tension between systematic and biblical theology.

The Covenant of Works is God's requirement of perfect obedience, broken by Adam and fulfilled by Christ. The Covenant of Grace is God's plan to save his people by grace, first promised to Adam after the fall, then renewed throughout redemptive history until it was fulfilled by Christ. This framework helps us understand salvation by grace alone, through faith alone, and in Christ alone.

The Bible says much about covenants, but it uses different terms. The covenants in the Old Testament include those made with or at the time of Noah, Abraham, Isaac, Jacob, Moses, Joshua, and David. The prophets also speak of a coming New Covenant. There is obvious continuity between some covenants (from Abraham to Isaac to Jacob), but less obvious continuity for others (for instance Noah or David).

In the New Testament, the terminology is simple: Christ has instituted the New Covenant and we are living under that now. The New is contrasted with the Old Covenant. The New Covenant is the goal of redemption history, the culmination of all previous covenants, so understanding what this covenant is and how it differs from the old is important. In Galatians Paul explains how the New Covenant is both continuous with the Abrahamic covenant but radically different from the Mosaic covenant.

The Covenant of Grace doctrine correctly teaches the continuity between the Old and New Covenants, but in the desire to emphasize continuity, it often de-emphasizes the importance and priority and newness of the New Covenant. This is illustrated in Berkhof's Systematic Theology when he begins his one page treatment of the New Covenant: "Little need be said respecting the New Testament dispensation of the covenant." I guess the New Testament has a lot to say about it, even if Berkhof doesn't.

Also, it's a common mistake to confuse Covenant of Works for the Old Covenant. This could be corrected by better teaching, but I think the terminology is prone to the mistake. One reason is that there's extremely little Biblical support for the term "Covenant of Works" (Hosea 6:7 and what else?) I think some renaming of the doctrine, without the word covenant, would be helpful.

Of course, changes like this take time. There is tremendous value in the Westminster Confession of Faith and other reformed confessions that define the Covenant of Grace and Covenant of Works. These should not be changed quickly or lightly. But our systematic theology and confessions should always be open for revision and clarification because they are written in submission to the Bible.

Wednesday, December 26, 2012

Cliff jumping

Only a few days from the fiscal cliff, it's my turn to weigh in on what this all means. Of course no one knows. The experts don't. Our political representatives don't. So there's no harm in my throwing in an opinion.

First in my mind is that the national debt ($16.3 trillion) will never be paid; it will only be serviced (there were a few years under Clinton and Bush when the dot-com bubble created surpluses and debt was paid down, but that was the exception.)

If this is true, then the debt should be viewed as the required payment as a percent of the annual budget. Right now it is $360 billion per year from a $2,600 billion per year budget. That's 14%.

But this payment is variable. It is determined by the interest rate on Treasury bonds, and those are bought and sold on the open market. The free market determines the rate. Greece learned that this year. Right now our interest rate is around 2 or 3 percentage points. Greece's rate in 2012 fluctuated between 18 and 30. So, when private investors determine that the risk on US debt is too great, our rates will go up in the same way.

When this happens, the Fed will try to hold the rate down by purchasing bonds on the open market. It does this with new money, created out of thin air. Of course, they've already been doing that for the last couple years, in small amounts, with little observable effect. But these small moves are setting policy for the big dance.

What will a substantial and sustained influx of new money mean to the little guy? Inflation. It is the inevitable result of deficit spending. It's the hidden tax that sneaks up and takes money from your back pocket. The rich mitigate it by purchasing real assets that rise with inflation. The poor don't know what just hit them.

Do you remember Ross Perot's dire warnings about the national debt? I still remember the little guy and his alarming charts. Our annual deficit in 1992 was around $290 billion and our national debt was around $3.6 trillion. Those numbers aren't alarming now, courtesy of inflation. And that was modest inflation.

This is why I'm not overly concerned about the fiscal cliff. It was a compromise between conservatives and liberals, signed into law by President Obama, which actually cuts spending. Yes, it raises taxes too, but this is the nature of a compromise. It was supposed to be a poison-pill compromise, one that would be avoided by both sides. But, amazingly, what it actually does is reduce the deficit. Maybe there is no way for either side to actually cut the deficit and take credit for it. Instead, we have to cut by blaming the other side. Is this so bad?

So I think we should let things take their course. Over the cliff. There will be short-term pain. The media will show the poor on the street, then cut over to House Republicans making speeches. It won't be pretty. It won't be fair. But what is a greater long-term help to the poor: more social programs or less inflation? Republicans should refute the charge that they are dismantling the social safety net or weakening national defense. A safety net based on deficit spending is not safe. An army funded by deficit spending is self-defeating.

Monday, July 9, 2012

Symphonies and Software

What does a classical music symphony have in common with a computer software program? I'm a professional software engineer but am only a fan of classical music, so I'm barely qualified to make the connection, but they strike me as surprisingly similar.

Both music and software are creative works. A person uses his or her mind to create something that did not exist before. They are inwardly driven to make something wonderful and they want others to enjoy it. They may have some extrinsic motivation, like fame or a fat salary, but the best creative work comes from some inner fire. We want to create something new, something wonderful, something that will last.

Both music and software is coded. The standard Western notation for music developed notes, staves, dynamic and tempo markers and such. It is a musical language. Other less formal systems have also been invented when it suits the music, like the jazz chord chart. Similarly, software is encoded using a variety of programming languages. Each language is designed to make certain tasks easier. There are general purpose languages (like C or JavaScript) and more domain-specific languages (like SQL or HTML). It shows that language is a malleable tool. We have the power to invent whatever language is needed for what must be done.

The language of music and software allows for abstraction. Low-level complexity can be hidden to allow higher-level ideas to come out. The composer knows the inner workings of his symphony, the harmonic structures, the themes and recapitulations, the balanced orchestration, and he captures all of this with the language of music. The listener may be aware of some of this, but it's not essential. He can simply listen and be moved. Likewise, the software developer knows the structure of his program. He has well-designed interfaces, tested modules, efficient algorithms and optimized inner loops. The user never sees it. If the program works, if it does exactly what he wants, if it's fast and stable, and if it's adaptable to new features over time, he grows to love and depend on that program for running his daily life. The composer and the programmer see the beauty of that complex inner structure, but everyone can appreciate the beauty that flows out of it.

Music and software allow us to communicate more directly than words. Music captures and communicates emotion and software captures and communicates work. How do you feel? I could try to describe it to you with words, or I can communicate it in a more immediate way with music so that you can feel it to. How do you do that? I could try to describe the process in words, or I can give you a software program that gets the job done for you in a faster and more efficient way than you could on your own. In both cases abstract thought-stuff comes to life as we listen to the music or use the program.

Both music and software give us insight into the nature of reality. Just like the discovery of the Higgs boson, we are privileged to get a glimpse into "how it all works." Why do certain chords or rhythms have such power? I think of it as mathematics incarnate. We can experience in an immediate way the beauty and perfection of mathematical proportion. In the same way, a new computer program that allows us to video chat with someone around the world allows to us exercise something like omnipotence over time and space. The almost unreal description of quantum mechanics turns out to be very useful when designing integrated circuits with millions of transistors. We might not believe all this talk about quarks and leptons and bosons, but there it is, working right in front of you.

And all this, both music and software, gives us insight into human nature, into who we are. Man is able to reason and dream beyond the bounds of our immediate experience. When I hear a Brahms symphony or a Bruch violin concerto, my emotions are moved and I ponder the significance of my existence. In the same way, I see a terabyte hard drive and a gigabit Ethernet connection as a fulfillment of the divine command to "subdue the earth." We should marvel at the logical complexity of software systems like databases and search engines. How is it that man is able to build such massive and wonderful creations out of 0's, 1's and a simple logic table? Even if you think our Internet-era utopianism is a little overblown, there's something very wonderful about being alive in this age. It is a marvel what man has done and we are right to enjoy it.

Wednesday, July 4, 2012

Time for the Fat Tax

Now that the Affordable Healthcare Act is the law of the land, confirmed by our Supreme Court, it is time to consider instituting a fat tax - a new federal sales tax on the sugary and fatty food which is making us the heaviest nation in history of the world. Just like smoking, we know that obesity leads to costly health problems. And it doesn't take much looking around to see that we have a big bill coming due.

The idea is simple: when purchasing the $3.00 Big Mac, the government collects 30 cents to take care of the heart attack that statistically follows.

This would not be a tax on overweight individuals. Maybe the name needs some refinement. It's a tax on the unessential food and drink that is making us overweight as a nation.

Of course, a fat tax is a great abridgment of personal freedom. Why should the government be telling us which foods are better or worse for us? But we have already crossed that bridge when we wanted the government to provide our health care. If the nanny state cares for you when you're sick, you have to let her help prevent you from becoming sick in the first place.

The fat tax is something conservatives can embrace because it is fiscally responsible. We can raise the funds to pay for the new health care entitlement without penalizing productivity. "Tax the Potato Chips" is better than "Tax the Rich." It is also self-balancing. If the fat tax causes us consume less junk food, then the decreased revenue should track with the decreased health bill. This will not convince the purists, but maybe it reduces the threat of wholesale instability that could end America's experiment of democracy. If we can keep the ship of state balanced and afloat, we give time to allow the natural consequences of nationalized health care to work itself out. Give democracy space to work.

Liberals will like the fat tax for different reasons. They will regard the government helping us make good eating choices as socially responsible. Apples and whole wheat bread and low-fat yogurt will now be comparatively cheap. It's a dream come true!

So we will disagree about the reasons for the tax, but this allows us to agree to have a solvent government based on laws passed by freely elected representatives. Maybe safeguarding our free government in the long run is worth the giving up another slice of personal freedom in the short run.

Saturday, April 7, 2012

Behold Your Mother

The Third Word

John 19:25-27 - “But standing by the cross of Jesus were his mother and his mother’s sister, Mary the wife of Clopas, and Mary Magdalene. When Jesus saw his mother and the disciple whom he loved standing nearby, he said to his mother, “Woman, behold, your son!” Then he said to the disciple, “Behold, your mother!” And from that hour the disciple took her to his own home.”

Right before Jesus dies, he looks down and sees his mother. He also sees John, his disciple and friend. His heart goes out to them. They are about to be left alone, so he entrusts them to each other. Mother, here is a son for you. John, please take care of my mother.

In these words we see Jesus’ humanity. He was fully God, able to save, but he was also fully human, just like us.

I spent a little time learning some Mandarin Chinese. It is a wonderful language and is quite different from learning any Western or Indo-European language. The vocabulary and tones and characters are unlike anything in English. But what is the Chinese word for Mother? It’s Ma ma. Ma ma. Of course this is no coincidence. When a baby first gains the ability to make a sound with its newly formed mouth, what else could the meaning of those first syllables be? It is mother who is there caring for her baby, in the middle of the night, all through the day, every day. When each of us is born, imagine how the strange and terrifying outside world starts to press itself in on us, but there is one person who is familiar, one person who is safe, who is known. It is ma ma. Every mother is hard-wired by God’s design with a love for her children, and we are all hard-wired to love our mothers.

And Jesus loved his mother. He is just like us.

I have a vivid memory of my mother when I went off to college. I was born and raised in Minneapolis, MN, but at 18 I went off to school in Chicago. I felt like I was finally moving out, ready to prove myself and conquer the world. My parents drove the 8 hours for me to get there. My dad helped me carpet my dorm room and move a few boxes of stuff in. We walked around campus a little bit and saw a few things together. Late in the afternoon I was going to visit a Christian student group on campus and it was time for my parents to drive back home. We said our goodbyes and walked out separate ways. But then I looked back and saw my mother in tears.

And then it hit me all of a sudden. I was leaving home and I wasn’t coming back. And my mother knew it. I barely realized it, but my mother had been preparing for this for years.

What was Mary thinking at the foot of the cross? Here is her baby, Jesus. She had cared for him from infancy. She knew who he was and what he would do before anyone else did. Do you remember the words that Simeon spoke to Mary after he saw the baby Jesus? “Behold, this child is appointed for the fall and rising of many in Israel, and for a sign that is opposed…and a sword will pierce through your own soul also” (Luke 2:34-35). The sword was piercing Mary’s soul right there at the foot of the cross. Her child was dying.

Jesus saw his mother Mary standing there. He saw what she was going through and his heart went out to her. Even in the middle of doing the greatest work ever done, to be suffering the greatest pain ever suffered, to be reconciling God and man for all eternity, yet in the middle of all that, he thought of his mother.

Who is this God? And how can it be? How could God the Son have come down and become a man so much like me that his heart is so simply and so obviously bound to his mother?

Here we see the dignity of man, created in God’s image. One of the most basic elements of our existence, my own love for my mother, is a reflection of the very character of Almighty God.

We also see the love of God. Jesus taught us that when we see him, we see the Father. If Jesus loved his mother in this way, what does this tell us about who God is? It tells us that God is love. God is not an all-powerful but impersonal judge from whom we grovel for mercy. We see that God has come down to us with a heart overflowing in love for sinners.

Does this word about God’s love stir anything in your heart? We are all made for it and are in desperate need of it. Without this love from God, we really are lost and alone in a strange and terrifying world. But here at the cross, we see it. It’s almost too good to be true. But here it is, shown to us plainly in Jesus’ love for his mother and offered freely to us. Jesus’ heart goes out to us as well at the cross, to everyone who comes to him as their Lord and God.

Mark 3:31-35 says, “And his mother and his brothers came, and standing outside they sent to him and called him. And a crowd was sitting around Him, and they said to him, “Your mother and your brothers are outside, seeking you.” And he answered them, “Who are my mother and my brothers?” And looking about at those who sat around him, he said, “Here are my mother and my brothers! For whoever does the will of God, he is my brother and sister and mother.”

From The Seven Last Words of ChristGood Friday Service, 2012, Christ Community Church