| « Buy Boogaloo Stuff | Programming Versus Learning » |
I Hate Ant
May 30th, 2007Last Meal by Shannon.
I hate Ant. Ant takes a miserable task and makes orders of magnitude more difficult. It is a horrible piece of software. I am constantly amazed at the traction it has gained.
Ant is a dependency management system, or rather that’s the void that it fills. Make for Java. However, unlike Make, Ant cannot build a dependency tree of an entire project, mapping dependencies from one target to the next.
They defend themselves. It is explained that it is a declarative language, not an imperative language, and you need to think declaratively. That’s a behavior they’ve aped from the SQL community. However, SQL is a declarative language, based on years of database theory.
The SQL community tells you think declaratively, so that you might open your mind to the rich expressiveness of relational calculus. The Ant community tells you to think declaratively, because they don’t have an answer for your question. Don’t go off thinking declaratively, expecting that your problems with Ant will ever be solved.
Yes, SQL is declarative, think declarative in SQL. Lisp is functional, think functional in Lisp.
Ant is broken. A real build system is a dependency management system. It should manage your dependencies. It should not ask you to change your thinking. It has nothing more to say.
Who wants to change their thinking for the sake of a build? A build system should be cursory consideration, not mental discipline.
Eventually, you’re going to install one of many Ant tasks that implement a loop, or embed JavaScript, or generate your Ant scripts, or write a bash program that will actually get the job done.
Ant is not a dependency management system. What is it then?
It’s concept of dependencies are nothing more than procedure calls. An Ant target is a procedure with no logical branches. Ant dependencies are a series of subroutine calls that can only be invoked at the start of the subroutine.
They fire unconditionally, they perform no checking of dependencies. They will not be skipped because their dependent files are up to date.
This is because, unlike C where dependencies form a tree, Java can have cyclical dependencies. The Java compiler does it’s own dependency management. This led the developers to decide that system wide dependencies were unnecessary.
The result is that every task has to manage it’s own dependencies. Few of them do. The copy command does, the zip command does. That’s about it. Most of them are procedures with a myriad of named parameters.
A target will always evaluate. They may not execute because of a condition attached to them, but that condition will have to be set by a task that executed prior. If you really do want to check dependencies, you are going to have a chain of targets. The noise that produces on the command line makes watching an Ant build akin to reading a core dump.
What does Ant give you that keeps people from running away? It doesn’t do repository management. We need Maven to cock that up.
I’ve abandoned the pointless XML files. I’m building in Groovy now, so I don’t have to pretend that Ant is teaching me how to think declaratively. I have real data structures and algorithms to make short work of what should be a short task.
I must still use AntBuilder and here’s what for. Ant wraps the Java compiler, and JUnit. Ant implements a form of file globbing. It has file system comfort functions, like conditional recursive copy and a recursive delete.
I Hate How Much I Hate Ant
Many drafts of this post. I wasted a morning looking for a photograph to accompany it. An important morning at that. I can’t find one. I don’t want to show ants, because they are ugly. I don’t want to show them eating poison, because they are ugly, even if they are going to die soon.
I hate Ant. I hate it because I spent a lot of time on it and in the end I did not use it. I spent months on the sort of non-trivial build. That sort that Ant will have you abandon your real project, and make Ant your project. I tried to generate Ant with with XSLT. I tried using the includes. I spent hours trying to push the limits of a this stupid batch file format.
I hate how much I hate something trivial. I hate how much I hate Ant. I can’t find a photograph, because it is such toxic process to do so. What conveys your hatred for a tool that makes a process even more labor-intensive? What conveys your hatred for an entire community that adheres to this childish weekend hack, this manifestation of a gross misunderstading of XML as a standard when it is so terribly easy to write a replacement?
Is it that Java is so permiated with bloatware marketing, that it has become part of the mindset of the open source Java community? Talking about a standard build tool, and that build tool is a hopeless joke, but if we talk right, it will correct itself, because it is a standard.
I am going to end this by saying, I don’t like bile. It is much easier to be creative than critical. It takes much less effort. It becomes almost effortless.
Revisiting my build system sucked me into the fear of getting sucked into build configuration and not shipping.
The approach has been toxic. It is here so I can revisit it.
(6)
|


