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

查看:30
本文介绍了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 写道Lua 的 Java 实现,称为 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)成为最好的语言每一个任务.唯一的其他主流语言在那里竞争用于编写任意脚本的 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.

没有手头的例子,我只能do 是说使用 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.

我个人更喜欢 Java 平台上的 JavaScript.用户基数更大.正如 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天全站免登陆