FFI - some comments
Thu, 5 Apr 2001 07:45:44 -0700 (PDT)
This is just some notes about my experiences with the
various FFI tools, and my opinions. Maybe I am missing
Let me just say that I like the 'new' FFI. The
approach is much better
then the usual approach to 'native' interfaces that
you see with
Tcl, java, python, whatever. In those cases you have
to do the
marshalling by hand, except where you can use SWIG,
which is a pretty
Overall, I think there is not a perfect solution.
Someone correct me
if I am wrong. The ideal solution should take
the fact that we are using Haskell:
1) Use the new FFI, for hugs and ghc.
2) Do Marshalling on the haskell side only.
3) Be a high level marshaling combinator library
(written in haskell).
4) OPTIONALLY support some sort of IDL for
automatically finding invoking
the correct marshalling combinators.
How do the existing tools stack up? I am not sure,
because they are all
in various states of support/etc. Here are my
impressions... they may be wrong!
Please take this with a grain of salt, I have not
spent a lot of time with
the tools below, just played with them a bit. Most of
time was spent trying
to build them L:)
Greencard: Seems to work pretty well overall.. I dont
beleive it supports
hugs/ffi, but it does support hugs. It does the
haskell, but with a lot of _casm_ so I am not sure
what that means.
I got some simple examples to work, but not the Gdbm.
didnt seem to make sense.. HC not defined, etc.
with abit of work. I cant tell if callbacks are
HDirect: This one is still pretty beta, and so I had
some trouble getting it
to compile on my solaris machine. Probably not
intended for solaris. I had
to by hand prune some of the makefiles, ( in lib,
there was some mysterious
error about 'test' haveing no arguments when deciding
whether to create
a 'hugs' subdirectory, and In the end I commented out
the all :: dlls line.
but I did finally get it to go, at
least the ghc parts. This one does its marshalling in
haskell. It uses an
IDL that is fairly common, although I dont know how
much longer COM is
going to be important. Anyway, when ready for prime
time it might work
pretty well, although like I said I would rather have
a nice library.
As for examples, I got the string example to work (you
have to set
FOR_WIN32 to no, even if you set FOR_HUGS to no. The
makefile is a bit
misleading). The gd example doesnt work, it assumes an
old libgd that used
to support GIFs. They arent suppored anymore, for
KDirect: Looked at it abit. Pretty sparsely
documented. I could not figure
out how it fits in with the latest tools. How does
QForeign relate to
Foreign? What is an hsc file? Also it is pretty
limitted in the marshalling.
No callbacks etc.
Others: I know there are a couple of others, but I
lost interest. I Just wanted
to report my findings for others, and then I am going
into wait and see mode :)
I dont have a dire need for this stuff at the moment,
I can get my tasks
done a different way. (Dont ask, it aint pretty)....
Cheers to all!
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.