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

python bindings #7800

Closed
njskalski opened this issue May 20, 2019 · 4 comments
Closed

python bindings #7800

njskalski opened this issue May 20, 2019 · 4 comments

Comments

@njskalski
Copy link

Hi,

I really like idea of Crystal, but pretty much all small scripts nowadays I am forced to write in Python. Not because I like it, but because I have very high probability of finding libraries automating 80% of work I need to do.

It would be great if I could use Crystal as primary script language and delegate some operations to Python libraries.

Is anybody working on something like that?

@oprypin
Copy link
Member

oprypin commented May 20, 2019

Unfortunately, I think that using Python in such a way would be such a clusterf*** that it would more than nullify any advantage of these libraries.

And this is coming from the #1 fan of Python.

Also this is probably not the best place to ask a question that isn't about the core language. Try the forums or crystal-libraries-needed

@asterite
Copy link
Member

I think Pyhton bindings are possible via C, but then it'll be just calling eval or similar from Crystal to Python and I don't know how you would communicate data back and forth. As @oprypin says, it's probably a recipe for a hard time, it might be easier to write whatever lib you need in Crystal. And yes, this is more a question for the forums, so closing.

@oprypin
Copy link
Member

oprypin commented May 20, 2019

To be fair, I think if Python bindings are approached in the same way as C bindings (binding generator or similar - with statically defined methods and types), then it could work. Still a ton of work and little flexibility.
And two separate garbage collectors 😅

@z64
Copy link
Contributor

z64 commented May 20, 2019

Maybe worth mentioning, there has been some success in embedding other runtimes:

JS (via duktape): https://github.com/jessedoyle/duktape.cr
Lua (via liblua): https://github.com/veelenga/lua.cr

You might try one of those if you're looking to run scripts in a Crystal app, or maybe just to give them a try to see how embedding another rt works in practice.

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

No branches or pull requests

4 participants