News for hackers. Stuff that matters.
Re:Sile: A Modern Rewrite of TeX by daly on Thursday November 03, 2022 @02:27PM (#33455274)
TeX and Literate Programming (and Lisp) are my fundamental, day-to-day tools.

Code it, explain it, generate a Literate PDF containing the code.

The programming cycle is simple. Write the code in a latex block. Run make. The makefile extracts the code from the latex, compiles it, runs the test cases (also in the latex), and regenerates the PDF. Code and explanations are always up to date and in sync.

I have found no better toolset.

Re:Sile: A Modern Rewrite of TeX by muds on Thursday November 03, 2022 @04:06PM (#33456751)
I've been struggling with keeping track of research experiments and code at the same time. This seems pretty cool! I like how this method is language agnostic and uses "matured" tools. Question: I'd love to give this a try; do you have any public code snippets?
Re:Sile: A Modern Rewrite of TeX by daly on Thursday November 03, 2022 @04:24PM (#33456972)
https://en.wikipedia.org/wiki/Axiom_(computer_algebra_system...

This is (most of) the source code for Axiom. The code is extracted from the latex for these pdfs.

Re:Sile: A Modern Rewrite of TeX by dcuthbertson on Thursday November 03, 2022 @09:29PM (#33460558)
FYI: axiom-developer.org/ seems to be down
Re:Sile: A Modern Rewrite of TeX by kkfx on Thursday November 03, 2022 @05:32PM (#33458011)
Not really a programmer (sysadmin) but I've tried the literate way with org-mode for my stuff and I use LaTeX for all "pretty docs" needs, however while for document production LaTeX excel literate programming AS A MERE CONCEPT for me does not work that much:

- simple things became uselessly lengthy and prolix

- complex things became too big to be easy read, while the equivalent "pure-code with comments" and a small new developers doc while fail to give an equally deep knowledge of the code base is FAR more quick and easy accessed.

Maybe it's my style, I do not know but while I do not feel LaTeX as painful, since most my docs are of the same kind so a template/class produced once with calm get reused issueless, I can't really digest literate programming...

Re:Sile: A Modern Rewrite of TeX by mirekrusin on Thursday November 03, 2022 @05:56PM (#33458358)
With pluto/jupyter/observable you can make it live.
Re:Sile: A Modern Rewrite of TeX by taeric on Thursday November 03, 2022 @07:43PM (#33459583)
I'm curious what literate style you use? I have tried getting into the style a few times, but I often find I'm not taking advantage of the full scramble of the code that is often possible.
Re:Sile: A Modern Rewrite of TeX by daly on Friday November 04, 2022 @05:29AM (#33463869)
The literate macro is just standard latex. The command line extraction functions are:

Lisp program to extract latex chunks: https://github.com/daly/axiom/blob/master/books/tangle.lisp

C program to extract latex chunks: https://github.com/daly/axiom/blob/master/books/tanglec.c

Note that the C program is just a hand translation of the Lisp code.

The lisp code has an explanation and the necessary latex macros. The idea is to scan the latex, find each named code 'chunk', and add each one to a hash table. Then the hash table is scanned to dump the requested chunk to stdout. For example:

\begin{chunk}{part1} code for part 1 \end{chunk}

Ordinary latex code between chunks.

\begin{chunk}{part2} code for part 2 \end{chunk}

\begin{chunk}{part1} this code will be appended to the prior chunk \end{chunk}

\begin{chunk}{getall} \getchunk{part1} \getchunk{part2} \end{chunk}

Assuming the above chunks are in the file foo.tex then

tanglec foo.tex getall >getall.code

will print out the named chunk (getall). For an individual chunk use

tanglec foo.tex part2 >getsome.code

Re:Sile: A Modern Rewrite of TeX by contrapunctus on Friday November 04, 2022 @11:29AM (#33468350)
You may be interested in using Org [1], in conjunction with literate-lisp [2] (for Common Lisp) and literate-elisp [3] (for Emacs Lisp). Org provides various outlining commands (among other things), letting you view your program at different levels of granularity. literate-lisp/elisp advise the Lisp reader so the Org file can be loaded and/or compiled directly, without requiring tangling. Consequently, tools like xref will jump to the source block in your Org file, rather than the tangled source. I wrote a little hack/guide to extend this to errors raised in Emacs' compilation-mode. [4]

(Unfortunately, the package that lets each Org source block behave as though it was using the corresponding language's Emacs major mode - poly-org-mode - has a ton of bugs. It was part of why I stopped using literate programming entirely for later projects.)

[1] https://orgmode.org/ [2] https://github.com/jingtaozf/literate-lisp [3] https://github.com/jingtaozf/literate-elisp [4] https://contrapunctus.codeberg.page/blog/literate-programmin...

Re:Sile: A Modern Rewrite of TeX by mark_l_watson on Friday November 04, 2022 @11:42AM (#33468551)
I work with the author of your link [2], and his literate programming documents for Common Lisp are awesome. Watching him during Zoom screen-shares is fun. I am not currently a user of literate-lisp but it is on my non-urgent to-do list.
Re:Sile: A Modern Rewrite of TeX by daly on Saturday November 05, 2022 @12:53AM (#33478093)
I should have mentioned that emacs is also a fundamental tool for all of my work. But since everyone, everywhere uses emacs that would be stating the obvious :-)

I tried orgmode. I even attended a course at CMU that used it for the "live notes". It is excellent for teaching. But it has the same flaw as the "live notebook" idea. There is no generally accepted structure to the approach.

Everyone "understands" books. They have a preface, chapters, an index, a bibliography, pictures, credits, and a table of contents. Literate programs leverage that shared understanding of the structure.

Think of a physics textbook. If you just copy every equation out of the book then you "have the code". All the rest is explanation. They belong together so the explanation and equations (code) are intermingled.

I'm a "primitivist". I work in straight text at an emacs buffer in fundamental mode.

The point of my code is to "talk to the machine". The point of my literate program is to "explain to other programmers (mostly 'future' me)". Note that this is NOT DOCUMENTATION. It is explanation, best presented in book form.

Re:Sile: A Modern Rewrite of TeX by mark_l_watson on Friday November 04, 2022 @11:47AM (#33468619)
About 12 years ago, I used LaTex to write a semantic web book, but in 2 editions: Common Lisp and Java. It was very cool to have 2/3 of the manuscript common text, and about 1/3 unique to the programming language.

For the last two evenings, I have been revisiting my old manuscript materials because I am thinking of updating the material and also creating additional editions for more programming languages: Python, JavaScript, and maybe Swift and Prolog.

I had forgot how cool TeX and LaTex are. It was very easy to start working with again, even after a 12 year gap.