Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Don't go surfing in South Dakota for a while.


comp / comp.programming.literate / "hello, world" Literate Programming example in Noweb

SubjectAuthor
* "hello, world" Literate Programming example in NowebEdward McGuire
`* Re: "hello, world" Literate Programming example in NowebWolfgang Agnes
 `* Re: "hello, world" Literate Programming example in NowebEdward McGuire
  `- Re: "hello, world" Literate Programming example in NowebWolfgang Agnes

1
Subject: "hello, world" Literate Programming example in Noweb
From: Edward McGuire
Newsgroups: comp.programming.literate
Organization: A noiseless patient Spider
Date: Thu, 31 Oct 2024 22:17 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: metaed@metaed.com (Edward McGuire)
Newsgroups: comp.programming.literate
Subject: "hello, world" Literate Programming example in Noweb
Date: Thu, 31 Oct 2024 16:17:17 CST
Organization: A noiseless patient Spider
Lines: 7
Approved: comp.programming.literate Moderators <cpl-mods@newjersey.metaed.com>
Message-ID: <slrnvi7bag.hge.metaed@newjersey.metaed.com>
Injection-Date: Thu, 31 Oct 2024 17:17:21 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c70c0ad9c85e6561e0284af1d3636a7a";
logging-data="2912321"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ywDesK4n59Uu0/jYVkbKY"
User-Agent: slrn/1.0.3 (Linux) tinews.pl/1.1.59
Cancel-Lock: sha1:KW1FbB49eEwNQReIgQ8qnqB+yGA=
sha1:KW1FbB49eEwNQReIgQ8qnqB+yGA=
Authentication-Results: name/695CE5F70C; dmarc=none (p=none dis=none) header.from=metaed.com
X-cpl-info-1: submissions to cpl@newjersey.metaed.com
X-Spam-Status: No, score=-99.8 required=5.0
tests=HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,
RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,
USER_IN_WELCOMELIST,USER_IN_WHITELIST autolearn=no autolearn_force=no
version=3.4.6
X-Original-To: cpl@newjersey.metaed.com
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
smtp.eternal-september.org
Delivered-To: comp-programming-literate@moderators.isc.org
DKIM-Filter: OpenDKIM Filter v2.11.0 mod-relay.zaccari.net C7C0B5FD1F
X-cpl-info-2: contact mods cpl-mods@newjersey.metaed.com
X-Auth-Sender: U2FsdGVkX18sd11yOH0u48dd2kD2NTE8ZdvIvrddIIhIUSjRaaD96qxn8w2GWU72acD9rXiRVoL44TlnJGRtUHsmkFNb2B6e
View all headers

Happy birthday to me. To celebrate, I'm releasing a simple Literate Programming
tutorial based on the classic C "hello, world" program.

https://metaed.com/papers/hello/

This is in the nature of a draft. Suggestions are welcome.

Subject: Re: "hello, world" Literate Programming example in Noweb
From: Wolfgang Agnes
Newsgroups: comp.programming.literate
Organization: A noiseless patient Spider
Date: Fri, 1 Nov 2024 23:28 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wagnes@jemoni.to (Wolfgang Agnes)
Newsgroups: comp.programming.literate
Subject: Re: "hello, world" Literate Programming example in Noweb
Date: Fri, 1 Nov 2024 17:28:48 CST
Organization: A noiseless patient Spider
Lines: 67
Approved: comp.programming.literate Moderators <cpl-mods@newjersey.metaed.com>
Message-ID: <87ttcqzxy9.fsf@jemoni.to>
References: <slrnvi7bag.hge.metaed@newjersey.metaed.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Fri, 01 Nov 2024 18:28:51 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7b1556c620441046d1cca0859d4b115d";
logging-data="3515716"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CUw4iGDyUyh0X5mLfgpkr"
Cancel-Lock: sha1:3sIo1VzhJsjkboT2wxvgYZ/IAv4=
sha1:gBJZ6+tldnatatsT0x9IzjnDcBE=
sha1:gBJZ6+tldnatatsT0x9IzjnDcBE=
X-Spam-Status: No, score=-98.9 required=5.0 tests=DKIM_ADSP_NXDOMAIN,
HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,
RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED,
SPF_HELO_NONE,T_SPF_TEMPERROR,URIBL_BLOCKED,USER_IN_WELCOMELIST,
USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.6
X-Auth-Sender: U2FsdGVkX1/w+TevmQ2omjnVpgEdFYv4jO5KvQ4gkB17HT0d97Wm4Y6bDoQqBwGHxMWN/aKGO0TfQb2k4l4QvoFfSkdHl5TuCZONX0YxsI0=
Delivered-To: cpl@newjersey.metaed.com
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
smtp.eternal-september.org
Authentication-Results: name/AEE425F701; dmarc=none (p=none dis=none) header.from=jemoni.to
X-Original-To: cpl@newjersey.metaed.com
X-cpl-info-2: contact mods cpl-mods@newjersey.metaed.com
X-cpl-info-1: submissions to cpl@newjersey.metaed.com
View all headers

Edward McGuire <metaed@metaed.com> writes:

> Happy birthday to me.

Happy birthday!

> To celebrate, I'm releasing a simple Literate Programming tutorial
> based on the classic C "hello, world" program.
>
> https://metaed.com/papers/hello/

NICE! Welcome to the literate programming world. I think you made the
best choice---NOWEB by Norman Ramsey. It's not that other tools are
inferior, but that Ramsey's LaTeX layout happens to be the most
beautiful one.

> This is in the nature of a draft. Suggestions are welcome.

I liked the introduction. However, notice that by calling your chunks
as holons, you're eclipsing the name ``chunk'' which seems to be the
understand one. Something to think about.

Also, you begin your program with hello.c---external declarations and
procedure definitions. It's questionable whether this is the best
presentation. This chunk is what the /compiler/ expects to see:
declarations first, then definitions. Is it what humans should see?
Why don't we go straight to the essence of the program and leave the
compiler preferred order for last? You observed that in the NOWEB
section:

--8<-------------------------------------------------------->8---
And they let you organize the sections of the work in the order that
makes sense to the future programmer, instead of in the order that the
programming language constrains you to.
--8<-------------------------------------------------------->8---

So I would say that perhaps the first chunk should be /hello main body/
because that is precisely what we expect from a hello-world.

I see you explain the NOWEB terminology. I wonder if Knuth was the one
who started with the term /chunk/ as well. If so, then I'd advise
against /holon/.

Thanks for keeping this newsgroup alive.

(*) Cosmetics

Your section 2 could use some cosmetic treatment. For instance, the
source code shown should perhaps be separated by a blank line from the
paragraph above.

Your section 5 could be reduced so as to get the section title in a
single line. Perhaps ``a complete program embodied in one file''.

(*) Makefile

More often than not, users don't have NOWEB installed, so they wouldn't
be able to do anything with your program but read it. So I usually
leave the Makefile outside of NOWEB as a stand-alone file and I include
in the package the C source files so that users don't need to have NOWEB
to just compile and run the program.

We could still put the Makefile inside of NOWEB and get it out before
packaging, but I actually like to use the Makefile to detect when make
itself should invoke noweb. In other words, I can prefer to have make
as the main driver.

Subject: Re: "hello, world" Literate Programming example in Noweb
From: Edward McGuire
Newsgroups: comp.programming.literate
Organization: A noiseless patient Spider
Date: Sat, 2 Nov 2024 03:23 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: metaed@metaed.com (Edward McGuire)
Newsgroups: comp.programming.literate
Subject: Re: "hello, world" Literate Programming example in Noweb
Date: Fri, 1 Nov 2024 21:23:39 CST
Organization: A noiseless patient Spider
Lines: 52
Approved: comp.programming.literate Moderators <cpl-mods@newjersey.metaed.com>
Message-ID: <slrnviahks.hge.metaed@newjersey.metaed.com>
References: <slrnvi7bag.hge.metaed@newjersey.metaed.com>
<87ttcqzxy9.fsf@jemoni.to>
Injection-Date: Fri, 01 Nov 2024 22:23:43 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7b1556c620441046d1cca0859d4b115d";
logging-data="3593942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UhjuC2ntxzf1ekoP9JToV"
User-Agent: slrn/1.0.3 (Linux) tinews.pl/1.1.59
Cancel-Lock: sha1:aAiRrElaQcMnKVcK7PIQ+FqN3cE=
sha1:aAiRrElaQcMnKVcK7PIQ+FqN3cE=
Delivered-To: comp-programming-literate@moderators.isc.org
DKIM-Filter: OpenDKIM Filter v2.11.0 mod-relay.zaccari.net 461EE61106
X-cpl-info-2: contact mods cpl-mods@newjersey.metaed.com
X-Original-To: cpl@newjersey.metaed.com
X-Spam-Status: No, score=-99.8 required=5.0
tests=HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,
SPF_HELO_NONE,SPF_PASS,USER_IN_WELCOMELIST,USER_IN_WHITELIST
autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
smtp.eternal-september.org
X-Auth-Sender: U2FsdGVkX18s5LAAoA/7dx87AbMFUbmnsiwJHBZrRzurCIBiqtAoZsyunrXxvTIv1Uq2aAEpFrOU6T03CI2BXEfe6uaC55Ni
X-cpl-info-1: submissions to cpl@newjersey.metaed.com
Authentication-Results: name/78D145F701; dmarc=none (p=none dis=none) header.from=metaed.com
View all headers

On 2024-11-01, Wolfgang Agnes <wagnes@jemoni.to> wrote:
> Welcome to the literate programming world.

Thank you, especially for the really thoughtful response. This kind of
constructive reply is exactly what I wanted.

> perhaps the first chunk should be /hello main body/ because that is precisely
> what we expect from a hello-world.

I agree. Part of what's fun about this design process is, instead of starting
literally at the top and sectioning down, or at the bottom and chunking up, you
can start at the middle, then both section down and chunk up. Knuth discovered
this was true for him also, and mentions it in the "Literate Programming" paper.
The tutorial should be reordered to demonstrate that.

> by calling your chunks as holons, you're eclipsing the name ``chunk'' which
> seems to be the understand one. Something to think about.
> [...]
> I see you explain the NOWEB terminology. I wonder if Knuth was the one
> who started with the term /chunk/ as well. If so, then I'd advise
> against /holon/.

My choice of _holon_ reflects my intention that the tutorial be, or become, less
about a particular tool, and more about what literate programming _is_, while
still showing a working example.

Knuth uses neither _chunk_ nor _holon_. In the "Literate Programming" paper, he
acknowledges de Marneffe's Holon Programming Language as the primary influence
on the design of WEB, but does not follow de Marneffe's terminology. In the WEB
manual he uses _module_, and in CWEB he uses _section_. Ramsey (noweb) uses
_chunk_. Briggs (nuweb) uses _scrap_ and _macro_. In short, there is no
agreed-on term.

The term _holon_ captures good design better than the others. It describes a
relatively independent "organic" or "granular" unit of code, whose form and
purpose is easily graspable by the reader, and whose boundaries easily allow for
sectioning down and chunking up, validation, testing, refactoring, etc. And
that's what a good literate programmer aims for.

> (*) Cosmetics

Again thank you.

> More often than not, users don't have NOWEB installed, so they wouldn't
> be able to do anything with your program but read it.

I need to add an appendix, that shows how a person could easily get Noweb
running and actually execute the tutorial code.

Cheers!
Edward

Subject: Re: "hello, world" Literate Programming example in Noweb
From: Wolfgang Agnes
Newsgroups: comp.programming.literate
Organization: A noiseless patient Spider
Date: Sat, 2 Nov 2024 05:11 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wagnes@jemoni.to (Wolfgang Agnes)
Newsgroups: comp.programming.literate
Subject: Re: "hello, world" Literate Programming example in Noweb
Date: Fri, 1 Nov 2024 23:11:48 CST
Organization: A noiseless patient Spider
Lines: 68
Approved: comp.programming.literate Moderators <cpl-mods@newjersey.metaed.com>
Message-ID: <87froazhac.fsf@jemoni.to>
References: <slrnvi7bag.hge.metaed@newjersey.metaed.com>
<87ttcqzxy9.fsf@jemoni.to>
<slrnviahks.hge.metaed@newjersey.metaed.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 02 Nov 2024 00:11:51 +0100 (CET)
Injection-Info: dont-email.me; posting-host="d11f8fec12cda9e4e4378705441680ae";
logging-data="3629143"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5JIcYM6Ghw4rO2gHeAe15"
Cancel-Lock: sha1:0/hLwhPmKaHUUBYYxt/Xr9knh6M=
sha1:sw1Xmt0Pzu8YHWN3fO8tYy7yikU=
sha1:sw1Xmt0Pzu8YHWN3fO8tYy7yikU=
Delivered-To: comp-programming-literate@moderators.isc.org
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
smtp.eternal-september.org
X-Spam-Status: No, score=-99.0 required=5.0 tests=DKIM_ADSP_NXDOMAIN,
HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_PASS,
USER_IN_WELCOMELIST,USER_IN_WHITELIST autolearn=no autolearn_force=no
version=3.4.6
X-cpl-info-2: contact mods cpl-mods@newjersey.metaed.com
X-Original-To: cpl@newjersey.metaed.com
Authentication-Results: name/E97C65F701; dmarc=none (p=none dis=none) header.from=jemoni.to
X-Auth-Sender: U2FsdGVkX1+jAC93o3y/2wCu0yVMw4TMqB+UH4ONNPY5x1PIOvOcu81wrmGSaIGF81bL4swmFKTBj4s8TxqlvLMvrgn0epWW4DmKH7D0gs0=
X-cpl-info-1: submissions to cpl@newjersey.metaed.com
View all headers

Edward McGuire <metaed@metaed.com> writes:

> On 2024-11-01, Wolfgang Agnes <wagnes@jemoni.to> wrote:
>> Welcome to the literate programming world.
>
> Thank you, especially for the really thoughtful response. This kind of
> constructive reply is exactly what I wanted.

You're so welcome. Glad I could be of some help.

>> perhaps the first chunk should be /hello main body/ because that is precisely
>> what we expect from a hello-world.
>
> I agree. Part of what's fun about this design process is, instead of starting
> literally at the top and sectioning down, or at the bottom and chunking up, you
> can start at the middle, then both section down and chunk up. Knuth discovered
> this was true for him also, and mentions it in the "Literate Programming" paper.

Nice. That's also why I like it so much. I had never noticed how the
compiler order is such a prison. Knuth liberated us from that. It
makes a lot of difference. It brought a pretty good deal of the joy of
programming back to me. (Lisp brought another half of that joy.)

> The tutorial should be reordered to demonstrate that.

Okay.

>> by calling your chunks as holons, you're eclipsing the name ``chunk'' which
>> seems to be the [standard] one. Something to think about.
>> [...]
>> I see you explain the NOWEB terminology. I wonder if Knuth was the one
>> who started with the term /chunk/ as well. If so, then I'd advise
>> against /holon/.
>
> My choice of _holon_ reflects my intention that the tutorial be, or become, less
> about a particular tool, and more about what literate programming _is_, while
> still showing a working example.

Interesting. I agree with that. I should've also said that I really
enjoyed the term, though if everyone *were* using a single one---say,
``chunk''---, I'd stick to it, but you showed that's not the case.

> Knuth uses neither _chunk_ nor _holon_. In the "Literate Programming" paper, he
> acknowledges de Marneffe's Holon Programming Language as the primary influence
> on the design of WEB, but does not follow de Marneffe's terminology. In the WEB
> manual he uses _module_, and in CWEB he uses _section_. Ramsey (noweb) uses
> _chunk_. Briggs (nuweb) uses _scrap_ and _macro_. In short, there is no
> agreed-on term.

Thanks very much for all the references!

> The term _holon_ captures good design better than the others. It describes a
> relatively independent "organic" or "granular" unit of code, whose form and
> purpose is easily graspable by the reader, and whose boundaries easily allow for
> sectioning down and chunking up, validation, testing, refactoring, etc. And
> that's what a good literate programmer aims for.

Totally agree. Maybe we all should use ``holon'' from now on.

>> More often than not, users don't have NOWEB installed, so they wouldn't
>> be able to do anything with your program but read it.
>
> I need to add an appendix, that shows how a person could easily get Noweb
> running and actually execute the tutorial code.

That's a nice idea. NOWEB is such a stable software, your tutorial
would likely last a good deal of time.

1

rocksolid light 0.9.8
clearnet tor