I need to embed some simple scripting abilities (with object support) to the Crystal app. I don’t like lua much - some sort of Crystal mini interpreter (written in Crystal) would be ideal :)
I have experimented with a basic “interpreter”, similar to Ruby’s Object#send (https://github.com/j8r/crystal-object-send). It is quite limited, I don’t think it will fit your use case.
Note that all method arguments have to be typed for the internal casting.
crinja is a template engine, but it has a very powerful expression evaluation and integrates deeply with Crystal types.
The jinja syntax is somewhat usable for app scripting (for example ansible uses it for customization). But it would probably be not too difficult to hook up a parser for a different syntax that’s better suited for this use case.
Apart from that, you can embed different scripting languages into Crystal, for example lua, mruby, python or javascript. There should be shards available.
Ideal solution is, when the user that writes scripts can transparently access Crystal objects (some classes/API from the main application, that user can use/call).
An other option is to have a RPC mechanism to communicate between the main app and the user “script”/plugins, and embed a statically linked crystal compiler along with your app.
A bit late, but maybe somebody might still find this useful
I want to bring up Anyolite (GitHub - Anyolite/anyolite: Embedded mruby for Crystal) as a solution, which allows for mruby scripting (regular Ruby soon) in Crystal (including automated module wrappers and passing of objects between Ruby and Crystal).