by Brian W. Kernighan, Dennis M. Ritchie
ISBN: 0131103628
Buy on Amazon
Found in 36 comments on Hacker News
jhatemyjob · 2025-12-06 · Original thread
People use C not because they like it, but because its the lingua franca [1]. As long as The Unix Programming Environment [2] remains dominant, The C Programming Language [3] will too.

1. https://humprog.org/~stephen/research/papers/kell17some-prep...

2. https://amazon.com/dp/013937681X

3. https://amazon.com/dp/0131103628

Lyngbakr · 2025-03-13 · Original thread
There's a second edition of the legendary K&R book¹ to get you started.

¹https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

_osorin_ · 2022-10-08 · Original thread
I would like to take it a step further and ask a question that has been bothering me a while. On my time in the academy I studied the following two books (regarding C):

[1] Advanced Programming in the UNIX Environment https://www.amazon.com/Advanced-Programming-UNIX-Environment...

[2] C Programming Language https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

In combination with other classes (and books) on networking, operation systems, data structures we covered a big variance of use cases with C. My question is: How do I take this to the next level? For example I feel I never missed a concept from those classes but when I see C code posted on a thread here it's probably something completely unreadable and complex. Can anyone provide resources to advance a little? What should I study if my goal is to make good and useful modern C software?

I feel like my typing is a bit abstract but I will be happy to clarify.

PS Yes, I've heard of C++ and Rust ;P

belter · 2022-10-08 · Original thread
For the professional programmer, knowing other languages and getting into C, besides the two great recommendations above, would recommend:

"C Programming: A Modern Approach, 2nd Edition" - https://www.amazon.com/C-Programming-Modern-Approach-2nd/dp/...

Note the above book is good for its quality as a reference, but not enterily considered as "modern". For a more updated approach I would also recommend:

"Modern C" - https://www.manning.com/books/modern-c

and

"Effective C" - https://nostarch.com/Effective_C

The first book on the language:

"C Programming Language, 2nd Edition" - https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

Is interesting from a historical perspective, but considered as not a recommended resource for learning C.

Edit: If you are learning C there is something quite important you need to know... C and C++ are two completely different languages, and that is how you should approach your learning. In other words, don't go learning the C in C++ :-)

