Sunday, June 29, 2008

Al learns more CS crap, has an idea.

Friday at work I learned what continuations and coroutines are. All you CS weenies can make fun of me now. Go design a hardware interface and then come back and make fun of me more.

I've also been doing some GUI programming in the common event-driven style, and wondering if this is really the best way to do it. If you're writing a typical program for the console overall program flow comes very straightforwardly from the code. If it's time to get some input from the user you can just call a subroutine with some scanfs in it. If there are temporary variables needed for this you declare them in this subroutine and they go out of scope when you're done. In event-driven programs you have to keep track of your flow with mode variables, and put giant switches in event handlers. If there's some data you need temporarily for input but has to persist across a few events (say, while the mouse is dragging out an area) you'll either make it a member of an object that will be around much longer than needed or else have to allocate and destroy it manually. We try to hide some of this behind libraries of pre-fab components, but that doesn't make it go away.

To me it makes a lot more sense that the routine you're executing has to do with the task you're performing, and to switch over the possible events that might occur, as in a command-line program. And when Matt Elmer told me what a coroutine was, and then I looked up continuations, it just clicked that this is how GUIs can act like console apps. When the user starts dragging an outline, generating a mouse-down event, call an inputOutline function. Temporary dragging state is automatically allocated on the stack. You yield to the system and pass your current continuation. The system calls this continuation when an event occurs, passing in event info, and then comes your switch over events that make sense at that time. Ultimately you probably wouldn't want to deal with bare continuations I guess. And it seems like program flow might get either inflexible or overcomplicated.

Does anyone know if this sort of thing has been done? Or if it's been tried and encountered serious problems? I can't seem to find anything similar, and I am probably not a good enough GUI programmer at this point to implement it. Also I am slow, lazy, and spend lots of time running and writing music badly. Maybe I could do it as a LISP project someday.

Sunday, June 22, 2008

Three sides of the energy crisis

1. I saw a headline in the Sun-Times a couple days ago around lunchtime saying that Americans had driven 30 billion fewer miles in the last six months, and I was curious precisely what they meant by that, so I fished out a couple quarters and bought a copy. They meant that driving had gone down in the period from December through May, year-to-year. That's about 100 miles fewer per American, which of course includes people that don't drive anyway. The article claimed that the sharpest decrease came on rural roads and attributed that to decreased vacation driving. Even the notoriously insight-free Sun Times made the point that the era of cheap energy could be quickly ending. But what really struck me was the portraits of people affected by high gas prices. Some of their problems really seemed to have easy solutions that they couldn't see. A person that typically drove home for lunch mentioned spending extra money to eat out every day; in Chicago she probably spends more money on that than she would driving home and back. If the money is in a crunch bring a lunch in! One Uptown resident had cut back on volunteering on the south side because of the cost of gas to drive there; I'm sure there's no shortage of volunteer options in Uptown! Now that doesn't mean it's an easy change; I'm sure he has relationships on the south side and it hurts to have to change them.

I think some of that is just the nature of Sun-Times writing, though. Given a chance that paper will print gripes over insight nine times out of ten. Energy getting expensive? Everyone's surprised, most of all, us! If Chicago truly functions as a bunch of little neighborhoods tied together by the loop (this is the common refrain, and it's at least superficially true; I'm sure sociological studies have been written that explore this hypothesis more closely) then it's at least reasonably well set-up to handle the problem of expensive energy. Though it would be better if the CTA wasn't living from budget crisis to budget crisis.

2. There was a DVD of a documentary made a few years ago with a title like The End of Suburbia sitting on the kitchen counter, so I watched it. Instead of being surprised that energy was getting expensive this film's makers had known it would happen since the 50s. If I really wanted to stick it to these guys I'd say, "These guys probably thought the oil crises of the 70s were permanent; even a broken clock is right twice a day," even though that argument doesn't speak to their claims. Well, they probably cherry-picked experts for opinions on peak oil, but that's not going to stop people from hearing the important message that we need to make our energy supply more robust before oil becomes a problem. What will stop people from hearing it is that the message, in this case, is tied up in a culture war. Mixed in with the arguments about energy are plenty of cheap, sarcastic criticisms of suburbia.

Now I think some criticisms of the general suburban way of life are apt. Yards were made to be mowed, that sort of thing. As far as the topic of energy is concerned, the big argument is that car-dependent towns won't work in an era of expensive energy. But this is a film that at one point criticizes people in oil-consuming nations like the US for blaming so many other people for high energy prices. And it, in turn, blames a worst-case caricature of suburbia. Which is pointless when talking about a problem that affects everyone. Everyone in the industrialized world uses lots of energy, and if we have decades of severe energy shortages (the scenario leading to the title of the film itself) everyone will suffer badly, not just suburban people.

