API

GeoIP API for Chicken Scheme

| | | | | |

As part of a distributed, geographically load-balanced DNS daemon I’ve been developing in Scheme, I’ve put together a set of GeoIP API bindings for Chicken Scheme that I’m hereby making available under the MIT License.

This was the first egg I’ve developed for Chicken — not to mention the first time I’d needed to make any real use of Chicken’s FFI — and I have to say I was pleasantly surprised at how easy it was to create.

It was gratifying to be able to go from zero to completed egg in only a couple hours simply by looking at some other eggs for examples on how to use foreign-lambda , create a setup spec, and write the eggdoc documentation.

The GeoIP API subset provided by the egg is straightforward to use. Basically, you feed in a hostname or an IP address, and you get back a country code or country name. Country codes can be returned as either the 2-letter or 3-letter codes defined in ISO-3166-1.

Poor Man's MySQL API for Gambit-C

| | | | |

Lately I’ve been familiarizing myself with Gambit-C. This has mostly been preparatory work in anticipation of the imminent release of Termite, Guillaume Germain distributed computing system inspired by Erlang and implemented using Gambit’s serializable continuations and lightweight processes, scalable up to millions of concurrent threads.

Gambit is definitely one of the more interesting Scheme implementations out there, not to mention among the fastest; its creator Marc Feeley has been described as a performance junkie, and according to the Gambit manual, “with appropriate declarations in the source code the executable programs generated by the compiler run roughly as fast as equivalent C programs.”

However, despite its technical excellence, Gambit doesn’t, as of yet, have much of a standard library.

Yesterday I needed to interface Gambit with MySQL, and couldn’t find any existing binding to let me do that (though an SQLite 2.x interface does exist). As I wasn’t familiar enough with Gambit’s FFI system, I took the über-simple, lazy man’s approach: I created a trivial wrapper API on top of the mysql and mysqladmin command line utilities.

Syndicate content