[Cuis-dev] On choosing between a plugin and ffi, and one ffi implementation - Re: Alien? ThreadedFFIPlugin?

Juan Vuletich juan at jvuletich.org
Wed May 27 11:01:19 PDT 2020


Hi Philip,

(below)
On 5/27/2020 2:17 AM, Philip Bernhart via Cuis-dev wrote:
> Hi,
>
> I recently asked on the squeak vm-beginners list about the stability
> of the external plugin interface. The general vibe from Eliot was:
>    don't! Use FFI instead!
>
> See:
>    http://forum.world.st/Stability-of-the-external-plugin-interface-td5117112.html
>
> In particular I got a response to an answer / comment:
>
>> I'm looking forward to it, but in the meantime I need to write packages
>> for Cuis Smalltalk which I need which in turn go over the slow legacy
>> Squeak FFI with no callbacks. Is there a roadmap, some public plan of
>> these implementations? I think that ideas are already around a long time
>> already and it seems that the VM development is heavily underfunded or
>> else it would already be here.
> Eliot mirandas response:
>> I don’t understand where you get the idea that Cuis has no callbacks.
>> Cuis supports Alien and has access to the ThreadedFFIPlugin and runs on
>> Cog, so it can have callbacks easily.  I suspect they’re there if you
>> load FFI and Alien.  Ask on the Cuis list.
>>
>> In a Squeak image look at Alien’s class side exampleQsort which uses a
>> callback to implement the sort function to qsort.  I bet this works on
>> Cuis too.
> So I think I never saw any Alien or ThreadedFFI in the
> Cuis-Smalltalk-Dev directories, I grepped for it. From the FFI I always
> thought that this is the old Squeak FFI implementation, am I wrong?
>
> I kind of feel like someone who lived in the geocentric worldview
> and was now told that the earth and other planets go around the sun.
>
>
> Thanks,
> Philip

The only FFI that has been ported so far to Cuis is the old original 
Squeak FFI implementation, port and migration to 64 bits done by yours 
truly. Still, we run the very same VM as Squeak, and there is a very 
high degree of compatibility between Cuis and Squeak. Porting other 
(better!) FFI implementations to Cuis should be straightforward.

Please note that doing the same with Pharo code could be harder. Pharo 
forked the VM, and it is likely that the Pharo VM can no longer run 
Cuis, while the FFI mechanism in Pharo might not run on the Squeak VM. 
Not saying it can't be done, but that more investigation would be required.

So, how is the FFI landscape in Squeak nowadays? How different is that 
from the old Squeak FFI we have in Cuis? I understand that some 
applications will need callbacks. But I am specifically interested in 
call speed. The OpenCL version of the VectorCanvas is working, but the 
overhead of calling OpenCL via FFI is too large. Doing the calls takes 
orders of magnitude more time that the actual OpenCL drawing primitives! 
So, I need wither a plugin, or a very fast FFI. For the reasons I said 
in another email "FFI vs. Plugins" I think that OpenCL is a good 
candidate for a plugin. But a very fast FFI could also work.

Finally, and on a separate note, are you thinking on a specific 
application of FFI / Plugins?

Thanks,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich



More information about the Cuis-dev mailing list