Wednesday, December 19, 2007

1929 here we come

In the New York Times' article today on Morgan Stanley's huge losses this quarter and subsequent sale of shares to China Investment Corporation, the article had this as its very last sentence:
"the People’s Bank of China continues to accumulate $1 billion a day as it buys up dollars to prevent the value of China’s currency from rising in international markets."
I saw Noam Chomsky speak at Columbia once and he said that you can often get the real news by reading the last paragraph of an article in the New York Times, he thinks because the reporter hides the juicy bits in the last paragraph so the editor doesn't get to it. The second to last paragraph is always a bit boring, and feels like it's just wrapping up, so the editor may just skim to the end.

Anyway, I finally understand what this sentence means. China has been buying dollars, which I guess means buying them on the stock market, and they've been really hoarding them, which takes tons of dollars off the market, keeping the supply low, which keeps their value artificially high. So China is our life support system at the moment. In return, we send them all our business. They make everything really cheaply and sell it back to us.

This government is in a dead panic, it seems to me. We're doing everything we can in a mad scramble not to go completely broke. We invaded Iraq to keep our hand on the oil spigot - not out of insanity, out of necessity. The moment we let go of that spigot (withdraw our troops), the cheap oil will go straight to China and Europe, and we are no longer the king of the planet. Meaning we will be very, very broke. The Iraq war was a big mistake, but it's no wonder no one really wants to withdraw (even Obama, sorry). The moment we do, the card castle falls. Our guns in Iraq are all we have left (well, along with our guns in Latin America and everywhere else in the world). It's the end of the empire, and the emperor is flailing wildly with a machine gun until he runs out of bullets to keep everyone from ripping his robes off, looting his castle and throwing him in the river.

It's all very depressing.

I wish the media would just discuss the situation openly and honestly - if they just told the American public what's really going on, instead of doing the usual election circus and talking about bullshit, the country could actually save itself because everyone would be highly motivated. But they won't, because the only way for them to stay in power is to try to solve the problem alone and keep the country in the dark, throwing whatever bullshit at us that they think will keep them in office.

But if everyone saw what was really going on, and why we're doing what we're doing, although we would despise our leaders I think we could save the country as a whole. We'd adopt a new energy policy immediately. We'd probably stay in Iraq because we're stuck there - no one knows the answer to that one, other than adopting a new energy policy that doesn't rely on oil. But Americans would stop buying SUVs and plasma TVs that they can't really afford and start trying to reverse things.

It makes me wonder if the United States is approaching communism while China approaches capitalism, that we're just slowly swapping places. We're already fascist. The problem with this country is the same problem with communism - a small group of people at the top can't possibly administer the entire country, one because it's impossible, and two because the people that get to the top are corrupt.

Hitler took advantage of post-WWI Germany's economic desperation to rally them behind his psychotic dreams of world domination and racist supremacy. Germany invaded Poland out of economic desperation, we invaded Iraq out of economic desperation. Hitler tortured Jews and Gypies in concentration camps, we're torturing Arabs in Guantanamo Bay. We've overturned the Geneva conventions because we're rampantly violating them, our leaders are seemingly immune to the possibility of impeachment, our phones are tapped, the rich are building a lifeboat and leaving the rest of the country to drown in the aftermath of their psychotic attempt to keep this ship afloat through brute force. Democrats and Republicans alike, they're the same candidate at this point. Their only goal is to stay on top.

I find this all terribly upsetting. I need a hot chocolate. But then I'd have to spend $4 at Starbucks.

Saturday, December 08, 2007

The Functional Representation of Data

What?

I just think this is damn cool, taken straight from SICP (Structure and Interpretation of Computer Programs) - the first-semester textbook at MIT, and the best textbook I've ever read on anything.

The idea is that you don't need to create data structures to represent data, if functions are first-order objects in your programming language, as they are in Scheme (among other languages). For example, to represent a pair of items, called x and y, one would usually think to create a data structure containing two slots of some kind, and then a function to retrieve the contents of the first slot, x, and another to retrieve the second, y. Lisp (Scheme is a variant of Lisp) comes with these functions, the first called cons, which creates a "cons cell" - a data structure holding two items together, and the others called car and cdr (for archaic reasons), which return the first and second item in the cons cell, respectively.

For example, we can create a pair containing the symbols 'jake and 'miles like so:

(define cons-cell (cons 'jake 'miles))
which creates a new cons cell that looks like this:
'(jake . miles)
and which is assigned to the variable we're defining called cons-cell. Then we can get back the first item in cons-cell by calling the car function with it:
(car cons-cell) => 'jake
and the second item with cdr:
(cdr cons-cell) => 'miles
But there's a way to do it without creating the cons-cell data structure at all, instead representing it using just functions.

Taking our cue from an example in SICP, to define our own versions of cons, car and cdr without using any additional data structures, we can define cons as

(define (cons x y)
   (lambda (selector)
      (selector x y)))
So cons creates a function (or "lambda") that itself takes a function as its argument (which it calls selector). It calls selector with the original two arguments x and y, and it's up to selector to return whichever of the two of them it represents. So we define car and cdr like so:
(define (car cons-cell)
   (cons-cell (lambda (x y) 
                 x)))

(define (cdr cons-cell)
   (cons-cell (lambda (x y) 
                 y)))
Which work the same way as the original car and cdr:
> (define cons-cell (cons 'jake 'miles))
<procedure #483282>  ;; however the system represents functions

> (car cons-cell) 'jake > (cdr cons-cell) 'miles

Voila - we've recreated the cons, car and cdr functions without creating an actual data structure, just by creating function objects that call each other. Purty cool, I thought.