Apache Ant 作为编程语言

发布于 2024-10-15 04:25:00 字数 34 浏览 4 评论 0原文

Ant 是编程语言吗?如果是,它是必要的还是功能性的?

Is Ant programming language? If yes, is it imperative or functional?

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

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

发布评论

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

评论(6

沩ん囻菔务 2024-10-22 04:25:00

问题应该是:如果你想用 Ant 进行计算,你能做到吗?让我们限制自己做一些简单的事情,比如模拟一个简化的命令行计算器。如果你能做到这一点,Ant 肯定有资格成为一种编程语言,即使这不是该工具最初的意图。

我们可以定义的也许最简单的语言是“Huttons Razor”,它由

  • 常量组成,如 5、37 等,所有自然数(从 0 开始计数)
  • A + 运算符,因此我们可以写 (37 + 5) + 15 + (42 + 0)

无论如何,这不是一种有用的语言,但如果您尝试滥用 Ant 进行计算,那么这是一个宏伟的开始;如果你连 Razor 都做不了,你可能就无法做更高级的事情。请记住,其他计算方法(例如 lambda 演算)与此有很大不同,因此其他路径可能也是可行的。 注意:我不知道Ant是否可以做到这一点。我最后一次查看它是在 2006 年,并决定不再查看它。

请注意,一种语言不一定是图灵完备的才能成为一种编程语言。我们有几种非常有用的编程语言,但实际上却没有。


对于非图灵完备有用的语言:

  • 仅接受 Total 程序(即终止的程序)的语言。这对于许多用作定理证明器的编程语言来说是必需的:Coq、Agda 等。另一个例子是简单类型的 Lambda 演算(简单的类型使得无法定义 Y 组合器并获得递归)。

  • 高度特定于领域的语言。巨魔就是一个例子,

    http://www.diku.dk/hjemmesider/ansatte/torbenm/Troll /

    这是一种用于描述桌面游戏和角色扮演游戏中掷骰子的语言。该语言似乎不是 TC,但在设计新游戏时非常有用,因为它可以快速计算掷骰子方法的概率分布。

The question should rather be: If you wanted to do computation with Ant, could you do it? Let us restrict ourselves to something simple, like emulating a simplified command-line calculator. If you can do this, Ant certainly qualifies as a programming language, even if that was not the intention of the tool originally.

The perhaps simplest language we could define is "Huttons Razor", which consists of

  • Constants, like 5, 37, and so on, all Natural numbers (counted from 0)
  • A + operator, so we can write (37 + 5) + 15 + (42 + 0)

Not a useful language by any means, but a magnificent start, should you try to abuse Ant to do computation; if you can't even do the Razor, you probably can't do something more advanced. Do keep in mind though that other means of computation, like the lambda calculus, is vastly different from this though, so it may be that other paths are also viable. Note: I don't know if Ant can do this. I last looked at it in 2006 and decided to never look at it again.

Note that a language does not have to be Turing Complete to be a programming language. We have several, highly useful, programming languages out there which are not.


For non-Turing Complete useful languages:

  • Languages that only accept Total programs (i.e., programs that terminate). This is a necessity for many programming languages that are used as theorem provers: Coq, Agda, etc. Another example is the Simply Typed Lambda calculus (the simple typing makes it impossible to define the Y-combinator and get recursion).

  • Languages that are heavily domain specific. One example is Troll,

    http://www.diku.dk/hjemmesider/ansatte/torbenm/Troll/

    which is a language for describing dice rolls in tabletop and roleplaying games. The language does not seem to be TC, yet it is highly useful when designing new games as it can quickly calculate probability distributions of dice throw methods.

又爬满兰若 2024-10-22 04:25:00

不,Ant 不是一种编程语言。它是一个用Java编写的构建工具。

Nope, Ant is not a programming language. It is a build tool written in Java.

冷弦 2024-10-22 04:25:00

是的,但只是而已。

我实际上必须在 ant 中编程。我在一家 Java 商店工作,我们使用 ant 来实现它的正确目的,就像 Java 的 makefile 一样,实际上它就是这个用途。但我们想要用它做一些有用的事情,而 ant 脚本对于所讨论的复杂性来说是逻辑上正确的地方。

(在 ant 中进行任意编程的官方方法是用 Java 编写一个扩展。这样做的问题是它不在您正在查看的脚本中,并且它需要编译步骤。因此,用 ant 本身编写是的。)

ant 就像一种深奥的编程语言,其自负在于它都是正确形成的 XML。即使做一些非常基本的事情也需要花几个小时思考如何解决这个问题。您可以将一些恐怖隐藏在宏定义后面。

大多数情况下,您只需使用基本的 ant 就可以完成任务,但如果您想保留宝贵的理智渣滓,则需要 ant-contrib。它包括一些稍微有用的东西,比如变量、算术和流程控制。

因此我的规则是:永远不要让你的领域特定语言图灵完备;
因为一旦您可以在其中编写代码,您就必须在其中编写代码。

蚂蚁编程是一项我不会在简历中列出的技能。

Yes, but only just.

I have had to actually program in ant. I work at a Java shop, and we use ant for its proper purpose, something like a makefile for Java, which it is in fact just the thing for. But we have useful things we wanted to do with it, and the ant script was the logical right place for the complexity in question.

(The official method to do arbitrary programming in ant is to write an extension in Java. The trouble with this is that it's not right there in the script you're looking at, and it requires that compilation step. So, writing in ant itself it was.)

ant is like an esoteric programming language whose conceit is that it's all correctly formed XML. Doing even quite basic things takes a few hours' thought of how to solve this one. You can hide some of the horror behind a macrodef.

You can mostly do stuff with just basic ant, but ant-contrib is needed if you want to preserve the precious dregs of your sanity. It includes slightly useful things like variables, arithmetic and flow control.

Hence my rule: never make your domain-specific language Turing-complete;
because once you can code in it, you will have to code in it.

ant programming is a skill I will not be listing on my CV.

风追烟花雨 2024-10-22 04:25:00

Apache Ant 是声明性领域特定语言,用于使用 XML 描述构建过程。 AFAIK 基本结构不是图灵完整的,所以我不会将其描述为编程语言。当然,通过执行其他程序,您可以实现这些程序所能实现的任何目标。

Apache Ant is declarative domain specific language for describing the build process using XML. AFAIK basic constructs are not Turing complete, so I would not describe it as programming language. Of course, through execution of other programs you can achieve whatever those programs can.

冷了相思 2024-10-22 04:25:00

一般来说,编程语言被认为是描述算法的形式主义。图灵机被认为是执行算法的最通用的机制。

Ant(没有扩展,例如 Ant-Contrib)不是图灵完备的,因为一旦为属性赋值,属性就是不可变的。在整个脚本中,每个属性必须至少显式命名一次。每个蚂蚁脚本都是有限的,因此属性的数量是有限的,因此状态的数量也是有限的。因此,ant 并不是图灵完备的。

因此,我们无法在 ant 中描述任何算法,因此 ant 不是一种编程语言。

Generally, a programming language is considered a formalism to describe algorithms. The turing machine is considered the most general mechanism to execute an algorithm.

Ant (without extension, such as Ant-Contrib) is not turing complete, because properties are immutable once a value is assigned to them. Every property must be named explicitly at least once throughout the script. Every ant script is finite, so the number of properties is finite and therefore the number of states is finite. Hence, ant is not turing complete.

Therefore, one cannot describe any algorithm in ant and thus ant is not a programming language.

一生独一 2024-10-22 04:25:00

编程语言?我想说 Ant 是一种受限的构建脚本语言。这是一个 XML 驱动的产品。

如果被迫选择,我会说它不是一种函数式语言 - 它在精神上更接近命令式/过程式。

Programming language? I would have said Ant was a restricted scripting language for builds. It's an XML-driven make.

If forced to choose, I would say it is not a functional language - it's closer in spirit to imperative/procedural.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文