Older blog entries for foster (starting at number 2)

I can't believe its been over 10 years since I last posted on Advogato. I'm hoping to get back to doing some serious programming again--so I've started renewing some of my connections. Enough with the research! I want to write code!

9 Sep 2001 (updated 9 Sep 2001 at 22:07 UTC) »

Last year I wrote a library to handle units in C++. After using it for a year, I found it useful enought that I thought I'd post it. The last project I posted was to sourceforge. But this time, I thought I'd enter the "big time" and post it to boost. (Boost.org is where the next modifications to the standards for C++ are being written today.) I'll see how harsh they are over there.

Here is my post to the boost news group:

Thanks for the kind introduction to boost. I posted my library on yahoo with the name of units.zip. As an academic, I'm used to receiving nasty referee's reports, so hopefully I'll be thick skinned about comments. I thought I'd say a few things that I learned about a quantities library from using one for the past year.

In reading over the postings over the summer I think there are two different goals a quantities library could aspire to. The first is the SI goal: avoiding crashing into Mars and all that. The second is catching programming errors by making signatures of functions more useful. I built my library assuming that the primary goal was the first one. So I built in the ability to have inches, yards, rods, miles, meters, etc. But when it came time to actually use it, I almost never gave explicit values. So the first goal seemed to be less important than I originally thought.

What turned out to be very important to me was the ability to have signatures of functions that were meaningful. To achieve this goal it is very important for the quantities to be user defined. Let me explain via example.

A physicist has nice concepts like length, weight, etc. Obviously they need funding (lots of it in fact) so they also would want to have a unit to represent money. For them, they would be happy with a single type called "dollars." But now consider a trader on wall street. They need not only dollar, but also yen, pounds, etc. From their perspective all the fancy units of physics could be lumped together as a single unit called "physical unit". So they would measure corn in dollars/physical unit, where physical unit would be a bushel, and gold in yen/physical unit, where physical unit in this case would be a Troy ounce. This mixing up bushels (a measure of volume) and ounces (a measure of mass/weight) would case them almost no confusion.

But units can get even more divided than that. A trader might want to have different sorts of dollars. Not only is it important to differentiate current_dollars, from future_dollars, but bids might want to be separated from asks. So there could be many different sorts of dollars.

In fact, the system that I use my units classes in has two sorts of time. Both CPU time and wall clock time are different units. Both of them are naturally measured in something called seconds, BUT these two different times measure different things.

My point is that as far as making programs easy to read, the crucial goal of a quantities class is to make the signature of a function say what the function expects when it is called. Thus you want as few different types as possible subject to the constraint that there sufficient types so that functions rarely have a useless signature. So my goal is to switch useless signatures like:

  • f(double a, double b, double c);

to:

  • f(Dollars a, Bytes b, Time c);

I've finally joined the open source movement for real. I've always been a "user" (at least since the early '80s) but I've finally GPL'd and released my first project.

I have a large project I'm planning on GPL'ing once it actually runs (computer go playing). But in the process of creating that, I created a bunch of Makefiles to implement Lakos' idea of levelization. A few weeks ago, I posted them on source forge (baby-lakos is the project name). I was primarily trying to figure out how to create a project and generally learn the ropes.

But I checked the stats, and a dozen people had actually downloaded it! That is about 12 more than I expected. I'm very excited! (This gives the project a ranking of 20%--I never understood what that number meant until I saw it for my own project.)

I have another small project that I think is ready for release. It implements units (lbs, kms, etc) in C++. I've been very impressed with how easy it is to set up a project with sourceforge. It rules!

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!