leah blogs

March 2005

05mar2005 · Vlerq, or: Thrive for Ruby

I think it’s always a good thing when you have a weird idea, but someone implements it independently quite how you thought of it. That proves your idea was not totally absurd (or you and the other implementor both are… :-)).

Anyway, this happended to me in the case of Vlerq. I have thought of the idea of embedding a small, fast language (I had retroforth in mind) to write quick inner loops for data scanning before. Then, I get to know the people that wrote MetaKit—an embedded database, easy to use and fairly quick (which admittedly is a lot easier to do with embedded databases)—are at writing a fast, embedded Thrill (a dialect of Forth) implementation called Thrive for querying databases. They already have early bindings for Tcl and Python, and I’m right now at coding one for Ruby. The Python binding is less than 250 LOC, so that won’t take too long.

Unfortunately, noone ever did a Ruby binding for MetaKit, but who knows, maybe Vlerq will obsolete it. :-)

The source of Thrive is an excellent example of Huffmann encoding, by the way:

L S cString(P p, I i) { P w = Work(p); I n;
  if (i < 0) i += Length(p);
  n = lenAt(p[i]);
  if (n >= Alloc(p[i].p) || strAt(p[i])[n] != 0) {
    S q = strAt(p[i]);
    p[i].p = newBuffer(w,0,n+1); Length(p[i].p) = n; p[i].i = -1;
  return strAt(p[i]);

Whole Thrive is a single ~630 LOC C header (plus some optional extensions) and licensed under the MIT License. ;-)

NP: Dan Bern—Black Boys On Mopeds

Copyright © 2004–2018