Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using noweb on a large Java project

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?

like image 362
lindelof Avatar asked Sep 30 '08 07:09

lindelof


2 Answers

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.

like image 108
Jason Catena Avatar answered Sep 21 '22 06:09

Jason Catena


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 doesn't 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?

like image 42
Thorbjørn Ravn Andersen Avatar answered Sep 18 '22 06:09

Thorbjørn Ravn Andersen