:: Re: [DNG] Learning C
Inizio della pagina
Delete this message
Reply to this message
Autore: Peter Duffy
Data:  
To: dng
Oggetto: Re: [DNG] Learning C
Apropos books on C, here's my two-penny-worth:

I'd always have Kernigan and Ritchie: "The C Programming Language" -
admirably clear, concise and yet eminently readable. I'd also not be
without the companion volume: Kernighan and Pike: "The Unix Programming
Environment" - still one of the best introductions to Unix yet written,
and most of it is still valid for linux. (I get the impression that
Brian Kernighan became the main communicator and documentor of the Unix
project, although he is obviously a master programmer in his own right:
he is the "k" in awk, as he was one of the three people who wrote it -
the others were Alfred Aho and Peter Weinberger. Kernighan allegedly
also came up with the name "Unix".)

The fact is that, effectively, C was written in order for Unix to be
rewritten in it. So it had to be enormously flexible, and closer to the
assembly level than most high-level languages. That was a two-edged
sword: it made the language unbelievably powerful and expressive - but
also introduced a massive set of pitfalls for the unwary. It's
trivially possible to write a C program (deliberately or accidentally)
which will be happily swallowed by the compiler, but which when run
will crash with "segmentation fault" or "bus error", or even worse, eat
its way through all available RAM and cause the system to lock up. It's
as though one first learns to program in C, and then starts to learn
how to write a C program (bit like the strange experience where one
passes the driving test, and then starts to learn how to drive).

I've found three books which go into the pitfalls and gotchas in
considerable depth, and which I wouldn't be without:

Perry, John W. : C programming by example (PWS Publishing Company,
Boston, MA.)

van der Linden, Peter: Expert C Programming (Deep C secrets) (Prentice
Hall) (title of one section: "Bus error, take the train")

Kelley, Al & Pohl, Ira: C by dissection (Addison Wesley)

Not sure whether these are still in print: if not, second-user copies
will probably be available via amazon or abebooks. I can't really
recommend one over the others - I've learnt a lot from all three, and
they seem to complement each other to some extent. There are mentions
of C++ here and there, but mostly as afterthoughts.

On Tue, 2024-09-24 at 10:43 +0200, Didier Kryn wrote:
> Le 24/09/2024 à 04:05, o1bigtenor via Dng a écrit :
> >
> I consider the best way is to take lessons, and the second best way
> is
> to use a good book. A book about C only, not "C and C++".
>
> --     Didier
>
> _______________________________________________
> Dng mailing list
> Dng@???
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng