views:

218

answers:

2

Has anyone used the noweb literate programming tool on a large Java project, where several source code files must be generated in different subdirectories? How did you manage this with noweb? Are there any resources and/or best practices out there?

+2  A: 

Literate Programming works its best if the generated intermediate code can point back to the original source file to allow debugging, and analyzing compiler errors. This usually means pre processor support, which Java does'nt support.

Additionally Literate Programming is really not necessary for Java, as the original need for a strict sequential order - which was what prompted Knuth to write a tool to put snippets together in the appropriate sequence - is not present. The final benefit of literate programming, namely being able to write prose about the code, is also available as Javadoc which allow you to put everything in as comments.

To me, there is no benefit in literate programming for Java, and only troubles (just imagine getting IDE support).

Any particular reason you are considering it?

Thorbjørn Ravn Andersen
+2  A: 

Noweb will dump out files relative to the current working directory, or at the absolute path you specify. Just don't use * at the end of your filename (to avoid inserting the # preprocessor directives). I would recommend using %def with @ to show where you define and use names.

<</path/to/file.java>>=
  reallyImportantVariable += 1;
@ %def reallyImportantVariable

noweb lets you reorder and (the real win) reuse snippets of code, which I don't think javac would understand.

I'd agree that since most people expect that you'll use javadoc, you're probably swimming against the stream to use noweb.

Jason Catena