Archive for September, 2008

The Paulson Plan

September 25, 2008

One more post in my drafts folder. I wrote this on Sunday (9/21/08) before we knew anything except that Paulson wanted $700B to buy bad assets from banks. I was right again: their solution is a bailout of the banks by buying well above the currently very low market price for mortgage backed securities. It’s unfair and I’m glad the Democrats are pushing for much tougher terms. It’s too bad they won’t let banks go bankrupt.

(more…)

Is there a commodities bubble?

September 25, 2008

I wrote the following post at the end of June, but forgot about it in my drafts folder. I guessed that there was a bubble in all commodities in the summer, and guessed that oil was inflated ~20% above “real value”. Looks like I was right: $145 at peak, now oil is around $106, down 27%. Corn and wheat are down over 20%. If I weren’t such a coward, I would be a rich investor by now.

(more…)

Ruby’s callcc might be broken

September 9, 2008

So after quickly picking up the basics for Ruby, I ran across an implementation of the amb operation, which does backtracking using continuations. So I tried writing a simple backtracking Sudoku solver, but it kept failing in weird ways. It looks like the continuation doesn’t get saved correctly. Here’s a simplified example where moving callcc onto a separate statement causes it to fail. Anyway, it looks like Ruby is dropping continuations in v2.0.

Ruby is strange

September 5, 2008

Today I learned Ruby. It’s a fairly simple OO language, but it has the kludgy feel of a language designed in a hurry. In particular, the design of closures appears to be half-assed. To summarize that link, there are 7 ways to implement something like a closure, but the semantics deviate in strange ways. There are other idiosyncrasies. For example, modules are used both to create namespaces and define mixins. Another is that two mixins that use the same instance names will collide when included in the same class. You can use mixins to fake multiple inheritance, but in the simple diamond problem, I couldn’t find a way to override the lookup behavior without resorting to reflection. All in all, I just don’t see what all the hype is about.

Industrial FP

September 3, 2008

This post points to a paper about Jane St. Capital’s use of functional programming for financial trading applications. In the paper, they explain that the important reasons for using OCaml versus familiar OO languages are better readability, performance and macros. Their use of macros is just to get a generic data printer. On performance, OCaml is fast, but the compiler doesn’t do a great job with some higher-order features, nor is there support for concurrency. On readability, they drop the “O” and just use Caml. They explicitly show all types so code reviewers don’t have to look types up to see what they are. This is also their complaint about inheritance in OO, that they have to look up all parents to figure out what an object really does. That strikes me as a problem with the editor, not with the language. Anyway, higher-order functions are just as mysterious as inheritance, but Caml programmers don’t seem to use it as much. IMHO, the primary reason to use an FPL is for the powerful type checker, which can catch more errors at compile-time compared to conventional languages with simpler type systems.