Paul, it seems that you replied directly to me and not to the list, so I
will quote your message here with my answers interceeded...
Paul Dixon a ?crit :
>>we also started to make a PHP 5 wrapper around the Xapian php api
>>generated by swig.
>>
>>Ideally, swig will one day be able to generate OO bindings for PHP which
>>will make our wrapper useless.
>>If not, perhaps we will start to write a native PHP extension...
>>
>>
>
>Wow, nice work! That should make Xapian accessible to even more PHP
>developers
>
Yes, there is a real need, and I think that Xapian is a serious
competitor for Zend_search, the php implementation of Lucene in the Zend
Php framework.
>the one gripe I'd have is "why change the method names?"
>- I would think it best to stay close to the C++ API so that if a
>better "native" wrapper becomes available, code can be
transitioned
>more easily?
>
>Using the same method names also allows easier communication of one's
>ideas with people using Xapian on other platforms. Indeed, that was
>one my main motivations in making the wrapper.
>
>
>
I agree that this is a discutable choice, but let me advocate :
- I started to develop this wrapper for our own needs, so I applied our
own naming conventions.
- it's becoming a current practice in PHP developpement to use
"lowercaseCamelCase" as a naming convention for methods (zend
framework,
symfony, ez components and many other use it).
- using the same naming conventions as major php libraries can be an
advantage for spreading Xapian in php developpement (the "inclusion"
is
more natural)
- the changes I made are not so important and they are quasi
"automatic"
: the method names are the same, it is just the way they are written
(set_data // setData). I'm not convinced that it can be a major problem
for sharing ideas with other persons.
- a similar choice was done in the java wrapper for Xapian. In fact, my
wrapper is very similar to the java one. For example, look at :
http://svn.xapian.org/trunk/xapian-bindings/java/org/xapian/Document.java?view=markup
- I don't know what will be the API for a "native" wrapper, but I
suppose that swig can generate any method's name (can't it ?). So
it's
not impossible to imagine that an OO wrapper would follow the same
naming conventions.
>>I don't know how our wrapper compare with Paul's one. Paul's
API is very
>>similar to the C++ one, and he used a lot the PHP '__call' magic
>>function. It's a brillant idea because most of methods get
'magically'
>>defined : size of his wrapper is half of our's and it's probably
easier
>>to add new method. But extensive use of '__call' probably have a
cost,
>>and it is not easy to have php documentation at the method level.
>>
>>
>
>You're correct that my wrapper doesn't allow generation of
>documentation, but it does have the advantage that new methods are
>automatically supported without any wrapper changes. That's just a
>lucky side effect, I only did it that way to save some time :)
>
>
It is really a brilliant idea, and I will certainly re-use it for rapid
developpement.
However, apart from documentation, there are other drawbacks : no
auto-completion nor quick help in IDEs, no possibility of reflexion on
such classes, overloading methods is not intuitive, and so on.
>Performance-wise, I haven't done much benchmarking aside from timing
>the smoketest - my class-based version of the smoketest runs 2-3 times
>slower than the function based smoketest included in the
>xapian-bindings package. That doesn't mean an awful lot, so I'll do
>some more detailed benchmarking to give a clearer idea of the overhead
>in calling an API via the class is.
>
>
Basically, I think that our two wrappers will have about the same
overhead, except if using "__call" is many times slower than using a
direct call. It is also probable that overhead of the wrapper will be
negligible on a real corpus containing many documents.
So it will be great if you can do detailed benchmarking.
>It would be great to see a "native" PHP5 class extension though...
>
>
Yes, we totally agree on that point!
(and I would use such an extension whatever naming conventions used !!!)
--
Daniel M?nard
Banque de Donn?es Sant? Publique
Avenue du Professeur L?on Bernard
35043 Rennes C?dex
T?l. (+33) 2.99.02.29.42
Fax (+33) 2.99.02.26.28
E-mail Daniel.Menard@Bdsp.tm.fr
http://www.bdsp.tm.fr