在大型 Java 项目上使用 noweb
有没有人在大型 Java 项目上使用过 noweb 文学编程工具,其中有几个源代码代码文件必须在不同的子目录中生成? 你是如何用 noweb 来解决这个问题的? 是否有任何资源和/或最佳实践?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Noweb 将转储相对于当前工作目录或您指定的绝对路径的文件。 只是不要在文件名末尾使用 *(以避免插入 # 预处理器指令)。 我建议使用 %def 和 @ 来显示您定义和使用名称的位置。
noweb 允许您重新排序并(真正的胜利)重用代码片段,我认为 javac 无法理解。
我同意,由于大多数人期望您将使用 javadoc,因此您可能会逆流而上而使用 noweb。
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.
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.
如果生成的中间代码可以指向原始源文件以允许调试和分析编译器错误,那么文学编程效果最好。 这通常意味着预处理器支持,而 Java 不支持。
此外,文学编程对于 Java 来说确实不是必需的,因为最初对严格顺序的需求(这正是促使 Knuth 编写一个工具来将片段按适当的顺序放在一起的原因)并不存在。 文学编程的最后一个好处,即能够编写有关代码的散文,也可以作为 Javadoc 提供,它允许您将所有内容作为注释放入。
对我来说,Java 的文字编程没有任何好处,只会带来麻烦(想象一下获得 IDE 支持)。
您考虑这样做有什么特别的原因吗?
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?