Saturday, May 8, 2010

US Debt and US Presidents





US Debt. Red background for Republican presidents, Blue background for Democrat presidents.**

It appears that from 1940 through 1981, under presidents of both political parties, the US debt stayed under control. WWII military spending* seems to account for the large debt incurred in the early to mid 1940's. For a time debt was well over 100% of the US GDP. After WWII we seem to have stopped incurring new debt. Note that the rise in debt, as well as the flat-lining of debt occurred under Democrats F.D.R and H.S. Truman. After the war was over up to the election of Ronald Reagan, we don't seem to have taken on much new debt and debt as a percentage of GDP fell. Of course, during the same period, no one bothered to actually pay the debt down to zero.

Then, as soon as Ronald Reagan entered office, debt underwent explosive growth. Judging by the Truth and Politics link*, the increase had nothing to do with increased military spending. Yet Reagan ran up the debt about as much as FDR did for WWII. G.H.W Bush continued the rate of increase of gross debt while increasing the rate of increase as a percentage of GDP.

During Bill Clinton's two terms debt as a percentage of GDP fell, gross debt leveled off and public debt decreased.

Then G.W. Bush took office and debt surged upward. During G.W. Bush's 8 years, the increase in gross debt appears to have slightly exceeded the increase during the 12 years of Reagan and G.W. Bush combined. G.W. Started two wars, Afghanistan and Iraq. However, neither the Korean War nor the Vietnam War seem to have increased the debt. It isn't like Iraq and Afghanistan are “worthy opponents” as was the case with WWII. I don't think war explains the rapid rise in debt under G.W.

With the arguable exception of FDR, it appears that Democrat presidents maintain or decrease debt. The same can be said of Republican presidents up until Ronald Reagan, then all hell breaks loose. Since Reagan, Republican presidents have run up our tab like drunks on a binge. Yet, to hear those Republican presidents and their spin doctors talk, one would get the impression that Republicans are the epitome of sound fiscal policy.

By the time G.W. Bush left office, gross debt was approximately 83% of GDP. Graphically extrapolating, I estimate that gross debt would have been 100% of GDP very near the beginning of 2010 and would have beat the WWII record 120% by 2011.

Extrapolating gross debt, we should owe well in excess of $13 trillion dollars as of this writing. According to U.S. NATIONAL DEBT CLOCK, today, 8 May 2010, we owe $12,941,038,878,533.84. So, the actual gross debt falls at least $60 billion short of my extrapolation which hopefully means the rate of increase has decreased under Barack Obama.

However, since the rate of increase at the end of G.W. Bush's term was approaching vertical (approaching infinite debt per year), I have low confidence in the validity of my extrapolation. Given the numbers I have here, I will say it is rather foolish for anyone to blame Obama for our truly gross gross debt when it is as plain as day that he didn't created hardly any of it. Only time will tell it will level out as it did from 1945-1981, or hopefully fall as it did under Bill Clinton.

More Graphs:Data from Wolfram|Alpha. Images modified**
US GDP 1929-2009

Per capita Federal Spending

Per Capita Federal Income (Taxes)

In these three graphs, we see that GDP growth has increased more or less smoothly and exponentially no matter who is president. The one glitch in the curve near the end of G.w. Bush's second term, may be when the financial crisis began.

Per capita federal income is likewise smooth. That is until roughly 2001 when there is a distinctive squiggle down. My first thought was that 9-11 caused a mini-recession we could blame on Osama Bin Laden and crew. However, if you refer back to the GDP graph, it seems like the mini-recession only had a negligible effect on GDP. I assume federal income is a function of citizen and corporate income and tax rates. If that's correct, then perhaps this was some sort of drastic tax cut.

However, if you look at per capita federal spending, there is no corresponding reduction to make up for the lack of income. In fact, during G.W. Bush's eight years, federal spending increased at a greater rate than at any other eight year period from 1952 to 2009. Per capita federal spending roughly doubled. Contrast it with the previous eight years under Clinton were spending increased about $1000 per person, instead of about $5000 under Bush.

*Truth and Politics Org: Graph 1: US military spending as a percentage of GDP, 1940—2003
Provides further evidence that the debt growth in the 1940's was due to WWII military spending. Neither the Korean War nor the Vietnam War appear to have had a significant impact on the debt.

**Image is from Wikipedia: United States public debt except I added the background colors, president names, and extrapolation lines in Gimp. I also proportionately scaled the entire image such that there were 100 pixels per decade to aid in accurately placing presidential terms. The image may have been scaled again in the process of uploading it here.

Other sources:
http://en.wikipedia.org/wiki/List_of_Presidents_of_the_United_States
http://www.brillig.com/debt_clock/
http://www.wolframalpha.com/

Saturday, April 10, 2010

My First Go Go

Today I decided that my first go at the Go Programming Language should be to learn how to log errors to Stdout and a log file. I thought I'd have to write a logger from scratch, but it turns out Go comes with a logging package. With more difficulty than I expected, I wrote this snippet:

package main
import (
"log"
"os"
"fmt"
)
func main(){
file, err := os.Open("./test.log", os.O_WRONLY | os.O_APPEND | os.
.O_CREAT, 0666)
if err != nil {
fmt.Print("error opening log file", err)
//TODO: bomb
}
l := log.New(os.Stdout, file, "", log.Ldate | log.Ltime | log.Lmicroseconds | log.Llongfile)
l.Log("WTF")
file.Close()
}

It logs something like the following to the console and the file ./test.log
2010/04/10 08:57:07.921499 /home/gdg/go/src/pkg/log/log.go:157: WTF

Things I learned:
  • 0666 != 666, 0666 == 438. The "0" (zero) in front of the 666 means Octal, not zero thousands, so 0666 is the same as 438 in regular base 10 (and that's a ten, not binary for 2). Somehow I forgot that in "chmod 666 foo.bar" the "666" is just understood to be in octal.
  • Even though the documentation says open accepts O_RDONLY, it doesn't. You have to do os.O_RDONLY to open a file for reading. I guess that's because O_RDONLY is part of the os package and not defined in an os.h header file like it probably would have been in C.
  • You have to do log.New(...blah...) to pass the log file handle(s) (object(s)?) to log.
  • This nonsense doesn't work: log.Lmicroseconds = true, log.Lmicroseconds=1, or log.Lmicroseconds(true). log.Lmicroseconds, as the documentation clearly states, it is a constant, not something you set. These constants can then be OR'ed together and passed to log.New(). How do very concisely change the flags being used for log.Stdout? Hell if I know.
  • When writing code documentation for public consumption, it would be a good idea to provide short examples of how to use the code. When documentation is written by the coder, the coder has been immersed in the code for so long (s)he simply will not think about all of the "obvious" details that make intuition possible. Someone who has spent all of ten minutes using the code isn't going to be able to make the same intuitive leaps. Working examples for every package would force the documentation writer to include the "obvious" details--otherwise it wouldn't compile. Yes, there are tutorials which helped me quite a bit, but they weren't enough to help me understand the log package right off.
I still need to figure out at least one more thing. Currently it prints "/home/gdg/go/src/pkg/log/log.go:157" which is a file in to Go source code. I'd prefer that it print my file, and the line number for: l.Log("WTF")