Java:用于嵌入Java桌面应用程序的脚本语言(宏) [英] Java: Scripting language (macro) to embed into a Java desktop application

查看:164
本文介绍了Java:用于嵌入Java桌面应用程序的脚本语言(宏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Java编写图形应用程序。最终我想用脚本语言构建,所以事情是可编程的。你推荐哪种语言库?

I am writing a graphics application in Java. Eventually I would like to build in a scripting language so things are programmable. Which language library do you recommend?

可能的嫌疑人是:

  • Rhino (JavaScript)
  • JRuby (Ruby)
  • Jython (Python)

候选人不太可能:

  • Whip up my own language using JavaCC
  • LuaJava (Lua)
  • Groovy
  • JavaFX
  • Script-Fu

目标受众可能不是核心程序员,因此首选的是较少的神秘语言。我的猜测是JavaScript更容易被他们接受,即使它的怪癖只是因为他们已经看到了更多。

The target audience are probably not hardcore programmers, so less arcane language is preferred. My guess is that JavaScript is more acceptable by them even with its quirks just because they've seen it more.

Lua似乎在C / C ++中很受欢迎,但至少LuaJava需要额外的.dll / .so,这使部署变得复杂。

Lua seems to be popular in C/C++, but at least LuaJava requires additional .dll/.so, which makes deployment complicated.

编辑:
PhiLho 写道,有一个名为 kahlua 。

PhiLho wrote that there's a Java implementation of Lua called kahlua.

相关问题:

  • Which scripting language to support in an existing codebase? (in C/C++)
  • Adding Scripting functionality to .net Apps
  • What is the best scripting language to embed in a C# desktop application.

推荐答案

我刚读过Steve Yegge的通用设计模式。这篇文章的内容比Java应用程序中的嵌入式脚本更广泛,但由于作者编写了一个允许编写脚本的Java应用程序(使用Jython),因此我发现有一些有趣的见解点。

I just read Steve Yegge's The Universal Design Pattern. The article is on much broader topic than just embedded scripting in Java application, but since the author writes a Java application that allows scripting (using Jython), there are insightful points I found interesting.


JavaScript是地球上两种最好的
脚本语言之一,在
中最正确的术语
脚本语言:即
语言被设计为
,专门嵌入较大的
主机系统,然后用于
操作或
主机系统中的脚本对象。这就是JavaScript
的目的。它是合理的
小的一些可选扩展,
它有一个相当紧凑的非正式
规格,它有一个精心的
精心设计的界面,用于透明地显示
主机系统对象在
JavaScript中。

And JavaScript is one of the two best scripting languages on the planet, in the most correct sense of the term "scripting language": namely, languages that were designed specifically to be embedded in larger host systems and then used to manipulate or "script" objects in the host system. This is what JavaScript was designed to do. It's reasonably small with some optional extensions, it has a reasonably tight informal specification, and it has a carefully crafted interface for surfacing host-system objects transparently in JavaScript.

相比之下,Perl,Python和Ruby都是
巨大的蔓延,都在尝试(比如C ++和
Java)成为
每项任务的最佳语言。另一种与b
JavaScript竞争的主流
语言用于编写任意
主机系统的脚本是Lua,以
为首选的脚本语言而闻名行业。

In contrast, Perl, Python and Ruby are huge sprawls, all trying (like C++ and Java) to be the best language for every task. The only other mainstream language out there that competes with JavaScript for scripting arbitrary host systems is Lua, famous for being the scripting language of choice for the game industry.

我同意他对缩小JavaScript和Lua的看法。

I agree with him on narrowing down to JavaScript and Lua.


如果没有示例方便,我可以说
就可以说使用JavaScript / Rhino
(或Lua,一旦它在
上可用,JVM)可能会让我的生活变得更容易

Without the examples handy, all I can do is say that using JavaScript/Rhino (or Lua, once it became available on the JVM) might have made my life easier.

我个人更喜欢JavaScript在Java平台上。用户群的人口更多。
正如Yegge所说,它是世界上最容易被误解的编程语言,但该语言的可用资源量是一个优势。 Rhino 似乎是一只成熟的野兽。

I personally prefer JavaScript on Java platform. The population of the user base is larger. As Yegge puts it, it is "the world's most misunderstood programming language," but the amount of resource available on the language is a plus. Rhino seems to a matured beast.

这篇关于Java:用于嵌入Java桌面应用程序的脚本语言(宏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