Apache Ant as programming language

3.3k Views Asked by At

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

6

There are 6 best solutions below

5
On BEST ANSWER

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.

1
On

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

1
On

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.

3
On

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.

0
On

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.

0
On

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.