News for hackers. Stuff that matters.
Re:Notes on Programming in C (1989) by pmarin on Sunday May 11, 2014 @09:37AM (#7728675)
All Plan9 C programs are written in this way. Paradoxically the number of includes in your code is minimal compared with the usual POSIX aproach. All C programs begin with two includes: u.h and libc.h and usually libio.h and it is often all you need for the startdard library.

The man pages of the libraries describe the libraries you need to include.

Example:

Plan9 cat: http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/cat.c

GNU cat: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f...

Plan9 du: http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/du.c

GNU du: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f...

Re:Notes on Programming in C (1989) by Peaker on Sunday May 11, 2014 @12:00PM (#7728980)
So basically the #include granularity is extremely coarse, because otherwise it is unmanageable.

I think it is nicer to have quite specific #include's:

  #include <stdbool.h>
  #include <stdarg.h>
  #include "hash_table.h"
Because it:

* Gives a list of dependencies at a glance

* Along with preprocessor optimizations to avoid reparsing protected headers, it can actually parse fewer headers in each compilation (reversing the performance argument by Rob)

* Can aid with greps for where modules are used

The comparison is really a strawman -- and the length of the GNU one and its many dependencies relate more to feature creep than to the #include issue here.

At least with GNU's #includes, I can see that it depends on the various stuff it needs for its feature creep.

Re:Notes on Programming in C (1989) by ufo on Sunday May 11, 2014 @01:54PM (#7729316)
Why do all the P9 files use `void main` instead of `int main`?
Re:Notes on Programming in C (1989) by pmarin on Sunday May 11, 2014 @02:17PM (#7729381)
Yes. Instead of returning an integer you use the function exits [1] and the value appears in the shell variable status.

[1] http://plan9.bell-labs.com/magic/man2html/2/exits

This is an introduction to programming in Plan9 C:

http://doc.cat-v.org/plan_9/programming/c_programming_in_pla...