Talking to other languages (with callbacks!) - possible solution
Daniel B. Faken
faken at cascv.brown.edu
Mon May 23 18:26:35 UTC 2005
Lex Spoon wrote:
[snip]
> my working assumptions have been:
> 1. If you want to talk to the software world, speak C. It's the
lingua
> posixa and almost everything can speak it in some fashion.
>
> 2. Speaking C without an accent means you have to support callbacks
> and using the Squeak VM as a library.
>
> 3. Allowing callbacks means that the interpreter must be reentrant and
> that the VM is implemented with a call stack that alternates back and
> forth between Squeak and C.
>
[snip]
> If I understand correctly, the DBus
> strategy might be an alternative that is easier than #3.
Exactly my point.. or, on an aside: easier for me, since I don't
want to get involved in Squeak internals, which I'm guessing would take
a long time to understand well enough to modify nicely (and this assuming
they don't need a complete rearchitecting).
> Further, it
> seems plausible that DBus will become a widely used "language" of its
> own -- perhaps even *the* lingua posixa of 2010 -- thus meaning #1 on
> the list above is unnecessary.
I'm more conservatively hoping it will at least be *supported* for quite a
while :). In any case I agree that it is a good portability strategy to
converse easily with C. Besides, Squeak's easy FFI to the DBus C library
is what made the bindings realizeable in the first place..
> Some questions:
>
> - How hard is it to bind an *arbitrary* C program to DBus? If it's
> easy, then that means we can talk to arbitrary C libraries even when
> they don't already have DBus support. (It also means that DBus will be
> supported more widely, because people can say "why not" and offer DBus
> bindings.)
DBus is a C library, so in that sense its trivial..
If you mean 'how hard is it to bind an arbitrary object-oriented system',
then I would say it seems relatively simple given the work I've done for
Squeak bindings. It is *designed* to be easy to bind..
> - You mention some impressive high-level examples--TeapotMorphs
> and TFrames. How about basic stuff like arithmetic? That is, how hard
> would it be to write in C the following:
>
> obj = executeSmalltalkCode("Compile evaluate: '5 factorial'");
>
> How complicated is executeSmalltalkCode()?
Well, currently this is not very hard.. it would just be a matter of
constructing a message to whatever object 'Compile' is, and reading the
answer.. maybe 5 lines of C.
> I ask about this example because I am wondering about what the exact
> overheads are of going via DBus. Those overheads can easily disappear
> into the noise if you are doing a more complicated project.
If you mean performance overhead: I haven't done benchmarks, and things
really aren't at that stage yet ("premature optimization..").
If you mean boilerplate-type overhead, this can be reduced...
> Please update the list with any further work you do on it -- this is useful stuff!
I'll announce something this week.. I appreciate the response - it lets me
know other people are interested in the issue..
cheers,
Daniel
More information about the Squeak-dev
mailing list
|