什么是能够理解数据类型并可以在 Java 中实现的脚本语言?

发布于 2024-07-24 02:28:05 字数 199 浏览 7 评论 0原文

我正在寻找一种满足以下条件的脚本语言:

  • 文档齐全
  • 用 Ja​​va 实现
  • 理解数据类型(可以处理长整型、字符串等)
  • 完全可扩展

有什么建议吗? 目前,我正在使用 Javascript,但它设置数字的双精度数对于我正在做的数据工作来说不够大。

谢谢!

I am looking for a scripting language that meets the following criteria:

  • Well Documented
  • Implemented in Java
  • Understands Datatypes (can handle longs, strings, etc)
  • Is fully extensible

Any suggestions? Currently, I'm using Javascript, but the Doubles that it sets numbers to is not big enough for the data work I'm doing.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

垂暮老矣 2024-07-31 02:28:05

Groovy

特别是,Groovy可以用作脚本语言,但不能必须如此,并且是构建在 Java 之上的。 它不是不同语言的 Java 端口,这意味着它与 Java 的集成比 JRuby/Jython 更紧密,尽管自从我上次查看它们以来,情况可能已经发生了变化。

至于 Groovy 的文档,您可能需要购买 Groovy in Action (插件插头 ;)

Groovy

In particular, Groovy can be used as a scripting language, but doesn't have to be, and is built on top of Java. It isn't a Java port of a different language, which means it integrates more closely with Java than JRuby/Jython, although that may have changed since I last looked at them.

As for documentation for Groovy, you may want to buy Groovy in Action (plug plug ;)

浅语花开 2024-07-31 02:28:05

Python 和 Ruby 有 Java 实现(查找 Jython 和 JRuby)。

Python and Ruby have Java implementations (look for Jython and JRuby).

月亮是我掰弯的 2024-07-31 02:28:05

LuaJava 可能就是这样。 所有数字在 lua 内部都表示为双精度数。

LuaJava could be it. All numbers are represented internally as doubles in lua.

羁〃客ぐ 2024-07-31 02:28:05

我不确定“理解数据类型”是什么意思。 如果你的意思是它有字符串、数字等,那么 JavaScript、Groovy、Python 和 Ruby 都是与 Java 集成良好的众多语言中的一些。 如果您正在寻找静态类型语言,我不确定。

关于 JavaScript 中双精度数不够大的问题,您可以从 JavaScript 代码中分配 Java BigDecimal 对象(或 BigInteger 对象)。 因此,数字表示对您来说不应该是问题。

I'm not sure what you mean by "understands data types". If you mean that it has strings, numbers, etc, then JavaScript, Groovy, Python, and Ruby are some of the many languages that integrate well with Java. If you're looking for a statically typed language, I'm not sure.

Regarding you problem of doubles not being big enough in JavaScript, you can allocate Java BigDecimal objects (or BigInteger objects) from within your JavaScript code. So, number representation shouldn't be an issue for you.

最美不过初阳 2024-07-31 02:28:05

“它设置的数字对于我正在做的数据工作来说不够大”是什么意思? AFAIK 在大多数语言中双精度数的大小相同。

您需要多少精度? 如果您需要超过 16 位的精度,也许 BigDecimal 适合您。

What do you mean "Doubles that it sets numbers to is not big enough for the data work I'm doing." Doubles are the same size in most languages AFAIK.

How much precision do you need? Perhaps BigDecimal is for you if you need more than about 16 digits of precision.

娇纵 2024-07-31 02:28:05

我的建议是 Clojure 或 Groovy。

Jon 的回答 已经有一些关于 Groovy 的详细信息,所以这里有更多关于 Clojure 的信息:

  • 它是一个 Lisp,所以具有高度可扩展性,并且非常适合构建 DSL
  • 它是用纯 Java 编写的,因此您可以轻松嵌入到 Java 应用程序中
  • 它非常动态,非常适合 REPL 上的交互式脚本

特别是 Java 互操作非常简单:Clojure 对象 Java 对象反之亦然,你可以直接调用方法:

;; create a string
(def s "Hello World")

;; inspect its type
(class s)
=> java.lang.String

;; call a method 
(.length s)
=> 11

;; count the characters (Clojure can treat Strings as a sequence of characters)
(frequencies s)
=> {\H 1, \e 1, \l 3, \o 2, \space 1, \W 1, \r 1, \d 1}

Clojure or Groovy would be my recommendations.

Jon's answer already has some details on Groovy, so here's a little more on Clojure:

  • It's a Lisp, so is highly extensible and great for building DSLs
  • It's written in pure Java, so you can easily embed within a Java application
  • It's very dynamic, great for interactive scripting at the REPL

In particular Java interop is very simple: Clojure objects are Java objects and vice versa, and you can call methods directly:

;; create a string
(def s "Hello World")

;; inspect its type
(class s)
=> java.lang.String

;; call a method 
(.length s)
=> 11

;; count the characters (Clojure can treat Strings as a sequence of characters)
(frequencies s)
=> {\H 1, \e 1, \l 3, \o 2, \space 1, \W 1, \r 1, \d 1}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文