Hacker News new | ask | show | jobs
by dnesteruk 3933 days ago
Looking at the HTML output, I'm not sure this consitutes proper literal programming due to the amounts of 'contextual noise' that the processor generates. I think the goal is to have the program read more or less like a book, and this...

{Print "hello world" 2} ≡

printf("Hello world"); This code is used in section 1.

...is not exactly it. It feels more like program-in-program Matrixy thing than a document to be read.

1 comments

The output is basically designed to look like the output of Knuth and Levy's CWEB tool. Maybe a better example to look at on the "try it" page is the wc.lit example, which makes a word count program. It's based on Knuth and Levy's wc.w tutorial example, and gives a similar output.

Of course, there are advantages of Literate's output compared with CWEB's; it's more flexible in that you can embed arbitrary HTML in the output, so you can easily put images into your explanations, and you can put as many code blocks and text blocks as you like in each paragraph.