开发者

Javascript engine with good interoperability with JVM and CLR

开发者 https://www.devze.com 2023-01-20 11:42 出处:网络
Due to the huge resources behind it, Javascript seems to rapidly becoming the scripting language of choice for applications, particularly those with a web front end.I have an application that requires

Due to the huge resources behind it, Javascript seems to rapidly becoming the scripting language of choice for applications, particularly those with a web front end. I have an application that requires extensibility both on the front and backend. Javascript, or a thin wrapper like CoffeeScript, seems like an excellent, future-oriented, choice.

The problem I'm having with using Javascript as the target is interoperability with existing server side libraries. V8 requires custom C++ code. I'd much prefer to leverage the vast resources of the JDK/.NET class libraries and our code that exposes APIs to these languages.

Are there any robust efforts that would allow users to call JVM/CLR libraries from Javascript, similar to the elegance of the IronPython-CLR and Jython-JVM link?

The alternative is to use something like IronPython/Jython, but both projects have only a fraction of the resources devoted to Javascript and it makes client-side extens开发者_开发技巧ibility story very difficult.

Has anybody successfully confronted similar issues?


Have you tried using the Javascript interpreter that ships with JDK 6 (Rhino)?

I mean, shipping with the core JDK is pretty interoperable, if you ask me. You can access Java services from the Javascript context, and from the Java side it's possible to introduce objects into the Javascript global context. It's also possible (with the ScriptEngine stuff) to use Javascript code as implementation of a Java interface.

Now, it's not at all interoperable with the CLR of course.


JavaScript compilers have shipped in the MS CLI implementation from the beginning, and in the Sun Java implementation since 1.6.0.

MS's is efficient, current, and uses DLR, so it interoperates with other implementaitons of dynamic languages, such as IronPython.

Sun's is based on the otherwise-abandoned 1998 Mozilla "Rhino". If you must have consistency or must have open source, you can run Rhino on MS .net via IKVM.

For more details, see:

Is there a port of the Rhino JavaScript engine for .NET

The web browser wars have led to their JS implementations (in C++) being radically faster & more up-to-date than all others. Mozilla's TraceMonkey has no Java bindings. But Google's V8 (Chrome, Android; faster anyway) does.

If you're prepared for some pain:

http://code.google.com/p/jav8/

http://rbackhouse.blogspot.com/2011/03/using-google-v8-javascript-engine-in.html

Or you can use MessagePack RPC to call into node.js (Google V8).

0

精彩评论

暂无评论...
验证码 换一张
取 消