Feeds:
Posts
Comments

Myths about the Great Depression

Herbert Hoover was a doctrinaire, laissez-faire, look-the-other-way Republican who clung to the idea that markets were basically self-correcting. No. Far from a free-market idealist, Hoover was an ardent believer in government intervention to support incomes and employment. FDR didn’t reverse course. He went further down the path that Hoover had blazed. It was Hoover who initiated the practice of piling up big deficits to support huge public-works projects. Hoover championed many of the basic ideas — such as central planning and control of the economy — that came to be known as the New Deal.

The stock market crash in October 1929 precipitated the Great Depression. No. The crash precipitated wrongheaded policies that did major damage to the economy — a retreat into protectionism with the Smoot-Hawley tariff causing the internation economy to collapse. Some have argued that the increasing likelihood of Smoot-Hawley passing was a major contributing factor in the stock market collapse.

Where the market had failed, the government stepped in to protect ordinary people. No. Exports accounted for about one-third of U.S. farm income which were lost with Smoot-Hawley. This devastated the agricultural sector. Following in Hoover’s footsteps, FDR tried to raise farm income with quotas and paying farmers to remove acreage from production which caused higher prices for hard-pressed consumers and had the effect of lowering productivity and driving farmers off their land.

Greed caused the stock market to overshoot and then crash. No. The real culprit (as in the housing bubble) was a speculative fever induced by excessively easy credit and broken by the inevitable return to realistic valuations. The last thing Hoover wanted to do upon coming into office was to rein in the stock market boom by allowing interest rates to rise to a more normal level.

Enlightened government pulled the nation out of the worst downturn in its nations history and came to the rescue of capitalism through rigorous regulation and government oversight. No. In disregarding market signals at every turn, Hoover and Roosevelt were jointly responsible for turning a panic into the worst depression of modern times. Government was responsible for a lost decade of economic growth.

Another almost-election-day issue. Last minute articles by both Obama and McCain.

The last weekend before the election, and not surprisingly, the emphasis is on politics: An interview with Palin, and an opinion piece discounting the expected Obama win, “This election is not a mandate for Democratic policies. Rather, it is a wholesale rejection of the policies of George W. Bush, Republicans, and to a lesser extent, John McCain.”

Executive Pay

Banks owe executives billions in deferred pay and pensions. The estimated debt to executives for Goldman Sachs, J.P. Morgan, Citigroup, and Bank of America is $11.8, $8.2, $5.0, and $1.3 billion, respectively. Compare this to the capital injected into each bank of $10, $25, $25, and $25 billion, respectively. These obligations should be material but are essentially hidden on balance sheets.

Third Quarter GDP shrinks 0.3%

The U.S. economy contracted in the third quarter — the first of two consecutive ones technically needed to declare a recession. The numbers may later be revised up or down. We read earlier that while the U.S. economy grew in the second quarter, it was only on the back of strong exports.

More Deregulation Myths

The combination of Mr. Bush’s enactment of Sarbanes-Oxley and Mr. Spitzer’s Wall Street prosecutions contributed to America’s significant market share loss of initial public offerings. Even Sen. Schumer came to realize that Sarbanes-Oxley was causing a migration of business from Wall Street to London, Hong Kong, and even Dubai and comissioned a study of the problem. When the study was released in January 2007, he and Michael Bloomberg wrote, “our regulatory framework is a thicket of complicated rules.” Without reform, “we will no longer be the financial capital of the world.”

The Bush administration set an all-time record in 2004 when it published more than 75,000 pages of proposed and enacted rules in the Federal Register. Were these rules a watering down of earlier standards? Not by cost. Economist Mark Crain estimates the regulatory cost of these rules at more than $1.1 trillion, up an inflation-adjust 16% from 2000. Agency enforcement budgets have increased each year since 2004. When it comes to regulatory budget increases, Bush is in a class by himself with an increase of almost 68% during his two terms — the largest increase in 50 years.

There is no record of deregulation here.

Credit Market

The commercial paper market is again showing signs of life.

Patents

Patents on processes must either “transform [an] article to a different state or thing”, or be “tied to a particular machine”. Industries like banking, accounting, insurance, and software are affected as the test for business-method patents becomes more stringent.

Nothing catches my eye.

Nothing catches my eye.

Gitmo

Even though the U.S. wants to transfer Guantanamo detainees to other countries, it has concerns that dangerous prisoners will either be freed or be treated inhumanly. An estimated 255 detainees are still held there (down from 780 in 2003).

