Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seamless compile-time FFI #129

Open
dumblob opened this issue Jun 23, 2021 · 5 comments
Open

Seamless compile-time FFI #129

dumblob opened this issue Jun 23, 2021 · 5 comments
Labels
feature request Requesting for new featuers

Comments

@dumblob
Copy link

dumblob commented Jun 23, 2021

Any plans to have first-class support for compile-time FFI (e.g. to C functions & structs)?

Or more generally - any plans to stand on the shoulders of some of the huge existing language ecosystems (C, Python, C++, Ruby, Rust, Java, ...)?

With compile-time I mean to not need to manually generate (or worse write) bindings, but use some language feature (e.g. special syntax like prefix C. resulting in C.printf( "%s%d", ... )).

@ThakeeNathees
Copy link
Owner

Any plans to have first-class support for compile-time FFI (e.g. to C functions & structs)?

If this requires a toolchain to achieve, No. Pocketlang is and will always be standalone, and I'm afraid this might break the "Easily embeddible" nature.

Any pointers on how to do this without breaking the "simplicity" of pocketlang is wellcome.

@ThakeeNathees ThakeeNathees added the feature request Requesting for new featuers label Jun 24, 2021
@dumblob
Copy link
Author

dumblob commented Jun 24, 2021

I'm not sure what you mean with "toolchain". Pocketlang seems to be 100% dependent on the Wren "toolchain" - so why not to allow FFI into Wren ecosystem? And if Wren already has FFI to e.g. C ecosystem, why not to use it as well?

@ThakeeNathees
Copy link
Owner

When I say toolchain I meant something like assembler and linker (like LLVM does), that cannot be integrated.

Pocketlang seems to be 100% dependent on the Wren

No, the phrase "The language is written using Wren Language and their wonderful book Crafting Interpreters as a reference." might confuse you, but pocketlang is written in pure C99 and it doesn't rely on wen. And wren doesn't support FFI (as for now).


https://github.com/libffi/libffi Seems promising and easy to integrate. Many mainstream languages are using it (python, ruby ffi, java openjdk, mozilla javascript).

@dumblob

@dumblob
Copy link
Author

dumblob commented Jun 25, 2021

Thanks for clarification! Yes, I got confused by the sentence you quoted (maybe this could be clarified in the readme?).

Regarding the need for a "toolchain" it's kind of implied by FFI itself. So I'm afraid if FFI should become a thing, then a "toolchain" is inevitable.

@dumblob
Copy link
Author

dumblob commented Jun 27, 2021

A seamless minimal FFI could look like this: https://slightknack.dev/blog/ffi-hard/ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requesting for new featuers
Projects
None yet
Development

No branches or pull requests

2 participants