Emma (hearthand) wrote in algorithms,
  • Mood:

C

Can anyone recommend a good beginners book on C?

In a few weeks time I will be using C for low level programming to solve problems. (Low level programming being the class.) C will be my second language, I already understand the basics of java objects and ADT's so preferably a book that defines clearly why C isn't object oriented... 

Edit: I ended up buying "C in a Nutshell" because it is the course textbook and came highly recommended. It doesn't provide enough baby-step explanations for me, though, so I'm still finding C a damned difficult language to learn. Thank you all for your suggestions, I'm planning on buying the recommended book anyway in the hope that the developers of C will be better at explaining things.
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 12 comments

roadriverrail

February 1 2008, 17:07:03 UTC 6 years ago

Well, it takes only a sentence to define clearly why C isn't object oriented. C isn't object oriented because C doesn't conform to the principles of object orientation.

Back when I taught operating systems, the students entered the class without having been taught C (thanks, University of Florida!), and we used this text to teach them C. It's basically the definitive classic.

lord_jim

February 1 2008, 17:16:41 UTC 6 years ago Edited:  February 1 2008, 17:17:24 UTC

I will second roadriverrail's suggestion. That book is the C Programming Bible. I taught myself C (pauses to count on fingers and toes) something like 17 years ago with that book. It was excellent then and there's still nothing better. It was written by Kernighan and Ritchie. Who better to develop a book about C than the 2 guys who initially developed the language in the first place.

lightning_rose

February 1 2008, 17:40:16 UTC 6 years ago


That's an easy answer. C has been around far longer than OOP.

C++ was a somewhat kludgey response to the OOP movement by adding objects to C.

But even if OOP had been around forever, C, or something similar, would have been invented for real-time and/or systems programming.

Any C coder should have a copy of Kernighan and Ritchie's "The C Programming Language" on their bookshelf, but as tutorial it's rather lacking.

Here's some online resources that may be useful.

http://www-users.york.ac.uk/~adh2/c_prog.htm
http://www.freetechbooks.com/forum-3.html

Also, there is a C programming community with plenty of knowledgeable people who can help.
http://community.livejournal.com/cprogramming/

root_fu

February 1 2008, 17:40:37 UTC 6 years ago

freetechbooks.com

preferably a book that defines clearly why C isn't object oriented...

I'll go out on a limb here and surmise C isn't object oriented because it was created during a time when procedural programming was all the rage.

: T

hearthand

March 27 2008, 13:09:31 UTC 6 years ago

Thank you :)

humanplacebo

February 1 2008, 17:43:16 UTC 6 years ago

Computers are not object oriented. A computer program is simply a list of instructions and arguments. There's no such thing as an object to a computer, just instructions and various kinds of memory.

Any language capable of low-level programming will not be object-oriented, because the programmer must be able to understand how their code will translate into a machine language.

A good C programmer knows pretty much how their code will be translated into assembly and knows how to modify their C code to produce assembly language that will run faster.

Any time you have more abstraction, such as in higher-level languages, you're relying on the compiler to guess what you want the assembly language to be. In general they're pretty good at it, but if you need something to be particularly fast (like a driver or math routine on a PC) or small (to run on a cell phone or other embedded device) then a compiler for a high-level language frequently won't be good enough.

It's not possible to have an object-oriented language with the same power as C. The point of abstraction is to hide the computer from you to make it easier, but sometimes you need to see the computer.

Those are some reasons why C is the way it is. I agree with the previous posters on the K&R book being the indispensable reference, even if you buy another C book for learning purposes.

hearthand

February 1 2008, 19:09:24 UTC 6 years ago

Thank you very much for that explanation! From it, I can guess that the reason they teach us Java (using the book "Objects First with Java" by David J Barnes and Michael kolling) is because it's easier for us to program in java with Objects as opposed to worrying about the speed. Most of our current classes are now brushing on and introducing the idea of faster programs. Beforehand we concentrated on making them work.

approachmdnight

February 1 2008, 20:07:16 UTC 6 years ago

I think schools tend to teach Java in early classes so you can focus on problem-solving rather than getting frustrated hunting down memory bugs.

I don't really agree with that approach, but more and more schools are using it. Some even teach systems programming in Java now!

Though you probably won't work with them on a day-to-day basis during your career, taking the time to learn C and assembly will help you understand things better. I also think it's interesting to know how things work at different levels.

In addition to the K&R book, you can find tons of real-world Open Source C projects on the web. Try to find something that interests you, like a toy HTTP server, and add features or try to improve it somehow. If you're looking for examples of how you would build things like Java's built-in ADTs in C, the book C Interfaces and Implementations is worth picking up.

humanplacebo

February 1 2008, 23:19:43 UTC 6 years ago

Glad you liked it. I'm fairly ambivalent on what language we should teach people, since as long as you cover how to program adequately, they can pick up any language later in life.

Coming from Java, there's only a few key concepts that will be unfamiliar, like pointers and dealing with strings as character arrays instead of objects. Another good topic will be dealing with I/O as reading and writing bytes.

Good luck and have fun!

hawklady

February 2 2008, 02:12:02 UTC 6 years ago

Here's another YES!!!! to the recommendation for what most of us call simply "K&R C".

I don't know if it's available now, but when I taught C we used a book that came with a very basic compiler on disk -- named something like "MIX C". The compiler that came with it was severely lacking in several ways, but for $20 for both book & disk, it was a bargain. The book was, IMO, *excellent* as an introduction to C.

Also, the "Dietel & Dietel" series of Learning books are usually quite good, although ideally you'd have someone to run to when you hit an error that doesn't seem to match up with anything the book helps out with.


nandish_wild

March 4 2008, 13:14:49 UTC 6 years ago

Book tited "Let us C" by Yeshwanth Kanitkar would be an awesome book for a beginner.I have read this book and strongly recommend to anyone who wants to learn C from basics to advanced topics

subfusc

March 12 2008, 16:48:10 UTC 6 years ago

Thirded on the Kernighan and Ritchie book, that was always the classic C programming book when I was learning.