Hacker News new | past | comments | ask | show | jobs | submit login

The literate programming is very under rated in Jupyter Notebook. It is mainly used for experiments. I hope that in the future there will be more applications in notebook for example in automation. Can you imagine notebooks replacing services like zapier?



Plain Jupyter Notebooks though offer only a fraction of what makes literate programming. They would need features like cell references, tangling and multi-lang in one notebook, to get close to other LP tools.


Why? Isnt enough if you mix markdown with code? What are other tools for LP?


LP permits arbitrary reordering of the code and a text macro-ish ability to plug in code to any other block of code (when tangling). Most of the markdown-centric tools for "literate programming" I've seen don't permit that, instead they just allow a cleaner interleaving of document and code but the code is still ordered exactly as if written in a conventional style. In WEB/CWEB-derived literate programming you could do something like this (very quick sketch):

  <<game-loop>> ==
    while (!dead) {
      <<get-input>>
      <<update-world>>
      <<display-world>>
    }
And way down at the end of the program you can do this:

  <<main.c>> ==
    <<includes>>
    <<globals>> // if appropriate
    int main() {
      <<initialize-game>>
      <<game-loop>>
      return 0;
    }
Throw that in an appendix or something because it's such blindingly obvious code (for C) that you don't need to dwell on it. It's not critical to the discussion contained in the rest of the text unless you're also providing a tutorial on C programming.

And, you can (like I said, text macro-ish) reuse blocks of code in multiple places. Maybe you have some common header files, you could write this:

  In order to have access to OpenGL capabilities, many of the .c files
  will require this header block:

    <<OpenGL-includes>> ==
      #include<GL.h>
      ...
And now when you want to include them, you just reference this. Of course, in C you could just create a common.h file or something and tuck the includes into that, but not every language has text inclusion of that same sort. If, for instance, you were writing Java or C# or something you could use the above modified to call whatever appropriate package imports were needed. Then update it in one place and all of them get updated.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: