Wednesday, September 24, 2008

Pain train is coming to town.

Holy cow I am very tired. In addition, the US capital markets seem to be going down quick and there isn't any real hope they will get better any time soon.

So, the quick summary is that for a long time housing prices had been rising. During this period some very questionable loans were made because *if* the house prices kept raising even if the homeoners couldn't pay the loan off the bank was left with a house that was worth more than the loan was worth. Thus from the bank's point of view it was a win-win. Huge adjustable rate loans matched to properties that couldn't drop in price.

Well the reality of the situation is that properties definitely can and do drop in prices. There is really no such thing as a safe real estate investment.

From the homeoner's point of view, when the property values rise this is awesome. Put down a 10 or 20 grand and you leverage a at least 2 or 3 hundred thousand dollars. If it rises, lets say 5% you have just about doubled your investment. This is called leverage and it really works both ways. Should it fall 5% you lost twice what you put in.

A lot of people bought houses they could barely afford in order to leverage the most amount of money they could. By barely I mean that for all intents and purposes they could not afford these houses.

Now lets say you can't really make the payments on the loan. Then you sell in the best case or default/foreclose in the worse case. If the property value has appreciated, then the bank wins whether you sell or whether you foreclose. If the property values drop, then the bank is only better off if you sell.

Lets say you have a lot of these properties. You are the bank. Now a ton of them have dropped substantially in value *and* your homeowners (odd term when there is a mortgage involved) can't pay you are screwed. Thus you lost a lot of cash.

In any case, this is probably a gross simplification but a huge amount of capital seems tied up in bad mortgages on bad properties.

The effect of banks going out of business is that everyone from you to your grandma to the farmer down the road cannot get capital easily. This will hit businesses increadibly hard because it is difficult to buy stock without capital. Thus the easier it is to get capital the easier it is to buy stock. This is also important because farmers need to buy seeds and, quite frankly for the US economy, people need to buy houses.

--digression--

A lot of stinky Europeans are talking about how much the US deserves this because we have an extremely unregulated financial market. I think this is a load of bullshit, personally. Europeans tend to be the most fiscally risk-averse people you have ever met. They like to have a single job for 1000 years and throw a fit when they might actually have to change that job. Of course our financial system is more unregulated but in the long run I think that it is probably more effective because of this. We think of all sorts of interesting ways to make money that you just can't do in Europe because the risks are too great. Every now and then there is going to be a serious correction; but at least we *can* buy a house. At least we *have* access to good fair credit.

So if you listen to a lot of BBC and various other outlets you will continually hear the reporters ask if this will lead to more regulation. I sincerely hope it will not; that regulation will make capital for small businesses harder to come by and make owning a home a much more distant proposition for millions of Americans.

--end digression--

In any case, we are going into a serious correction. This will most certainly end in a recession but it should not end with a depression. A lot of smaller businesses are going to have a hard time because they can't invest in stock required for their operation as easily. A lot of people are not going to have houses or are going to lose their houses and that is the way it is.

So lets talk about the government's buyout plan. First, let me explain my biases because I am sure they have colored my analysis of the situation.

When I hear the Bush administration talking about $700,000,000,000 of money going to someone I assume it will be the top 1% of Americans it will go towards and it looks like initially this is the case. I haven't made it into this percentage group yet so of course I think this is utter bullshit.

They want to buy the bad assets from the banks. This will let the banks off the hook and leave the taxpayer holding onto approximately $700,000,000,000 of foreclosing mortgages and poor property values. Should the taxpayer hold on to this long enough they will surely get this money back. The main question is how long is long enough and what is the real return on investment.

Notice that I didn't say they will buy the high-interest-rate ARMs from the home owners. The home owners get no protection; the banks and financial institutions get to continue business as usual. Most likely the managers of said banks will continue get their awesome bonuses just as they would have anyway and a lot of them will talk about how hard the crisis hit them to ensure the proletariate don't get too upset.

They needn't worry about it, however, as the proles will never revolt.

The Democrats in congress are attempting to provide the other side of the equation. They want some of this money to go to homeowners buy most likely refinance the sub-prime mortgages into ones that have a little more lenient interest rates.

Now, let me quickly say what is really going to happen. Should congress authorize this gigantic bill who controls all of this money of the long run? Somehow money will start flowing into some account, and some group of legislators will be put in charge. A bit of it will go towards the advertised uses; whether the banks or the homeowners. The rest will be buying the most cocaine, hookers, and bridges to nowhere you have ever seen in your life. Those senators will suddenly have amazing reelection campaigns because whoever stands to get even a little bit of that money will fucking hook a brotha up.