Blu-Ray

Blu-Ray has yet to catch on with American consumers, and manufacturers and retailers want to boost adoption before digital-movie downloads and video on demand overtake movie disc sales and rentals. They have greatly reduced prices on entry-level players, but Blu-Ray disks still cost twice as much as DVDs.

U.S. Automakers

Without a merger and possibly an assist from the federal government, two of Detroit’s automakers could run out of cash within a year. It could set off a chain reaction across the U.S. auto industry, choking off parts supplies to healthier Asian and European car makers and also leaving the federal government to make good on pension guarantees for hundreds of thousands of auto industry retirees.

Unemployment

Usually unemployment, a lagging indicator, peaks after a recession has ended. That the labor market is already as weak as it is suggests a deeper and longer recession than previously thought. When this issue was printed, unemployment rate was 6.1%. It has since increased to 6.5%.

5S

5S is the first step in lean manufacturing techniques and six-sigma, and in recent years, 5S has been moving from the plant floor to the office cubical. Translated from Japanese, the five S’s stand for sort, straighten, shine, standardize, and sustain.

5S is obviously useful and necessary for shared work spaces. Even for something simple like picking up a safety jacket and walkie-talkie needed to direct cars in a parking lot, it is more efficient to go to a closet where the jackets are always kept than to look in three places they might be or try to find someone who is the designated jacket-manager.

In an office environment, the efficacy of 5S is more suspect. It does help to work against the natural office pack rat, and it also serves as counterpoint against those whose naturally make themselves official jacket-managers, but for information workers, much of what occupies modern officies is on their computer, in their E-mail, and on servers. Having lived under 5S for two years, I can assure you, its implementation in our office cost days and saved me nothing. Management used it to shut down a shared lab which one engineer was using as his own private stash space and kept intentially cluttered to prevent other engineers from invading. It was turned into a conference room. The rest of us were using our cubicles as temporary labs (power supplies, logic analyzers, EPROM burners, etc.) which was more efficient for us but was at odds with 5S because everything was ‘out’ and being used.

I’ve since changed jobs, but the habit from those two years is to not bring anything physical or tangible to work — no books from my vast library at home, no paper, no plants, no furniture, nothing. Almost all of what I need is on-line and digital anyway. Having nothing makes moving offices much easier. However, my office is left uninviting and cold, and it would be more efficient at times if part of my library was at work. Probably one-third of my work is accomplished working remotely, so implementing 5S to make a few cables less visible just making it pretty for people who pass by.

Wealth Gap

The financial crisis is closing economic inequality because it is draining the rich of some of their riches.

Small Banks

Small Banks worry that bailed-out larger banks will use their new cash to buy smaller rivals — a taxpayer-subsidized consolidation.

The two ‘Dragon’ compiler books are wonderful, and the labeling described here is but one of the several methods the Dragon books describe, but they leave Ershov numbers and labeling open to confusion. In the First Edition, the fictional target is a two-address machine whereas in the Second Edition, they change to a more RISC-like, three-address machine. This impacts how trees are labeled.

For example, on a two-address machine (like x86 or x86-64), we need only a single register for multiple operations:


LD  R0, a
ADD R0, b
ADD R0, c

Because of this, only the first instruction (LD) is deemed to use a register. The second two instructions require no additional register and therefore are assigned a zero label. The First Edition Dragon book calls the first instruction the leftmost child. The others are called right children.

In the Second Edition, with its three-address machine, every leaf node requires a register and all operations are performed on registers. They describe the machine as having other addressing modes, but their code generator does not use them. So, the corresponding code looks like this:


LD  R0, a
LD  R1, b
LD  R2, c
ADD R0, R0, R1
ADD R0, R0, R2

Neither edition draws enough attention to this difference — perhaps assuming it will necessarily be included as part of the classroom presentation. The important thing to remember is that in the labeling pass, each node is marked with an upper-bound of the number of registers required to evaluate the node.

Continuing from Part 1, we start describing hatori.y. Notice the tokens (NUMBER and ID) used by the updated scanner are defined here. Bison will produce hatori.tab.h from this. Also, sometimes we manipulate pointers to Node structures and sometimes we manipulate an index to either an ID or NUMBER, so the parser needs to know which pieces are associated with which type:

