Thoughts On ...

October 19, 2004

Structureless Programming

Imagine a programming language with one namespace. One where all variables (including parameters) are one big happy ball of interacting goo and functions are only usable by side-effect. Add a cumbersome verbose syntax, make it relatively slow, and provide only one data type. Remove any sort of debugger or trace mechanism and make what errors you do generate cryptic and misleading. Finally, top it all off with a standard programming idiom that encourages long dependency chains and reusing functions with different side-effects.

The result? Writing large build scripts in NAnt.

As Martin talks about, at some point build scripts for a code base of any size shift from being primarily declarative descriptions of what to build to ever larger procedural descriptions of how to build it.

Its not the NAnt guys fault -- Ant suffers from similar limitations -- Its just that XML is truly awful for this sort of procedural work. In fact, as both projects have added more and more features, they've continued to push back the limit after which the complexity just becomes too much. Unfortunately, all this does in the end is make the resultant mess that much more difficult to clean up.

Good standards, obsessive removal of duplication (tip: keep paths that aren't prefixed with a root property to a bare minimum) and an even more obsessive (and often conflicting) attention to reduction of cross-file calls and overly-clever reuse of workflows can extend the boundary, but in the end I think there is just a limit to what you can do with these XML-based MAKE tools. Sooner or later, you get wedged in tight, and there's nowhere to go (but into the next hour of debugging).

I have been up against this limit on more than one occasion -- including right now (I am writing this on a couple hours of sleep after working through a never-ending thread of dependency woes), and I am convinced that while NAnt is a great tool, its not necessarily the right tool for large build projects.

But I am going to use some of this pain to my advantage. I am going to take this big hairy code base (8300 files, 3300 tests and approximately 15 build scripts -- some over 700 lines long) and see if building it using RAKE is easier to maintain.

I suspect it will be, because in the end build scripts are just code -- with all of the design and architecture issues faced by other systems. Building systems in a language that has the limitations listed above just doesn't scale. Such considerations are why (among other things) OO languages have classes, and functional languages eschew side-effects in functions.

Seeing as how RAKE is just Ruby (which has these and other modern PL constructs), I fully expect to be able to push the wedge point back even further -- perhaps far enough to handle the larger, interdependant build scenarios that our clients seem to increasingly find themselves trying to manage.

If I get the chance, I'll try to write it up as an article (which I want to do more of now that I have some time).

Posted by wcaputo at October 19, 2004 05:01 PM
Comments

As I was reading your article, I kept thinking "He needs to use Rake, he needs to use Rake ...". So I was pleasantly surprized to see that is exactly where you end up.

From your reference to NAnt, I assume you are working on a .Net project. I have not heard of anyone using rake in that environment yet, so I would love to hear any feedback on your experience with Rake. And feel free to contact me with questions.

Good luck.

-- Jim Weirich (Rake developer)

Posted by: Jim Weirich at October 20, 2004 12:12 PM

So nice to see that you're blogging again. This is just another fine piece of writing. Funny, entertaining, but above all, interesting and with a strong point.

Posted by: Jan Van Lysebeth at October 20, 2004 05:01 PM

Yes, yes, yes! Hacking large (n)ant scripts has to be one of the demoralising activities in software today. Especially, when the original authors tried to be clever.

Posted by: Steve Freeman at October 31, 2004 08:10 PM

Gee, I wonder where you would find such a "big, hairy code base". But yes, I've felt kind of queasy about the size and complexity of our Nant scripts but I thought I just didn't get it or hadn't spent enough time to understand them. But I appreciate all your effort and I'm interested in how RAKE works out.

Posted by: David Rhodes at November 3, 2004 11:52 AM

"I fully agree with you.

Ant (or any other xml based scripting language) just doesn't scale."

Do you think this is because of something inherent in XML, or is the problem with those XML-based languages to date? I would think that one could recreate Lisp as an XML language, and certainly Lisp scales.

I'm not arguing for this; I'm a Rake fan. I think the error of the more common XML languages, though, is that of trying to use a syntax better suited for specifying a funtional programming language to design what seem to be largely procedural languages, or at least an awkward hybrid.

Posted by: James Britt at November 10, 2004 10:32 AM

Thanks Jim, I'll post something if/when I get a chance to try RAKE on that code base.

Jan, thanks for the kind words.

James, I think syntax is part of it (the XML gets really wordy, and I can't seem to remember any of the properties for NAnt elements), but a lot of it is just implementation. N/Ant are both great tools -- to a point, they just weren't conceived as true PL's and they don't have the constructs, and other protections for writing larger scaled programs (IMHO).

Posted by: bill at November 11, 2004 10:35 PM