9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Brantley Coile <brantley@coraid.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] OT: programming style under Plan9??
Date: Fri,  1 Apr 2005 22:34:31 -0500	[thread overview]
Message-ID: <5ef017b602f99114e817ac37589aef3d@coraid.com> (raw)
In-Reply-To: <Pine.GSO.4.58.0504012026300.14759@cps211.cps.cmich.edu>

Speaking as a semi old fart, some of the early structure of
programs into separate files was just to keep the file
small enough to compile quickly.  Dennis' pdp11 compiler
was a number of files that all essentially got cat'ed together.
Back when a MIP was a real MIP and you had only one,
having the source in small files really sped up compilation.
You could get a lot more work done in a given amount of time.
The first thing I noticed when I first saw the Plan 9 code in 1990
was how header definitions were combined into the same file.
This turned out to be a great win.

Of course, a more constructive answer would be to get a copy
of ``The Practice of Programming'' by Kerninghan and Pike.

I would make the remark that C doesn't have modules.  After
compiling the code type information is lost and you can link
to anything that will resolve a name.  For example I can treat
the name qsort(3) as an array of integers.  The loader will resolve
the name qsort and the code in main will just do what I told it to.
This in in contrast to Wirth's Oberon that does type checking
at compile, link and runtimes.


#include <stdio.h>

extern int qsort[10];

void
main(void)
{
         int i;

         for (i = 0; i < 10; i++)
                 printf("%08x\n", qsort[i]);
         exit(0);
}
   Brantley


On Apr 1, 2005, at 8:34 PM, I RATTAN wrote:

> I have observed that that the Plan9 C-code generally
> consists fo ALL modules of a program are in the same file.
> Is it deliberate or a matter of style? It does make life
> easier in terms of include files but seems a bit little off
> key in context that C supports separate compilation of modules
> and hence, each module could be in a file of its own! I was accused
> of being University type in comp.lang.python for asking how
> keep each modules in a separate file  and make the program
> work correctly.
>
> Thanks in advance.
> -ishwar
>



  parent reply	other threads:[~2005-04-02  3:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-02  1:34 I RATTAN
2005-04-02  2:40 ` Ronald G. Minnich
2005-04-02  3:34 ` Brantley Coile [this message]
2005-04-02  4:06   ` Russ Cox
2005-04-04  9:56     ` Gorka Guardiola
2005-04-04 13:24       ` jmk
2005-04-04 14:20         ` Charles Forsyth
2005-04-02  9:31   ` Charles Forsyth
2005-04-02  9:56     ` noselasd
2005-04-02 19:31       ` jmk
2005-04-02 20:57         ` Devon H. O'Dell 
2005-04-02 22:08           ` jmk
2005-04-02 12:36     ` Brantley Coile
2005-04-02  3:54 ` Russ Cox
2005-04-02 13:11   ` I RATTAN
2005-04-02 15:50     ` Ronald G. Minnich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ef017b602f99114e817ac37589aef3d@coraid.com \
    --to=brantley@coraid.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).