与 JVM 和 CLR 具有良好互操作性的 Javascript 引擎
由于其背后拥有巨大的资源,Javascript 似乎迅速成为应用程序(尤其是那些具有 Web 前端的应用程序)的首选脚本语言。我有一个需要前端和后端可扩展性的应用程序。 Javascript,或者像 CoffeeScript 这样的瘦包装器,似乎是一个优秀的、面向未来的选择。
我使用 Javascript 作为目标时遇到的问题是与现有服务器端库的互操作性。 V8 需要自定义 C++ 代码。我更愿意利用 JDK/.NET 类库的大量资源以及向这些语言公开 API 的代码。
是否有任何强大的努力允许用户从 Javascript 调用 JVM/CLR 库,类似于 IronPython-CLR 和 Jython-JVM 链接的优雅?
另一种方法是使用 IronPython/Jython 之类的东西,但这两个项目都只有一小部分专用于 Javascript 的资源,这使得客户端可扩展性变得非常困难。
有人成功面对过类似的问题吗?
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 extensibility story very difficult.
Has anybody successfully confronted similar issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过使用 JDK 6 (Rhino) 附带的 Javascript 解释器?
我的意思是,如果你问我的话,与核心 JDK 一起发布的互操作性非常好。您可以从 Javascript 上下文访问 Java 服务,并且可以从 Java 端将对象引入到 Javascript 全局上下文中。也可以(使用 ScriptEngine 的东西)使用 Javascript 代码作为 Java 接口的实现。
当然,现在它根本不能与 CLR 互操作。
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 编译器已经发布
从一开始就执行 MS CLI,
以及从 1.6.0 开始的 Sun Java 实现。
MS 高效、最新,并且使用 DLR,因此可以互操作
与其他动态语言的实现,例如 IronPython。
Sun 的版本基于已被废弃的 1998 年 Mozilla“Rhino”。
如果你必须保持一致性或者必须有开源,
您可以通过 IKVM 在 MS .net 上运行 Rhino。
有关更多详细信息,请参阅:
是否有端口.NET 的 Rhino JavaScript 引擎
Web 浏览器之战导致了他们的 JS 实现(用 C++ 实现)
速度更快&比所有其他的都更新。
Mozilla 的 TraceMonkey 没有 Java 绑定。
但 Google 的 V8(Chrome、Android;无论如何更快)可以。
如果您准备好承受一些痛苦:
http://code.google.com/p/jav8/
http://rbackhouse. blogspot.com/2011/03/using-google-v8-javascript-engine-in.html
或者您可以使用 MessagePack RPC 调用 node.js (Google V8)。
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).