Which is why, at the end of the day this just will suck for a while and who knows what will happen. Everyone will say how they supported whatever solution the legislative branch comes up with and talk about how they were really working for the American people. These guys are assholes. First rate assholes.

Chris

Saturday, September 20, 2008

Blogging is hard

Writing blogs, at least for me, is one of the harder things i have ever tried to do.

I guess I imagine a reader who is as critical as I am of things, perhaps everything.

Depending on how cocky or conceited you think I am, you may consider me completely ignorant of how I sound to other people. Perhaps a few of you think that I have no idea my effect on other people or that I have no knowledge of how different I seem to other people.

I know that I come across as perhaps over-emotional and very sophomore. I also realize that I have had a really difficult time communicating the deeper things that I think about. As everyone I have ever met, I of course feel I have very intelligent, important things to talk about. Just like everyone else, however, I also know that I am an extremely poor judge of what will be considered intelligent, interesting or anything else to other people.

In retrospect, I don't find the really interesting bits of things I come up with in the blog. One of the things I really enjoy doing is shocking people with a deep or clever insight. I love the look in someone's eyes when you say something that they really consider to be abstract or interesting. It seems that my ability to do this is based, at least partly, on social circumstances. I cannot do it in writing; it is something I have to feel the flow of the conversation to really do it well.

I also feel, however, that it is at least partly rude or perhaps even violent to do it at will. Because I love to do it so much I really never considered the fact that it might upset someone or make someone feel uncomfortable. In a way it kind of rips control away from the person you do it too. A lot of times it may even be just showing off; perhaps a super sophisticated way to bully someone.

I guess the sad part of it also is that I appreciate sophistication and extremely subtle communication. Unfortunately the type of people who I would usually do it to may be exactly the type of people who would be most upset or uncomfortable with someone coming in and doing it to them.

Anyway, this is hard for me. I walk a line between trying to be unemotional enough to be intellectually stimulating while trying to also have the courage to express things that are hard for me; the expression of such does leave me a little more open than I am otherwise comfortable with.

Chris

Saturday, September 6, 2008

Amante thoughts

Back at the coffee shop, getting ready to go out tonight and having some tea and a gin n tonic.

This post is going to be quite idle, so tune out now if you have better things to do.

It occurred to me that what I really like about well-written software is its composability. The more composable a piece of software is the more options it gives people to do something cool with it.

I spoke with my father about building tools for the pathology lab and he had a superb insight. Please place this into context; my father and I are a lot alike but technical ability we don't share. He has the social ability that I lack and I have a higher order mathematical ability.

Anyway, he said that you want to make every tool as general as possible; this is what makes it useful. I didn't expect to hear that from someone who is not an engineer but it is one of the golden truths of computer science. Most likely it is the golden tool of anyone who builds and uses new tools in different ways; it then occurred to me that the diagnosis that he does probably involved quite a bit of problem solving. For some reason this never occurred to me.

This is the one primary advantage of functional programming if you are talking about the microscopic version of composability. It is also one primary advantage of open source software when are are talking about software development in the large.

I think we actually took quite a large step backwards in terms of software composability and reuse when we started compiling every down to binary. For some reason it seems that c,c++ based systems are inherently tougher to compose. Perhaps because malloc is a global, perhaps 1000 other reasons.

--context change--

It seems there is a lot of contention around garbage vs non-garbage-collected code. As far as monads and monadic forms are concerned, couldn't you consider the memory allocation system to be a monad? Isn't creating a new object implicitly changing state of the system in one way or another? Thus shouldn't every function that allocates new data use a monad passed in?

Granted this would be tedious but it would also allow you to use different memory management systems with different pieces of code.

Chris

Friday, August 22, 2008

A Change in Programming Style

I am sitting in Amante coffee shop in Boulder, just kind of doing a bit of code and waiting for the night to start. A salsa band is playing soon nearby and I need to burn some time.

A jazz band just started to play in the shop and they are quite melodic and smooth.

It is almost worth it to just sit here and chill, thinking about random thoughts about life and lambdas.

A while back I started to get a few symptoms of RSI. Mainly I was getting tendinitis in my fingers. It *still* isn't gone but it is a lot better than it used to be.

But that experience really prompted me to think about what I could possibly accomplish at the end of the day. It occurred to me that I really did a bit more work than I needed to. I would spend a lot of time typing something, think of a better way, and then spend a lot of time typing it again.