Comments 

Wow. What bile.
I use Ant. I like it. I use it to manage about a half-dozen related projects in a single svn repository. I like it because I found it quite manageable to make a simple build file that I can extend with different behaviors in different projects. Yep, it took a while to get it right. It was not trivial.
One time I felt the need to use the antcontrib for loop. Its still in my build files, but the functionality that it implements is now obsolete. In that sense, ant was write: I didn’t need that logic. I just hadn’t realized it yet - and I wouldn’t realize it until I did it and discovered it was pointless.
Yes, Ant has warts, repository management being far and away the largest (in my humble opinion). Exploring maven is always on my to-do list. But much as you express fear of ant becoming a project itself, taking you away from your real project, I resist moving to a different “better” system: doing so will become a project itself. And as it stands now, I don’t even notice my build. It just works.
I steadfastly believe that there is no perfect build system. Each build system has staunch defenders and just-as-staunch ridiculers. Build systems are inherently complex, and inherently customized by the project they are used in and the developer using it. Ant works for me - sorry it doesn’t for you.
But I’d love to hear you try to convince me to use Maven. I want to, but I don’t want to invest the time it would take to rewrite my builds.
Maven is Ant compounded. Maven makes me seethe. It is pestilence.
This is one of the funniest posts I have come across. I say that because I just lost a day of my life trying to do trivial tasks, but ANT made it exceedingly painful. As I was searching the web for help I came across your post and throughout the last day those very words had been echoing through my head. Our current build system is based on ANT, thus I have no choice. I could have done the same thing in Ruby/Rake in 2 hours or less. I heartily concur on all your points.
See Paul, I’m not alone. Chuck, for me I don’t see how XML is an expression of program logic, it’s not, but I don’t see why I’d want to so something so obviously programmatic, and building a computer program, without a real programming language.
I can loop through the directories and… Uh, wait. There is no looping. I can recurse through the directories and… Uh, wait. There is no recursion. I can create a static fixed set of directories and type the same thing over and over again. That is what Ant considered simplicity.
I was always happier with Make, bash and Perl. Ruby/Rake I’m sure has the same, yeah, I can do that, expressiveness, I’m sure.
[...] I hate Ant. [...]
Nice article - after many years of using “make” with gnu tools to build projects written in C, C++, python, perl, lisp, even java and some other languages I must use “ant” in java projects…
I think the person who wrote “ant” must have really hated people.. I can’t imagine any other explanation for such terrible tool…
BTW - what is it in which “ant” really IS better than “make” ? The only thing I’ve ever heard is that “make” has this “tab vs space” problem… uhm.. is this really so big problem to set up your editor/IDE to use real tab characters when editing Makefiles?
oh, and I must not forget - ANT is in java so it’s 100% portable… uhm.. wait.. no.. no it isn’t if you are doing anything non-trivial…
“make” depends on underlying unix-like system (so it worked only on: Linux, AIX, HP*UX, OpenBSD, FreeBSD, NetBSD, Mac OS, Solaris, IRIX, MS Windows with CYGWIN .. I’m sure this is not complete list..) and its tools, and allows you to use _easily_ any other programs, scripts or anything…
“ant” on the other hand is written in java and does not depend on your OS.. so instead of using some nice cooperating system tools like cat, grep, nc, wget, find, diff, sed and many others, we can use THE ONLY ONE TOOL ANYONE WOULD EVER NEEDED - java.. hmm.. so instead of one line in sed, I write 20 lines in java, creating new ant task.. great! .. and of course, you can call any script/program from your ant buildfile.. why not.. well.. maybe not because then you lose your 100% portability and still easy things are not easy and complicated things are even more complicated… hmm.. is this really better than “make” ?
…I miss “make” so much