Re: OT: Programming in C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2008-04-07 at 12:25 -0400, max bianco wrote:
> I want to learn C and I know there are quite a few programmers on this
> list.  I am looking for a couple of good books on learning C. I am not
> exactly a beginner but I am no expert and i would like to start going
> over everything from scratch.  So if I could get some referrals to a
> couple of books I would greatly appreciate it. I am looking for a good
> thorough beginners guide to C and also something for the intermediate
> programmer as I expect to get through the former in fairly short
> order. I ultimately will be directing my efforts at kernel hacking. As
> always , any advice and or opinion is gratefully received.
> 
> Max
> 
Hi, Max,
	There are several good books out there for C.  The base language
reference is 
The C Programming Language by Kernigan and Ritchie.  C is a very compact
language, and this book shows the real underlying structure.  However
most C programming is done by calling Library routines.  A book that a
lot of colleges use is Teach Yourself C or Teach Yourself C++.  

	The thing to remember is that C is a functional language, where you
have to design the data structures, and C++ is object oriented, so while
the underlying code operations are the same, the manner in which they
are accessed is different.  Most programs today are written in C++
because the object orientation removes some of the arduous tasks from
programming, that is managing data structures separately from code, and
keeping the code coherent with the data structure.  With objects the
data structure is the object, and the code is assigned to the object, so
for example if the object is car, then the function call for turning the
car might be car.turn(left) in object code.
In functional code there would be a structure for the car with various
attributes, one of which might be direction.  So to get the car to turn,
the operation might look like car.direction+=LEFT  Where direction would
be a property of the car structure, and LEFT would be some angle which
would be added to the current value of direction.  Note that in the
object portion, you would also have to define left and what the
direction might look like, and the function turn would adjust the
direction by the value of left.  They both do the same operation,
however the object version is less direct in coding, and more obtuse
because you may not be able to even see the function or the direction
value if they were controlled by the program as private data.  This is a
bit off what you asked, but is important that you get the correct
information.  C is one language and C++ is a different language because
of this structural difference.

	Along with the correct book, there are some books referred to as
primers.  One of my favorites is the C Primer +.  

	Reading code will help you to see what constitutes good practice vs bad
practice.  Essentially if you can follow the code, and it is well
commented and follows the comments well, that is good coding.  You will
see lots of other varieties from OK to horrible as you read pages.
Worst in my book are tutorials with a page of code with no comments
other than the text.  Even the most trivial algorithm should always have
a comment telling what its input is, what its output should be and
preferably illustrating how that result is obtained.  But many authors
don't bother, and we tend to follow what we learn, so there are reams
and reams of programs out there with few or no comments at all.  May you
never have to debug one of them.

Others here will suggest other books.  Check them all out on line or at
libraries to see what you think will help you.  Pick one and read it
through first before trying to code.  It is dry reading, but once you go
all the way through it, it will make more sense why the exercises lead
you to new understanding.

Regards,
Les H


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux