0

I'm designing a system and thinking about using some scripting language, in order to let a third party developer extend the capabilities of the system.

Just to give you an idea of my goal...When an event is triggered, the scripting language will need to invoke some Objects on the VM space that will provide common functionalities (e.g. storing objects on the BD, sending emails).

In a similar situation, a couple of years ago, I used BeanShell and it worked fine. Checking the website it looks like the project is a bit out of date.

Nowadays there are several VM languages, Groovy, Scala, just to name a few. What considerations should I have ? Do you have any experience in a similar environment?

10
  • first class support for libraries for timers, schedulers, http support and system calls should be the priority of choosing. but most language on JVM will have the support because they can reply on java libraries Commented Sep 1, 2016 at 12:45
  • And java 9 will come with a REPL too. Scala might be a too high goal. JavaScript is ugly (imho), but most accessible and one could use the Java Scripting API. Commented Sep 1, 2016 at 12:46
  • 1
    I highly recommend scala its worth the effort spent in learning. Scala already has REPL and Ammonite repl is also available which is way better than scala repl Commented Sep 1, 2016 at 12:48
  • 1
    I wouldn't call Scala a scripting language, any more than I would say Java is. Commented Sep 1, 2016 at 12:49
  • 1
    Check this for Scala scripting lihaoyi.com/Ammonite Commented Sep 1, 2016 at 12:53

1 Answer 1

3

Groovy is syntactically similar to C/Java language family, and, semantically, based on Ruby/Python/Smalltalk. It is supposed to have a smooth learning curve and shouldn't be hard to pickup and be productive right away (if that is a problem to your client).

It features GroovyShell and Eval, which are used to easily evaluate some script, stored in database, for example:

result = Eval.me """
    a = 1 + 2
    b = 3 + 4
    a + b
"""

assert result == 10

Note that this is too raw and you might need some kind of sandboxing, otherwise your client might do something nasty, like System.exit. For these scenarios, there are compiler customizers and groovy-sandbox. Also, you can add type checking through compiler customization.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the recommendation. I think that you mentioned at least two key features: sandboxing, learning curve.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.