3. After I went to Urbana last weekend for Jess' birthday I stopped at my parents' house to drop off a cooler I'd borrowed from them for the MC200. When they saw me they were very relieved. They'd sent me an email the night before that I hadn't yet received (as I was downstate) because they'd heard about a naked bike ride in Chicago and wanted to make sure I wasn't taking part.

I don't think I would have done it if I'd heard about it. Unless I had a crush on someone that was going to be there and wanted to prove to her that I was, you know, just as willing to flash the whole north side as she was. But I'm sort of honored that someone, anyone, even if it's just my parents, would worry that I would do something like that. Clearly I at least look like I'm on the right track.

Saturday, June 14, 2008

Complaints, complaints!

All through the MC200 last weekend I was talking about my training and how I hadn't been doing enough speedwork or strength training and how I thus, predictably, had no speed. But on my run today I realized the reason that's been the case, and why I don't really mind. I've been running not so much for training, but to see the city. It's hard to even do timed segment training when you're out exploring new neighborhoods and parks (and very hard to do in Chicago traffic, too). And I think it's been worth it. I'm seeing lots of things and lots of people in the radius around where I live, and I'm enjoying that. Maybe I should be more strict about getting to the track once a week, since there aren't many hills around here to give me "free intervals" (in California I got in great shape because I ran at Rancho San Antonio once a week; I did it mostly for the scenery, but those hills got me fit). And when I gain a better knowledge of Douglas Park and maybe of the boulevards south and east of there I can use those areas for segment work.

Anyhow, today I tried to go running through Chinatown but I think I just skirted it. I approached from the southwest on Archer but turned due east on Cermak. I probably should have stayed on Archer. I guess I don't really know where the heart of Chinatown is, I was just looking at the label on Ye Olde Bikemap. I also went through some pretty nice residential neighborhoods in Bridgeport and Bronzevile, through industrial areas along the Chicago Sanitary and Ship Canal, and by the Cell. So now I've gone running directly next to every major Chicago stadium except for the United Center. Which, oddly enough, is the closest of them to where I currently live. I ran near the U.C. on my first Douglas Park run, where I ran along Lake between Albany and Halsted, but I didn't see it as as I went by (it's not a particularly tall or distinctive building, though I probably would have seen it if I was looking). I'm sure I'll do it at some point. Not at night, though.

Pannekooken!

This is pretty damn random.

After GRR last year we ate at a Pannekoeken Huis in suburban Minneapolis, which I guess is a regional chain of family restaurants featuring these wacky Dutch pancakes called Pannekoeken. And when they serve them to you, they say, "pannekoeken," loudly enough for at least several nearby tables to hear.

Today I saw a Pannekoeken Café, on Western just south of Lawrence (east side of the street, so on the outside of Lincoln Square, as in the real triangle of Lincoln Square, in case the incredulous among you want to StreetView it). I was on a southbound Western Ave. Express bus coming back home from Devon, where I went to get urad dal flour, because it was the only place in the city I was confident I could find it. It's a long trip. In retrospect, the recipe I'm following allows a substitution involving mung beans, and I almost certainly could have found mung beans in nearby Chinatown, so I probably should have just gone there. But by going to Devon I saw Pannekoeken!

OK, enough of that. Tomorrow is for cooking and going to Urbana. One of these days I will bike to Urbana, but not tomorrow.

Tuesday, June 10, 2008

Pilsen!

I just moved, for those of you that didn't know that. To Pilsen, not far from Cermak and Ashland, with Heather and Christina.

The move was done mostly in a Budget truck, which stopped at my apartment, then Heather's, then Christina's. Except that because the Internet was slow to arrive at this place I kept my computer and phone hooked up at my old one for a while and had to make a couple additional trips as a result of that. It is pretty nerve-wracking to drive one of those trucks on the city streets. So that's one more job that I absolutely don't want to have after globalisation destroys the market for soft, lazy, pampered American programmers. Although I can probably count on the energy crisis killing the market for fossil fuel-powered trucks. With any luck after the Great Crash(es?) I'll find something agreeable to do. Bike messenger? Professional pessimist?

I've had a couple of nice runs on the near south and west sides, and one right up to the Sears Tower and around Wacker Drive at night. I like seeing people, especially kids, when I'm out on runs, and there are lots of kids and parents out here all the time. They make me feel happy, because they're usually doing something joyful or funny.

And some time soon I should bike the boulevards from Jackson Park through Washington Park, Douglas Park, Garfield Park, Humboldt Park, Palmer Square, and to Logan Square. It looks on my bike map like the boulevard thing then sort of runs to the river and stops. That's where the bowling alley on Diversey is. So maybe a bike-and-bowl? Speaking of biking, my commute on bike to work is really quick now. Blue Island, Roosevelt, and Halsted are all very wide and fast. The Pink Line is also very fast compared to how the Red and Brown have been for the past year (it's probably always faster because it makes so few stops between 18th and the Loop; just Polk, Ashland and Clinton).