Tuesday 12 November 2013

How on earth did ant become the build tool for java?

I got pretty sick of netbeans taking forever to build a very simple JavaFX app on my apparently now-too-slow (too-little-memoried) dual-core laptop, and so looked into why it was taking so long by creating a Makefile.

I wasn't expecting this ...

[notzed@unknown001fe11d1e42 MapViewer]$ time ant clean jar

... many pages of completely illegible and altogether
    meaningless-to-human-or-computer output ...

BUILD SUCCESSFUL
Total time: 22 seconds

real    0m22.527s
user    0m32.211s
sys     0m1.919s
[notzed@unknown001fe11d1e42 MapViewer]$ make clean all

... a succinct if not particularly human-friendly list
    of the specific commands executed ...

real    0m1.563s
user    0m1.678s
sys     0m0.349s
[notzed@unknown001fe11d1e42 MapViewer]$ 

What? What? Huh?

Oh, so it seems 'ant clean' cleans all related projects as well so it's rebuilding many more files needlessly. I thought one of the main points of having multiple sub-projects is to avoid this kind of thing ... but yeah, "whatever", ... in the parlance of our time.

So what about just changing one file ...

[notzed@unknown001fe11d1e42 MapViewer]$ touch src/mapviewer/MapViewer.java 
[notzed@unknown001fe11d1e42 MapViewer]$ time ant jar

.. pages of crap again ...

BUILD SUCCESSFUL
Total time: 7 seconds

real    0m8.344s
user    0m9.161s
sys     0m1.038s
[notzed@unknown001fe11d1e42 MapViewer]$

Even what amounts to a simple batch script which just does everything from scratch is an order of magnitude faster than using ant - which only compiled one file. With JavaFX (as well as android), netbeans just keeps forgeting to pick up changes so I almost always have to use shift-f11 (complete clean and rebuild) every time I run whatever i'm working on otherwise I get either the old code or runtime failure.

I'm using javafxpackager to create the final jar, and the makefile is only 30 lines long, and you know, at least a bit readable.

I hate to think of the days I alone waste every year because of this completely incompetent and utterly shit tool.

Oh my god, it's full of boggles.

3 comments:

Solerman Kaplon said...

Ant is an old tool. After going to maven, I will never go back to a build tool which can't figure out the needed packages by itself.

It's like after you meet with apt-get: no way I'm going to fiddle with dpkg ou rpm again if I have the choice.

Plus: netbeans have great support for Maven, not so much with eclipse, but last version is bearable.

NotZed said...

My last few experiences with maven were even worse. Much worse.

They include ...

a) Missing repository pieces, preventing code from compiling.

b) Again, totally useless and completely overbose 'user' messages. Useless when it works, and useless when it fails.

c) General complexity.

d) The whole idea of compiling code against on-network resources just doesn't sit well with me _at all_; from a configuration management, testing, practicality (off-line operation), and security standpoint.

e) It's way WAY too slow.

The last thing I tried to build with maven was still going after 20 minutes (on a reasonably beefy bit of hardware, and it wasn't like it was the operating system for the space shuttle here) - I realised if I ever did get whatever it was to compile I would never be looking at it ever again so I cancelled and deleted everything and swore off maven forever.

I don't even like scanning through maven projects because they tend to suffer from severe apothecary drawers syndrome (SADS) - just too many directories whose only purpose is to categorise other directories.

So as far as i'm concerned maven on my totally-shit list along with cmake - if a project uses either of those I wont even bother because it just isn't worth my time trying to get it to work, because the chances of them ever working straight out the box are about as remote as if they were using imake.

At least with ant I can usually get things to compile. Because nobody knows how to edit the labyrinthine 'build' file, they usually leave it alone so it really isn't doing anythimg more than javac src/* anyway - and at worst case I can do that myself.

Before it gets mentioned I think the design of gradle is even worse - because it replaces a tool with a language. This shows a fundamental misunderstanding of tool design which is a completely separate problem from software development. It's a big mistake that i'm certain will haunt quite a few projects at some time in the future.

Fortunately most java projects provide a .jar, and I just use that when available. I tend to avoid using too many libraries anyway - either for licensing or availability reasons.

I do think that java source packaging is pretty fucked up ... but at least if you just copy everything you know it will run and compile. Disk space is expansive and network bandwidth cheap.

I don't really like debian explicitly because of it's packing system amonst a few other things, apt-get included. Actually with all the different and inconsistent tools it's just unnecessarily confusing and seemingly broken - but that's just my opinion based on personal experiences.

Unknown said...

Maven 3 should be fast and once you got all dependencies downloaded the first time, just supply --offline to it and forget about it all. But since you aint going to use any external dependency at all, not much point really seeing what kind of project you have been doing. For pretty complex stuff with dozens of sub-modules and the same amount of external stuff, no one uses ant really