Thread: The C Programming language (K&R) Book

  1. #1
    Registered User
    Join Date
    Sep 2014
    Posts
    1

    Question The C Programming language (K&R) Book

    I have been checking out The C Programming Language by K&R (The book mostly everyone learned C from) and I was wondering why is it so popular among many programmers? A lot of beginners learned from the book but I find the book a little hard to follow. Why is K&R's book style so popular and loved by many programmers? Is it something really special or what? I noticed another book (Programming In Lua) is also said to be "K&R" style and again, it's popular and 5 stars by many on amazon. Can someone explain to me why "K&R" book style is so popular? It seems hard to follow to me.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    The book mostly everyone learned C from
    I doubt that most everyone learned C from this book. This book IMO is not a book for beginners, but it is a great reference.

    I was wondering why is it so popular among many programmers?
    Probably because it was written by the original developers of the C language, and this book in it's original version was considered the "standard" before the standards even existed. Almost every early compiler would compile the code presented in this book because they used this book as the basis of their compilers.

    Jim

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I doubt "mostly everyone learned C" from K&R. That book is considered important in C programming circles because Dennis Ritchie, one of the authors, designed the C language, and the first edition of that book was the basic standard for the language. It's considered a classic piece of work.

    While some of the "standard" information from that book has since been superseded by official standards, that book still contains good information and exercises.

    I personally don't feel it's a good book to learn C from scratch, since the information is very dense (and, as I mentioned, a lot of it is dated). More modern books, in addition to up-to-date practices, offer a more gradual learning approach.

  4. #4
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    I learned C from the book, but the experience was a bit like beating my head against a wall. I can't recall ever needing a month to get through a book so small before. Still, it has some great stuff in it that I've been back to several times, like the binary tree part. I don't know if it's necessarily better than any other book or tutorial, but it's good for what it is.

    There is maybe one advantage to learning C from K&R, and that is that a lot of stuff after comes a lot easier, thankfully.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Also notice "K&R style" can sometimes refer to indentation style. Also "K&R C" is a particular older version of C that most notably lacks function prototypes.

    For the question of the style of this book I like the following
    1. The book is short enough and reads in a more interesting way than many large textbooks.
    2. All concepts are explained with code snippets which are simple but not too simple.
    3. Examples of the book show how you can implement your own standard library functions from more basic operations. It makes you say to yourself "oh, so that's how that works."
    4. By the time you finish the book you can already use those skills to write your own C compiler.

    In reality you shouldn't learn something like programming or even a single programming language from a single source. Use as many sources that are useful to you and that motivate you to learn more.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Before programming books (in fact, computer books in general) became mainstream, people learned from these dense, verbose and highly rich manuals. Like point 4 in c99tutorial's post #5 illustrates, these books and manuals used to present readers with all that was needed to begin and, in some way, master the material. Because there was no other readily available books around, programmers wouldn't mind dedicating large amounts of time reading and understanding the concepts being told. Most of the praise for these books comes from that time (70s through the 90s) and the status they gained that is then spilled over onto the new generations who, while not having dedicated their time to them as others have, tend to follow on the footsteps of that approval.

    In fact most computer related books and manuals used to be dense and highly rich, not just programming. I remember MSDOS shipping with a 500(?) page manual that covered everything down to batch programming, or computer games shipping with 300 page paper manuals. And not just computer related books. Back in the 90s, my friends and I took about 1 full month to learn how to to play Avalon Hill's Advanced Squad Leader 1st Edition board game through its highly complex and dense 300 page manual. It's just how things where and people were used to read large manuals.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Quote Originally Posted by Mario F. View Post
    In fact most computer related books and manuals used to be dense and highly rich, not just programming. I remember MSDOS shipping with a 500(?) page manual that covered everything down to batch programming, or computer games shipping with 300 page paper manuals. And not just computer related books. Back in the 90s, my friends and I took about 1 full month to learn how to to play Avalon Hill's Advanced Squad Leader 1st Edition board game through its highly complex and dense 300 page manual. It's just how things where and people were used to read large manuals.
    This reminds me a bit of the old Ultima games, where every keyboard button was a control. It came with a fairly big manual, but your knowledge wasn't complete until you bought a guide. Does anyone remember when guides were a thing? Like textbooks that would tell you all the secrets of a game. All that information is on the internet now .

  8. #8
    Registered User jdragyn's Avatar
    Join Date
    Sep 2009
    Posts
    96
    Guides were never a thing for me. I don't understand the desire to pay money for a puzzle and then pay someone else to bypass the puzzle. What was the point in buying the puzzle? I loved Ultima 3, 4 and 5, solved with perseverance and dedication and I could quote most of the NPC text because I became immersed in the game! Now my son is playing Final Fantasy XCVIIIVICXCVSV (or whatever it's up to) and he, along with my father-in-law, look up strategies and guides online. I don't understand what enjoyment he gets from that; he's not solving the puzzles, he's just pushing the sticks on the controller to make the "movie" advance. I must be old.
    C+/- programmer extraordinaire

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by jdragyn View Post
    I must be old.
    It's not an age thing. It's just how you tick. I used to enjoy exploring a game. Not anymore. I don't have the patience. I played Fallout 3 and New Vegas, complete with all DLC, with strategy guides, following to the letter all the best options to solve all the quests and sidequests, get the best gear and the best gameplay options. I enjoyed myself greatly regardless. I too am getting old.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    It's not an age thing. It's just how you tick. I used to enjoy exploring a game. Not anymore. I don't have the patience.
    O_o

    One must also consider the sentiment in the context of a given game.

    I probably have 110 hours on my "Final Fantasy X" save. (I grabbed the HD release a few weeks back.) I never used a guide, and I love almost every minute.

    I tried playing "Final Fantasy X-II" the same, but I didn't enjoy the play nearly enough to run around for 100 hours to find everything myself.

    *shrug*

    I didn't enjoy playing the game enough to spend the extra time, but I did like watching the movie. I'd already paid, so why not?

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  11. #11
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    The Touhou series is a bunch of games that I want to play, but at the same time it's such a giant challenge for me I feel like it would take away time from other things I want to do. To get good, I'm told that players practice "all the time." Fortunately, in bullet hell games you either succeed or fail, so there is no manual to spoil the fun.

  12. #12
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by phantomotap View Post
    One must also consider the sentiment in the context of a given game.
    This is true. I still prefer to waste days trying to solve SpaceChem challenges the most efficient way, despite having no patience for RPG and adventure games anymore.
    Last edited by Mario F.; 09-10-2014 at 04:56 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  13. #13
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    I've probably played 500 hours or so of Morrowind, across the years. It used to be the first thing I would do on getting a new computer, was to install it and see if the performance had improved. Even in today's standards, it's a huge game. The storylines and graphics have aged a lot however. God that was a great time for gaming, Baldur's Gate 1 & 2, Planescape Torment, and Morrowind came only a few years apart 0.0 .

  14. #14
    Registered User fahadali's Avatar
    Join Date
    Sep 2014
    Location
    Lahore
    Posts
    1
    good c plus plus programming book ..???

  15. #15
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    At the top of the C++ board page, there is a link called "C++ Book Recommendations". See if you can find it.

    In the future, don't hijack another thread to post a question.
    And do some research before asking a question. This question has been asked countless times.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 11-19-2011, 07:57 PM
  2. Question on the book "C Programming Language" by K&R
    By noahian in forum C Programming
    Replies: 3
    Last Post: 09-04-2011, 02:56 PM
  3. binsearch function c programming language book
    By blob84 in forum C Programming
    Replies: 4
    Last Post: 05-17-2011, 04:36 AM
  4. a mistake in the c programming language book.wtf?
    By KidMan in forum C Programming
    Replies: 9
    Last Post: 01-17-2006, 04:33 AM
  5. The C++ Programming Language(book) exercise troubles
    By Daniel Primed in forum C++ Programming
    Replies: 11
    Last Post: 11-07-2005, 01:56 AM

Tags for this Thread