%{
#include <stdio.h>
#include <stdlib.h>
#include "hatori.h"

void yyerror(char *s);

#define YYERROR_VERBOSE

Node *g_tree = NULL;

Node *MakeNode(int op, int idx, Node *left, Node *right)
{
    Node *p = (Node *)malloc(sizeof(Node));
    p->op = op;
    p->idx = idx;
    p->left = left;
    p->right = right;
    return p;
}

%}

%token NUMBER
%token ID

%union {
    Node *p;
    int   i;
}

%type <p>  all stmts stmt expr term factor
%type <i>  NUMBER ID

%left '+' '-'
%left '*' '/'
%right '='
%right UMINUS

We could also have evaluated the tree as we parsed, but building the tree first and then traversing it later is easier to describe. Continuing with hatori.y, the parsing rules are straightforward, and as a side-effect, create a parse tree rooted at g_tree:

%%

all      : stmts                   { g_tree = $$; }
         ;

stmts    : stmts stmt              { $$ = MakeNode('S', 0, $1, $2); }
         | stmt                    { $$ = $1; }
         |                         { $$ = NULL; }
         ;

stmt     : ID '=' expr ';'         { $$ = MakeNode('=', $1, $3, NULL); }
         | ID ';'                  { $$ = MakeNode('P', $1, NULL, NULL); }
         ;

expr     : expr '+' term           { $$ = MakeNode('+', 0, $1, $3); }
         | expr '-' term           { $$ = MakeNode('-', 0, $1, $3); }
         | term                    { $$ = $1; }
         ;

term     : term '*' factor         { $$ = MakeNode('*', 0, $1, $3); }
         | term '/' factor         { $$ = MakeNode('/', 0, $1, $3); }
         | factor                  { $$ = $1; }
         ;

factor   : '(' expr ')'            { $$ = $2; }
         | '-' factor %prec UMINUS { $$ = MakeNode(UMINUS, 0, $2, NULL); }
         | NUMBER                  { $$ = MakeNode(NUMBER, $1, NULL, NULL); }
         | ID                      { $$ = MakeNode(ID, $1, NULL, NULL); }
         ;

%%

Our new main() function first parses the input into a parse tree and then executes it:

int main(int argc, char *argv[])
{
    yyparse();
    Execute(g_tree);
    return 0;
}

Executing the parse tree is divided into two parts: an upper-level execution of statements, and a lower-level evaluation of expressions. First, here’s Execute():

void Execute(Node *p)
{
    if (NULL == p)
    {
        return;
    }

    if ('S' == p->op)
    {
        Execute(p->left);
        Execute(p->right);
    }
    else if ('P' == p->op)
    {
        Symbol *sym = &pIdTable[p->idx];
        printf("%d\n", sym->val);
    }
    else if ('=' == p->op)
    {
        Symbol *sym = &pIdTable[p->idx];
        sym->val = Evaluate(p->left);
    }
    else
    {
        printf("Unexpected command.\n");
        exit(0);
    }
}

As expressions are evaluated, their values are either assigned to symbols for use later or printed out. Here’s the expression evaluation:

int Evaluate(Node *p)
{
    if (NULL == p)
    {
        return 0;
    }

    if (ID == p->op)
    {
        Symbol *sym = &pIdTable[p->idx];
        return sym->val;
    }
    else if (NUMBER == p->op)
    {
        return pNumTable[p->idx];
    }
    else if (UMINUS == p->op)
    {
        return -Evaluate(p->left);
    }
    else if ('+' == p->op)
    {
        return Evaluate(p->left)+Evaluate(p->right);
    }
    else if ('-' == p->op)
    {
        return Evaluate(p->left)-Evaluate(p->right);
    }
    else if ('*' == p->op)
    {
        return Evaluate(p->left)*Evaluate(p->right);
    }
    else if ('/' == p->op)
    {
        return Evaluate(p->left)/Evaluate(p->right);
    }
    else
    {
        printf("Unexpected operator.\n");
        exit(0);
    }
    return 0;
}

And, finally, our updated Makefile:

all: hatori

hatori: hatori.l hatori.y hatori.h
        bison -d hatori.y
        flex -f hatori.l
        gcc -g -o hatori lex.yy.c hatori.tab.c -lfl

clean:
        rm hatori lex.yy.c hatori.tab.c hatori.tab.h

For the same example we used before,

b = 200;
a = 1 + (-b/2)*30;
a;
b;

we now get the following output:

-2999
200

In the next stage, Execute() and Evaluate() are replaced with a x86-64 code generator, but rest of the parser remains largely intact.

« Newer Posts - Older Posts »