Needless to say, on large projects this was just not going to get me anywhere. I would also get frustrated with how mundane some of the code I was writing was and just writing absolutely as fast as I could. This was somewhat effective, but I also would not necessarily cover all of the bases when I did this.

Anyway, I still work pretty fast at times. This week is an intense week, I am working multi-pass effects into a somewhat sophisticated effect authoring system and really getting into it. They will be very powerful and quite beautiful when they are running, but what I can get done under the time allowed is only so much.

A large change has happened when I am working on my own home projects. Rarely do I spend more than about 10-20 minutes typing. A lot of time I spend just looking at the code and trying to figure out some way to do what I want to do with the least amount of typing.

I spend a lot more time researching different ideas and trying to figure out what language theorists are up to. I spend a lot of time just trying to visualize how I would like whatever I write to look like when I am done.

In any case, I don't type nearly as much. I also don't type nearly as quickly.

Now for an interesting although really obvious thought. The longest lived systems tend to be the most programmable. It is one thing to design your application for plugins and such but that is a very...boxed sort of programmability. Shove scheme or javascript into the application and enable a sort of live editing and updating. Excel does it pretty well! So do a handful of other applications.

But the point is, the more programmable you build the application the better off you are. Don't have a fixed data model, avoid anything fixed if it is an application of any significant functionality. Live coding is where it is at, why code any other way? I love F# and haskell; those work well for foundations. The top layer needs to be typeless and crazy dynamic.

Chris

Thursday, July 31, 2008

Time passes

Lots of applications incorporate animation. In fact, I would say that animation and interactivity are the two hardest things to add well to any application. I don't intend to address interactivity as I really don't know that much about it. So then we are left with time.

What exactly is animation? By animation, I generally mean interpolation; not frame-by-frame. I mean that you have something like two values, and an equation that takes you from value one to value two based off a third, independent variable.

This is a generally very useful and beautiful idea. Something really cool that Maya lets you do is it allows you to add a property that controls a set of other properties based off some interpolation of the original property. Lets say you have an animated face. You make it look like it isn't smiling and take a snapshot of your data (this snapshot is usually called a keyframe). Now you make it look like it is smiling and take another snapshot. Figure out the differences between the two of them and add a property where when the property is 0 the face isn't smiling and when it is 1 the face is smiling.

Crazy and simple; but the results of allowing the users to do this can *greatly* simplify a lot of tasks. Because the next thing an artist will do is to add a set of properties that describe a set of facial expressions and then try to play with all of them and see what happens. They then get completely bizarre output that is often delightful and have expressions on characters that no-one really understands either what the expression means *or* what is mathematically going on underneath the covers.

So there we have something *animating* due to user input. Now lets say you have a clock that continually increments based on time. You patch this value into the facial animation engine and all of a sudden the person may look like they are laughing (assuming the value is moded by its range). But that brings up another topic; what sort of transformations can you do on the input stream to get interesting behavior?

What if you take twice the range of the input and mod the clock by twice the range. If you time is in the upper half of the range then you run it backwards; if it is in lower have you run it forwards. This would be called ping-pong, and would make the animation bounce between the interpolations like someone dancing or doing facial exercises.

What if you multiply the input by a number? You can see that how you manage this input stream *also* gives you ranges of creativity and interesting effects?

So you have some function that takes input that ranges from 0-1 and produces output based on keyframes. You get all sorts of interesting properties by controlling this input. Lets say you use a bezier function to control this input range. Then you get bezier animation; except it is normalized so you can take the same bezier curve and apply it to several inputs. You can merge input streams by using a combination operator like divide or add (or subtract). You can do any number of crazy input nonsense and really produce some interesting stuff.

You can also setup processing graphs of these inputs. This will mimic behavior that makes a set of animations run in the *time context* of other animations.

So now lets get back to applications. Lots of applications allow animation. But none (or very few) of them allow you to setup arbitrary processing graphs to experiment with arbitrarily complex and clever animation systems. Breaking animation down into its components really allows you to do some interesting things.

For instance, what if the beginning value *isn't* a keyframe? What if it is based on something else; like an object's position or something like that. Then the animating object will animate from one object to a point in space. We called these dynamic keyframes; they are cool; I swear it. They allow you to mix interactivity with animation; without them you run into a lot of situations where you just can't get the object to move around reasonably.

We have an acyclic directed graph of floating point processing routines (at least; presumably other information could flow down this graph along with the floating point values). We have an object that generates a consistent increasing signal, we have things that will *reset* that signal when told so it appears to start from zero. We have sets of functions that given a floating point value can produce another floating point value. By combining these functions in clever ways we produce sophisticated and somewhat non-obvious such as character animation. But the point is that I think it would be cool to allow very open manipulation of this processing graph.

