[Nut-upsdev] upsclient high level API and Java wrapping
Charles Lepple
clepple at gmail.com
Fri Jul 8 12:29:17 UTC 2011
On Jul 7, 2011, at 10:06 AM, <EmilienKia at Eaton.com> wrote:
> This mail is a reply to mails from Charles Lepple and Petr Kubánek
> dated from july 7 with the same topic.
>
>> From: Charles Lepple
>>
>> "One thing with SWIG (and other binding systems) is that it is not
>> easy to handle errors gracefully. I can't count how many times I got
>> segmentation violation errors calling well-tested C code from Python
>> via SWIG.
>>
>> I tried using ctypes, which doesn't require any recompilation of the
>> target library, but it has similar problems.
>
> I am surprised. I follow wxWidgets open source project for a while,
> their python wrapping is done with SWIG and they do not have so many
> problems with that.
> Note I have not used SWIG for python (nor python itself)
> personnally, so perhaps I missed something.
The difference here is that wxWidgets is a much more complex library
than upsclient.
>> The big advantage to SWIG is supposed to be that you can generate
>> bindings to many languages once you set things up, but in reality,
>> each language has its nuances for passing things by
>> reference, and so
>> each set of bindings has slightly different semantics.
>
> I never say that SWIG will generate all bindings magically without
> any specific code.
> The experience I had with SWIG was with Java and Lua on separated
> projects. In theses cases, once some specific code was set (mostly
> typemapping), adding methods and objects was not so problematic.
Granted, there will be language-specific code. What I meant by "each
set of bindings has slightly different semantics" is that the way to
call a "get variables" method in Python might look different than in
Java if Python has to return things in the return arguments, and Java
simply allows the programmer to pass a reference to a list that gets
filled in.
So in addition to differences "under the hood", you would end up with
API differences. It's not a show-stopper, but it means additional
documentation to point out how to use each language binding.
--
Charles Lepple
More information about the Nut-upsdev
mailing list