Here's a quick example of why it's nice to have a script interpreter embedded in Qt: Plasma's KRunner has a calculator which used code borrowed from the KDE 3.x minicli. The old code started up the bc command line calculator then displayed the result - not exactly an efficient way to do things. I've just committed a change that makes it use QtScript and the code is trivial:
QString CalculatorRunner::calculate( const QString& term )
{
QScriptEngine eng;
QScriptValue result = eng.evaluate( term );
return result.toString();
}
This replaces 23 lines of code and is quite a bit more powerful. Nice!
Running arbitrary code
Won't this allow people to run arbitrary JS code from KRunner?
Granted, there isn't much you can do with a pure JS environment without any binding...
Re: Running arbitrary code
No, you can't run arbitrary code as the calculator KRunner is only activated when the message typed matches a certain regexp (ie. a whitelist). I am thinking of changing this so you can run arbitrary code however. This isn't a security problem as only the core JS objects are available so you have no way to escape the sandbox.