Chris

Saturday, July 26, 2008

Concurrent Patterns, Part 2

http://citeseer.ist.psu.edu/trinder98algorithm.html

This is more of what I was getting at; although for massively parallel systems the actual examples are all off the mark.

So far I have examined two algorithms; bitonic sort and parallel prefix scan. I have some clarifications on the parallel prefix scan.

You can visualize the two parts of the parallel prefix scan starting with n threads, and at each stage decreasing the number of threads by n/2 till you have 1 thread. So the algorithms starts with an inverted pyramid of threads.

Second off, you run from 1 thread back to N threads; this is a normal pyramid assuming you picture time increasing down; each level has 2*n more threads active than the level before it.

So we are all used to the terms gather and scatter. The parallel prefix scan basically maps a certain type of gather operation followed by a specific scatter. I believe the descriptions given in the paper really are not very good; and in any case the algorithm isn't easy to visuals *even* if you attempt to visualize it in terms of gather and scatter. All gather and scatter do is provide the thread management in this case.

Next up is the bitonic sort. That is an algorithm that sorts somewhat efficiently (not that I know a better algorithm) in a massively parallel system. It has an interesting property in that it takes a fixed number of stages regardless of the condition of the input. This algorithm is somewhat difficult to visualize; and the description I see on the web are generally really bad. Luckily I bought a book on massively parallel systems a long time ago and it contains a really, really good description of the algorithm.

This contains some pretty darn cool visualizations of it working, however:
http://www.tools-of-computing.com/tc/CS/Sorts/bitonic_sort.htm

Anyway, if you visualize the algorithm correctly, which is exactly what a parallelization strategy is supposed to provide for you, then it isn't quite so darn tough to reason about the algorithms. Bitonic sort is very cool in that it basically builds up inversely sorted sequences (increasing/decreasing) called bitonic sequences from unordered data. Each stage takes in twice the number of elements as the stage before it, and it requires log(n) stage-groupings to work correctly.

It all comes down to algorithm visualization and then concise implementation. I believe that separating code from parallelization strategy helps in both respects, and the parallelization strategy should be reusable for different problems. Furthermore I believe that a system build to support the use of parallelization strategies could provide much more benefit in terms of debuggability, memory and speed profiling as well as optimizations than a system that was not built with such steps in mind.

For instance, lets say I want a parallel max/min operation. I would use the gather (begin with many threads; end with one) parallelization strategy along with some min,max operation. The compilation system could check that I am accessing the shared memory or scratch pad as efficiently as possible and could generate the code to run the operation efficiently taking into account the fact that you are using the gather pattern.

This is a trivial example, but I guarantee it wouldn't work the way you think it would upon first attempt on a CUDA processor. Unless you already implemented sum, because min/max are identical operations to sum, and would use the same gather pattern.

Chris

Sunday, July 13, 2008

Ruminations on opengl

I have been rolling the idea of using thinking of rendering a particular item to the screen as executing all of the opengl state calls used for that item. All of them.

Meaning glEnable(GL_BLEND), as well as glDisable(GL_CULL_FACE) as well as glUniform and glUseProgram.

Given all the necessary state to render a given object, you have a large state vector. Now it wouldn't be efficient to actually program like this, but it makes sense, and sets the stage to think about things in an interesting way.

There are two concepts that I believe are important here:

First, given the set of objects you intend to render, I can produce a set of opengl state vectors assuming you need to set every single opengl state variable for every single item you want to render.

Now you would like to optimize this. Lets say you render a couple times and record, for each state item, if it was different from the last state item and if so, now many different items you found.

Now you sort each state vector by the number of different instances of each state property you found. Next you sort your entire render list by the state vectors. Now if you walk through the state vectors you are guaranteed to need to change the minimal number of gl state for each item in the state vector. You could add expense information to different operations in the sense that you some gl state properties are expensive to set (glUseProgram) and some aren't.

That gives you an extensible way to order your rendering operations on opengl objects where actually changing the state is slowing the program down.


Lets now take a look at exactly what a state vector is, or perhaps rather what it reminds me of.

The other place I have seen a large number of state items was a CSS system for html I wrote once. The result of a success full CSS system is a large vector of properties you apply to this html object during the rendering phase.

Perhaps there could be a graphics css system where the result is the opengl state vector you need to rendering this particular piece of geometry? I need to think about this for a while to see if it goes anywhere, but it is a start.

Chris