[Developers] Perl API (hi Hayden!)
Kirrily Robert
skud at infotrope.net
Sat Aug 18 22:56:05 UTC 2007
I'm sitting next to Kirsten at BarCampBlock in Palo Alto right now,
and we were just talking about Perl APIs. I'm reading the thread that
starts at http://lists.freebase.com/pipermail/developers/2007-August/000502.html
and thought I'd give some belated feedback. Sorry for breaking the
threading but I only just joined the list last night.
I'd like to draw an analogy to Perl's DBI and Class::DBI modules.
In DBI you work at the level of database handles, statement handles,
etc, and you write SQL. This is kinda a pain in the arse because it's
a bit low-level and also you can't just think in one language. So
along came the ORMs (eg. Class::DBI and friends) and made things
easier and more Perlish, less like writing in SQL and more like
writing in Perl.
So looking at Hayden's proposed API, which goes something like this:
$handle = Metaweb->new( server / login details here );
$handle->add_read_query( query here );
$handle->send_read_envelope;
It's dealing with things like envelopes, but when I'm looking up films
in Metaweb I'm going to be thinking about films. So I'd want the
syntax to reflect that.
Very very roughly, I'd expect something like:
my $metaweb = Metaweb->new( blah blah );
my @films = $metaweb->query({
director => 'Martin Scorcese',
blah blah etc
});
foreach my $f (@film) {
print $f->title();
}
Now under the hood that might be dealing in envelopes, but I think
most of the time -- definitely in accordance with the 80/20 rule if
not moreso -- we're going to be dealing with "here, gimme the results
of this query" and not want to deal with the under-the-hood stuff.
Shawn seemed to be talking about some similar things back in the earlier thread:
http://lists.freebase.com/pipermail/developers/2007-August/000510.html
K.
--
Kirrily Robert
skud at infotrope.net
http://infotrope.net
More information about the Developers
mailing list