lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject Re: [lucy-dev] Porting Clownfish compiler to C
Date Mon, 21 Feb 2011 21:52:14 GMT
On Mon, Feb 21, 2011 at 12:29:00PM -0800, Mattmann, Chris A (388J) wrote:
> Is there any reason to look at SWIG for the language bindings (not now, but
> maybe later?). I know SWIG is pretty good at taking C code and generating
> language specific bindings and that SVN uses it.

SWIG was considered and rejected long ago.  It does not provide sufficient
flexibility, power, or elegance to meet our high standards for interface
design.

We touched on the subject of SWIG during the discussion of LUCY-5, which
introduced "Boilerplater", later renamed to "Clownfish":

  http://s.apache.org/pSd

  However, the bindings we can generate with Boilerplater are much more
  powerful and integrated into our custom OO model than what we could achieve
  with SWIG.  SWIG bindings allow you to invoke the C library from the host
  via wrappers.  Bindings generated by Boilerplater, on the other hand, allow
  you to write subclasses entirely in the host language which override methods
  defined in the C core.

This feature has been exploited to write custom subclasses of Query,
QueryParser, Highlighter, FieldType, Schema, Similarity, IndexManager and so
on -- all in pure Perl.  Several such projects have ended up as distributions
published on CPAN. 

Clownfish also offers these features:

  * Automatic refcount management (thanks to the "incremented" and
    "decremented" keywords).
  * Default parameter values.
  * Method bindings which use labeled parameters rather than positional
    arguments.
  * Sophisticated parameter validation.
  * Caching of host objects, for speed and to make inside-out subclass
    implementations practical.

SWIG bindings would not allow us to meet Lucy's central design goal of
providing highly idiomatic interfaces tuned for each host language.

  http://wiki.apache.org/incubator/LucyProposal

  Proposal

  Lucy has two aims. First, it will be a high-performance C search engine
  library. Second, it will maximize its usability and power when accessed via
  dynamic language bindings. To that end, it will present highly idiomatic,
  carefully tailored APIs for each of its "host" binding languages, including
  support for subclasses written entirely in the "host" language. 

Clownfish is thus an essential component of Lucy.  However, it is so
seamlessly integrated that end users have no idea that it exists. :)

Marvin Humphrey


Mime
View raw message