redis_mlc · 2021-04-23 · Original thread
Just learn C by reading and working through the K&R book. (It's one of the best CS books ever written.)

https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

Also, there's nothing magical about pointers - scripting languages use "handles", which is the same thing except they're read-only to the end-user programmer.

The real challenge with C is multi-threaded programming, so don't do that if you don't need it.

gjkood · 2020-03-08 · Original thread
To start with, "The C Programming Langauge", Kernighan & Richie (K & R) [1]. Find the latest edition that you can buy.

I think the primary topic to master in C is pointers. This is where most falter. It takes a few years to "master" (if we ever do). Here I would recommend "Understanding and Using C Pointers", Richard Reese. [2]

If you are interested in networking, any of the classic "TCP/IP Illustrated Vols I/II/III", W. Richard Stevens, [3] contain a ton of C code to implement components of TCP/IP.

If you are interested in Graphics, then "Graphics Gems", Andrew Glassner [4] is a good source.

"An Introduction to GCC", Brian Gough, [5] to understand the tooling and its various bells and whistles.

My learning swimming by jumping into the deep end of the pool experience was realized by learning Windows Programming using the Charles Petzold book and navigating through Microsoft Foundation Classes in the late 80s/early 90s. The state of the art in tooling wasn't that great in those days and I spent months with the book to get things going. This was done after I had built a foundation with K&R and a decent amount of Unix network programming.

I see a lot of the other posts recommend more modern books. But you still need to build your foundation on C and Pointers in particular.

Good luck on your journey.

[1] https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

[2] https://www.amazon.com/Understanding-Using-Pointers-Techniqu...

[3] https://www.amazon.com/TCP-Illustrated-Protocols-Addison-Wes...

[4] https://www.amazon.com/Graphics-Gems-Andrew-S-Glassner/dp/01...

[5] https://www.amazon.com/Introduction-GCC-GNU-Compilers/dp/095...

pritovido · 2020-03-08 · Original thread
C is a very simple language. I have used just the official old book to create a compiler for it:

https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

The best thing you can do is finding some open source code that interest you, read it and write it.

For example, I write my own controllers for CNCs, and there are lots of code for controlling stepper motors out there. I also learned OpenGL and sockets this way long time ago.

On the other hand, C is a terrible language for any big project unless you automate it some way.

I use mostly lisp in order to write C code automatically. C is too low level for writing any substantial code. Lisp has things like Macros(nothing to do with c macros) that can make you write code 10x, to 50x faster easily.

whydoyoucare · 2019-12-03 · Original thread
As far as I know, prices of books differ between rich and developing nations. For e.g., The C Programming Language that costs $50 in the US [1], is sold for Rs. 259 (~$4 US) in India. I believe that is the case with most "economy editions" specifically targeted at developing nations. It certainly isn't an "year's wages".

While I do understand your point, it still does not justify encouraging modern-day Robinhoods' and breaking the law.

[1] https://www.amazon.com/Programming-Language-2nd-Brian-Kernig... [2] https://www.amazon.in/Programming-Language-Kernighan-Dennis-...

whydoyoucare · 2019-09-18 · Original thread
The C language can be best learned from "The C Programming Language, 2nd Ed" [1], also known as "K&R book". Pair it with excellent notes by Steve Summit [2], and you don't need any other book to master C.

[1] https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

[2] https://www.eskimo.com/~scs/cclass/notes/top.html

kevindong · 2018-11-09 · Original thread
AbeBooks is a great place to buy the non-US versions of textbooks (which are almost always identical to the US version, but in grayscale rather than in color).

For instance, on Amazon, the K&R C Programming book goes for $28.52 used, $61.74 new, or $28.70 for a one semester rental [0]. For a book that hasn't changed since 1988, these prices are absurd.

While as on AbeBooks, the international edition goes for $10-11 [1].

[0]: https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...

[1]: https://www.abebooks.com/servlet/SearchResults?bi=0&bx=off&c...

lossolo · 2017-05-07 · Original thread
I don't share your opinion and most people I know that do C do not share it also. It's good base to get familiar with language, no one say you can't expand your knowledge further after reading this book.

I've read some other "modern" books about C like "21st century C" but they are not for people that do not know C and they are not so good for people that know it.

Can you provide any arguments to support what you wrote? What alternative you would propose for learning C?

https://www.amazon.com/Programming-Language-Brian-W-Kernigha...

Read what majority of opinions say. It's really easy to criticize without giving better alternative.

jasonlhy · 2017-04-20 · Original thread
C is a very "strict" language. It do the right thing only if you write the right code. It has many undefined behaviors. One of the undefined behaviors I found when I studied the compiler course. The purposed grammar from https://www.amazon.com/Programming-Language-Brian-W-Kernigha... allows this kind of structure, there can be statements after the switch but before the case labels. gcc also accepts this, but those statements will not be executed. Note: code modified from https://www.tutorialspoint.com/cprogramming/switch_statement...

#include "stdio.h"

int main () {

   /* local variable definition */    char grade = 'B';    int a = 1;     switch(grade) {       printf("great!\n" );       a = a + 1;              case 'A' :          printf("Excellent!\n" );          break;       case 'B' :       case 'C' :          printf("Well done\n" );          printf("a: %d\n", a);          break;       case 'D' :          printf("You passed\n" );          break;       case 'F' :          printf("Better try again\n" );          break;       default :          printf("Invalid grade\n" );    }        printf("Your grade is  %c\n", grade );      return 0; }

pdog · 2016-12-22 · Original thread
Why did people think otherwise? Chapter 5 of K&R[1] is titled Pointers and Arrays and basically explains that arrays and pointers are equivalent.

[1]: https://www.amazon.com/Programming-Language-Brian-W-Kernigha...

bra-ket · 2016-10-08 · Original thread
I learned programming without a computer in the 90s with Kernigan & Ritchie "C Programming Language", one of the best coding books ever written:

https://www.amazon.com/Programming-Language-Brian-W-Kernigha...

I'd also learn SICP: https://www.amazon.com/Structure-Interpretation-Computer-Pro...

and algorithms from either CLRS https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press... or Skiena Algorithm Design https://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena...

What's the rush?

http://norvig.com/21-days.html

Learning C is difficult because you need to know how the machine actually works. Trust me, there are no shortcuts. The year can be 2036, learning C will be the same.

With that said, these books are excellent:

http://www.amazon.com/Programming-Language-Brian-W-Kernighan...

http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp...

http://www.amazon.com/Primer-Plus-6th-Developers-Library/dp/...

percept · 2016-03-04 · Original thread
I looked forward to a complete chapter on IO (not unlike http://www.amazon.com/Programming-Language-Brian-W-Kernighan...), but didn't see one.

Perhaps a future edition...

echeese · 2015-06-23 · Original thread
You can get a copy here: http://www.amazon.com/dp/0131103628
trequartista · 2015-06-22 · Original thread
Some love for - The C Programming Language - Kerninghan & Ritchie -

http://www.amazon.com/The-Programming-Language-Brian-Kernigh...

sgt · 2015-03-05 · Original thread
For those of you who are not familiar with "The C Programming Language" (also written by Kernighan), see: http://www.amazon.com/C-Programming-Language-2nd/dp/01311036...
kgabis · 2014-06-24 · Original thread
It was released years ago: http://www.amazon.com/dp/0131103628
leoc · 2014-05-09 · Original thread
Reposting an earlier comment of mine https://news.ycombinator.com/item?id=6530180 with context https://news.ycombinator.com/item?id=6526412 :

> pjmlp 211 days ago | link | parent | flag

> Nice article, but it fails to explain the experience using Smalltalk environment really is. Smalltalk, like Lisp Machines, was originally a blend of GUI operating system, development environment and the first real IDE.

> agumonkey 211 days ago | link

> It's funny. Unix was also meant as an IDE (persistency, logic, machine and user interfaces). It seems they all were trying to reach the same goal in their own way. -----

> 2 points by leoc 210 days ago | link

> The fact that dc was originally intended as basically the Unix system's bignums library http://www.catb.org/esr/writings/taoup/html/ch08s02.html#id2.... helped to open my eyes to this. I think you could talk about this idea of Unix as "big Unix" and the narrower understanding of Unix programming, dominated by the C APIs, as "little Unix". Little Unix took over the world, while big Unix collapsed under its own weight due to things like portability/versioning hell, robustness problems due to faulty tools and text-parsing errors, performance issues and so on. (Partly this was a success catastrophe, of course, for example in how the popularity of Unix resulted in a profusion of different Unix userlands with varying interfaces and bugs.) Also little Unix was more comprehensible from, and more portable to and from, the world of PC (MS-DOS/Windows/Mac) application development, where the environment is more or less the kernel's/OS vendor's APIs. The fact that clearly many more people have bought or read K&R http://www.amazon.com/dp/0131103628/ (with its very little-Unix perspective) than /The Unix Programming Environment/ http://www.amazon.com/dp/013937681X reflects this divergence, and also surely helped to create it.

angersock · 2013-11-15 · Original thread
Some helpful starting points:

Learn about the Unix Way: http://c2.com/cgi/wiki?UnixWay

Learn about crufty neckbeard stuff: http://doc.cat-v.org/programming/

(cat-v has all kinds of interesting things)

Learn C: http://c.learncodethehardway.org/book/

No, really, learn C: http://www.amazon.com/C-Programming-Language-2nd-Edition/dp/...

Learn about networking with sockets: http://www.beej.us/guide/bgnet/

(it's in C, but the principles are in other language bindings as well)

Devops/sysadminning is mostly just damned superstition and voodoo and hard-fought experience...that said, consult notes from others: http://users.cis.fiu.edu/~tho01/psg/

~

If you want more hands-on experience, setup a VPS and make something: http://feross.org/how-to-setup-your-linode/

If you find stuff in there you don't understand, ask your devs for help.

leoc · 2013-10-10 · Original thread
The fact that dc was originally intended as basically the Unix system's bignums library http://www.catb.org/esr/writings/taoup/html/ch08s02.html#id2... helped to open my eyes to this. I think you could talk about this idea of Unix as "big Unix" and the narrower understanding of Unix programming, dominated by the C APIs, as "little Unix".

Little Unix took over the world, while big Unix collapsed under its own weight due to things like portability/versioning hell, robustness problems due to faulty tools and text-parsing errors, performance issues and so on. (Partly this was a success catastrophe, of course, for example in how the popularity of Unix resulted in a profusion of different Unix userlands with varying interfaces and bugs.) Also little Unix was more comprehensible from, and more portable to and from, the world of PC (MS-DOS/Windows/Mac) application development, where the environment is more or less the kernel's/OS vendor's APIs. The fact that clearly many more people have bought or read K&R http://www.amazon.com/dp/0131103628/ (with its very little-Unix perspective) than /The Unix Programming Environment/ http://www.amazon.com/dp/013937681X reflects this divergence, and also surely helped to create it.

chadnickbok · 2013-06-02 · Original thread
As many people have said, no, you're not too old to get started. And despite what some people might say, a multi-year degree program, with a decent GPA, is a great way of showing employers that you're a decent potential candidate.

That said, software engineering is one of the fields you can get employment without a degree, provided you can 'show your work'. The hard part is building up your skills in a way that can easily be demonstrated. The common wisdom these days is to create a github profile, build some interesting things, commit to some open-source libraries, and use your profile as a resume of sorts.

Here's interesting article on being a well-rounded programmer: http://jasonrudolph.com/blog/2011/08/09/programming-achievem...

We're also in a 'golden age' of self-guided learning, with online tools to help learning galore, here are a few:

http://codecademy.com http://www.codeschool.com/ https://www.khanacademy.org/cs

Also, get a few decent books on "Programming 101". Common wisdom suggests you learn C, one of Ruby/Python, Java, and a functional language like Haskell. Here are some good books to learn from:

The C Programming Language (some people say you should start here, I'm one of them!): http://www.amazon.com/Programming-Language-2nd-Brian-Kernigh...

Learning Python: http://www.amazon.com/Learning-Python-Powerful-Object-Orient...

Learning Java: http://www.amazon.com/Learning-Java-Patrick-Niemeyer/dp/0596...

I hope you do choose programming as a career, its been very rewarding for me :)

robomartin · 2012-11-27 · Original thread
OK, if you don't have any real experience in low-level embedded coding (relevant to device drivers), RTOS or OS design in general, file systems, data structures, algorithms, interfaces, etc. And, if you have "hobby level" experience with Assembler, C and C++. And, if your intent is to write a desktop OS, from the ground up, without making use of existing technologies, drivers, file systems, memory management, POSIX, etc. Here's a list of books that could be considered required reading before you can really start to write specifications and code. Pick twenty of these and that might be a good start.

In no particular order:

1- http://www.amazon.com/C-Programming-Language-2nd-Edition/dp/...

2- http://www.amazon.com/The-Answer-Book-Solutions-Programming/...

3- http://www.amazon.com/The-Standard-Library-P-J-Plauger/dp/01...

4- http://www.amazon.com/C-Traps-Pitfalls-Andrew-Koenig/dp/0201...

5- http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp...

6- http://www.amazon.com/Data-Structures-In-Noel-Kalicharan/dp/...

7- http://www.amazon.com/Data-Structures-Using-Aaron-Tenenbaum/...

8- http://www.amazon.com/Mastering-Algorithms-C-Kyle-Loudon/dp/...

9- http://www.amazon.com/Code-Complete-Practical-Handbook-Const...

10- http://www.amazon.com/Design-Patterns-Elements-Reusable-Obje...

11- http://www.amazon.com/The-Mythical-Man-Month-Engineering-Ann...

12- http://www.amazon.com/The-Programming-Language-4th-Edition/d...

13- http://www.amazon.com/The-Standard-Library-Tutorial-Referenc...

14- http://www.amazon.com/API-Design-C-Martin-Reddy/dp/012385003...

15- http://www.amazon.com/The-Linux-Programming-Interface-Handbo...

16- http://www.amazon.com/Computer-Systems-Programmers-Perspecti...

17- http://www.amazon.com/System-Programming-Unix-Adam-Hoover/dp...

18- http://www.amazon.com/Memory-Programming-Concept-Frantisek-F...

19- http://www.amazon.com/Memory-Management-Implementations-Prog...

20- http://www.amazon.com/UNIX-Filesystems-Evolution-Design-Impl...

21- http://www.amazon.com/PCI-System-Architecture-4th-Edition/dp...

22- http://www.amazon.com/Universal-Serial-System-Architecture-E...

23- http://www.amazon.com/Introduction-PCI-Express-Hardware-Deve...

24- http://www.amazon.com/Serial-Storage-Architecture-Applicatio...

25- http://www.amazon.com/SATA-Storage-Technology-Serial-ATA/dp/...

26- http://www.amazon.com/Beyond-BIOS-Developing-Extensible-Inte...

27- http://www.amazon.com/Professional-Assembly-Language-Program...

28- http://www.amazon.com/Linux-Kernel-Development-3rd-Edition/d...

29- http://www.amazon.com/Version-Control-Git-collaborative-deve...

30- http://www.amazon.com/Embedded-Software-Primer-David-Simon/d...

31- http://www.amazon.com/Programming-Embedded-Systems-C/dp/1565...

32- http://www.amazon.com/Making-Embedded-Systems-Patterns-Softw...

33- http://www.amazon.com/Operating-System-Concepts-Abraham-Silb...

34- http://www.amazon.com/Performance-Preemptive-Multitasking-Mi...

35- http://www.amazon.com/Design-Operating-System-Prentice-Hall-...

36- http://www.amazon.com/Unix-Network-Programming-Sockets-Netwo...

37- http://www.amazon.com/TCP-Illustrated-Volume-Addison-Wesley-...

38- http://www.amazon.com/TCP-IP-Illustrated-Vol-Implementation/...

39- http://www.amazon.com/TCP-Illustrated-Vol-Transactions-Proto...

40- http://www.amazon.com/User-Interface-Design-Programmers-Spol...

41- http://www.amazon.com/Designing-Interfaces-Jenifer-Tidwell/d...

42- http://www.amazon.com/Designing-Interfaces-Jenifer-Tidwell/d...

43- http://www.amazon.com/Programming-POSIX-Threads-David-Butenh...

44- http://www.intel.com/p/en_US/embedded/hwsw/software/hd-gma#d...

45- http://www.intel.com/content/www/us/en/processors/architectu...

46- http://www.intel.com/p/en_US/embedded/hwsw/hardware/core-b75...

47- http://www.hdmi.org/index.aspx

48- http://en.wikipedia.org/wiki/Digital_Visual_Interface

49- http://www.amazon.com/Essential-Device-Drivers-Sreekrishnan-...

50- http://www.amazon.com/Making-Embedded-Systems-Patterns-Softw...

51- http://www.amazon.com/Python-Programming-Introduction-Comput...

52- http://www.amazon.com/Practical-System-Design-Dominic-Giampa...

53- http://www.amazon.com/File-Systems-Structures-Thomas-Harbron...

54- ...well, I'll stop here.

Of course, the equivalent knowledge can be obtained by trial-and-error, which would take longer and might result in costly errors and imperfect design. The greater danger here is that a sole developer, without the feedback and interaction of even a small group of capable and experienced programmers could simply burn a lot of time repeating the mistakes made by those who have already trenched that territory.

If the goal is to write a small RTOS on a small but nicely-featured microcontroller, then the C books and the uC/OS book might be a good shove in the right direction. Things start getting complicated if you need to write such things as a full USB stack, PCIe subsystem, graphics drivers, etc.

kaolinite · 2012-03-08 · Original thread
As you're interested in electronics you may be interested in Arduino, which you can program in C (and perhaps some other languages too). If you do decide to pick C, I'd really recommend picking up a copy of K&R's "The C Programming Language": http://www.amazon.com/C-Programming-Language-2nd-Edition/dp/...

You're also interested in games, so you could consider Python and the PyGame library: http://www.pygame.org/ Or if you want to go with C, try the allegro library: http://alleg.sourceforge.net/index.html (Learning this library was what taught me C, after picking up the basics of C I picked up the rest as I went along).

End of the day though, just pick something and learn it. It's better to be learning than worrying about what to learn.

andymoe · 2011-11-07 · Original thread
Joel likes the sink or swim approach apparently.

The first book, Code - Charles Petzold, is only ten bucks on the Kindle right now (SOLD) and I own the other two.

I remember SICP being like 90 bucks for my hardcover copy and I'm pretty sure I bought it after reading the Joel on Software article "The Perils of Java Schools" while I was loving life as a bank IT guy so this is workable advice. It only took five years to become a "real" programmer after that. Also I sure don't remember K&R being $68[1]. (Yes I know SICP and K&R are both online for free)

[1] http://www.amazon.com/Programming-Language-2nd-Brian-Kernigh...

[2] http://www.joelonsoftware.com/articles/ThePerilsofJavaSchool...

wyclif · 2011-10-30 · Original thread
I would be far more impressed and gratified if Prentice Hall were cool enough to offer Kernighan & Ritchie's classic "C Programming Language" (2nd Edition) at 1/2 off their $57.99 sticker-shock price.

http://www.amazon.com/Programming-Language-2nd-Brian-Kernigh...

nswanberg · 2010-12-17 · Original thread
Here's the slightly modified answer I just posted there (even though it's an old question):

Back when he was still doing podcasts Joel Spolsky answered the similar question, which was partly "Does a good programmer without a CS degree really have a chance to get a job at Fogcreek?[1]" (It's near the end of the page.)

He says that for a good self-taught programmer who began with a high-level language, say PHP or Java, who comes at programming from a practical perspective, there are a few important parts of the CS curriculum the person may have missed out on, and goes on to list some books that would help fill in those gaps.

Off the top of his head he named these books in about this order:

- Structure and Interpretation of Computer Programs[2] (also free online[3])

- C Programming Language[4]

- The Unix Programming Environment[5]

- Introduction to Algorithms[6]

He said that those books covered the aspects of the CS curriculum his company needs in a good programmer, e.g. being able to create algorithms for an uncommon data structure.

Those books all have the added advantage of having exercises, and all being a very pleasant read. SICP is an introduction to many of the big ideas in CS: data structures, streams, recursion, interpretation, compilation, register machines, etc., and their implementation in Scheme (a kind of Lisp). It's a great place to start. The next two focus on implementation details like pointers and memory allocation. They are compact, powerful books. The last, Introduction to Algorithms, seems misleadingly titled, as it is fairly comprehensive and used in both undergraduate and graduate courses. If you work your way through the entire book, chapeau!

[1]: https://stackoverflow.fogbugz.com/default.asp?W29060

[2]: http://www.amazon.com/Structure-Interpretation-Computer-Prog...

[3]: http://mitpress.mit.edu/sicp/

[4]: http://www.amazon.com/Programming-Language-2nd-Brian-Kernigh...

[5]: http://www.amazon.com/Unix-Programming-Environment-Prentice-...

[6]: http://www.amazon.com/Introduction-Algorithms-Third-Thomas-C...