Weight Loss (14.7 kg, 32.4 lbs)

College Petitions (1 of 5)

With my work on BooGame, one of the things I wanted to know is if my generics-based vector library is actually better or worse than hard-coding the entire coordinate system. I like PointF, but the original BooGame used something else. Physics2D.NET used a third option. And I used all three libraries at once. The annoying point is that simply everyone reinvents the wheel when it comes to core libraries like vectors, matrices, the like and it is kind of annoying. I'm guilty of that, actually, for the same reasons most other developers reinvent the math wheel.

The built-in System classes are fairly limited. You have Point (integer) and PointF (single precision). No PointD, PointL, or anything like that. Also the rest of the math concepts lag pretty far behind.

There is also AdvanceMath, which is used by Physics2D.NET. I like the library, but AdvanceMath's precision is determined at build time and you can't really get it to co-exist with the other precision (i.e. same class names and assembly). I couldn't easily find a way of making it a proper library that didn't break binary compatiablity with a simple build option.

There are other libraries, but most of the ones I found are closely tied into another library or a game.

So, I decided to roll by own, called MfGames.Numerics, but try to make it as pure of a library as possible. It doesn't even depend on MfGames.dll, my primary utility library. It is also generics-based so it can handle single or double precision values, integers, or even random classes. Eventually, I'm going to roll in matrix, curve fitting, noise generations, and other semi-fancy math-like things I occasionally use.

But, when you write something like this, you write for a given style. But, it is hard for me to get a baseline if I'm actually making a difference or just wasting my time. I want something as fast as an obsessively written library, like AdvanceMath, but flexible enough for generic-based algorithms. I already accepted that it will be slightly slower, but how much is a key point. In theory, with a generics structure, it should be almost as fast as PointF.

I stalled on BooGame because of this. BooGame had its own vector library and I spent a decent amount of effort converting to/from the various versions of PointF. I could use AdvanceMath, but I don't want to require a specific compiled version of that library. But, I wanted to know if the generics idea actually works.

Last night, I started working on a tool to answer this. It is a timing tool and I'm going to call it UnitT (unit timing, like unit testing). I'm making it entirely separate from everything, simply to give me a framework to test things like my Numerics library. It will also tell me if I'm close to actually writing something performant or just wasting my time.

I'm modeling this after NUnit, one of my favorite development tools. It focuses on timing of a single block of code, potentially even the same unit being tested repeatedly, and giving me something I can at least compare different implementations. Yes, this is working under the assumptions that all benchmarks are wrong. They are, actually, since you can take something blazingly fast and make it slow. But, slow is slow, and I'm looking for the slow no matter what I do.

I think this will be my project for the weekend. That and messing with the Numerics library. I'm hoping that I can produce something useful. If I can't, I'll find another variant. But, I still think there is a place for this, even if it is reinventing the wheel.

2009-04-24