I'm comparing options for running user-defined logic inside a Java application. How useful are performance benchmarks across these languages, and what else should I consider?
How do Jactl, Groovy, MVEL, JEXL, and SpEL compare for embedded scripts?
Answers
I'd treat a benchmark as a starting point, not a ranking. The published comparison was made by Jactl's author, so check the workloads and methodology with that in mind. Jactl reportedly did well, but didn't win every test.
For your own application, measure parsing or compilation separately from repeated execution. A script run once per request may have very different costs from an expression compiled once and evaluated thousands of times. Use representative inputs and include JVM warmup.
Reply to this answer
These aren't all interchangeable. SpEL is an expression language, while JEXL has grown beyond simple expressions and supports things like loops, variables, functions, and lambdas.
Start with what the embedded code actually needs to do. If users only need to calculate a value or test a condition, a full scripting language may be more than you need. If they need control flow and reusable functions, check those features before looking at speed.
Reply to this answer
Compiled versus interpreted performance can be a misleading comparison if the benchmark doesn't match how you plan to use the code. Compilation overhead may be worth paying for a script that runs repeatedly, but less attractive for a one-off expression.
Look at both startup cost and steady-state throughput rather than assuming one number answers the question.
Reply to this answer
Performance isn't the only practical filter. Check how each option lets you expose Java objects and restrict what user-supplied code can access. Also look at error reporting and how comfortably your users can write and maintain the syntax.
5u!spareclip_492:
That matters especially if the scripts come from users you don't fully trust. Check the specific restrictions each engine supports rather than assuming embedding alone provides isolation.
Reply to this answer
If you're still exploring, Janino, EvalEx, CEL, and Java Scheme are other candidates worth investigating. They won't necessarily be direct substitutes, so compare their capabilities and intended use before adding them to the same benchmark.
Reply to this answer
Add your answer
Answers are reviewed before publication.
u82~parcel_614:
Also check whether the benchmark includes the cost of passing data between Java and the script. That can matter for small expressions.