You Will Learn C! Zed Shaw has crafted the perfect course for the beginning C programmer eager to advance their skills in any language. Follow it and you will learn the many skills early and junior programmers need to succeed–just like the hundreds of thousands of programmers Zed has taught to date! You bring discipline, commitment, persistence, and experience with any programming language; the author supplies everything else. In Learn C the Hard Way , you’ll learn C by working through 52 brilliantly crafted exercises. Watch Zed Shaw’s teaching video and read the exercise. Type his code precisely. (No copying and pasting!) Fix your mistakes. Watch the programs run. As you do, you’ll learn what good, modern C programs look like; how to think more effectively about code; and how to find and fix mistakes far more efficiently. Most importantly, you’ll master rigorous defensive programming techniques, so you can use any language to create software that protects itself from malicious activity and defects. Through practical projects you’ll apply what you learn to build confidence in your new skills. Shaw teaches the key skills you need to start writing excellent C software, including It’ll Be Hard at First. But Soon, You’ll Just Get It–And That Will Feel Great! This tutorial will reward you for every minute you put into it. Soon, you’ll know one of the world’s most powerful programming languages. You’ll be a C programmer. Watch Zed, too! The accompanying DVD contains 5+ hours of passionate, powerful a complete C video course! If you purchase the digital edition, be sure to read "Where Are the Companion Content Files" at the end of the eBook to learn how to access the videos.
This is a very different approach to learning a programming languages. It turns the traditional approach on its head. Rather than first explaining a new concept and then showing some example code, this book does it in the reverse order. It starts with code that demonstrates everything you'll learn. The idea is, you type it in, play with it, and try to break it. Then you read about what each line does. Rather than going through each new keyword separately, it just dumps a dozen or two on you at once and asks you to memorize them. Later, you understand what they do.
I have mixed feelings about this book.
The Good
I think this new approach is a better way to learn a new programming language. So often, in other books, I read all this explanation that I have trouble grasping because I need to see it to understand it. So I power through the explanation first, and then once I see it in action it all starts to become clear.
With the "hard way" approach, you see a bunch of code you don't understand at first, but that's fine. You just need to type it in and play with it. Some of it you can probably figure out on your own as you experiment. Then the explanations answer any questions you have. It seems so much easier this way. That's ironic, since it's called "the hard way."
This approach has another huge advantage: it doesn't require quite so much explanation. You've already played with the code, maybe looked some stuff up on your own. By the time the explanation comes, there's not much left to do. This seems especially appropriate for such a minimalist language like C. You're already doing pointers by page 62 and heap and stack memory allocation by page 74. The language proper, advanced topics and all, is done by 135 pages, only 1/3rd of the book.
That leaves 200 some pages for all the important stuff most language tutorials overlook: defensive programming, build systems, linking, libraries, automated testing, data structures and algorithms. So, by the time you're done with this book, you're pretty much done. You'll understand not just the language but how to do full projects, and how to use it for real work. You'll have practiced with tons of actual code, not just coding it but changing it and trying to break it.
That brings me to something else I liked about the book. So many books talk about programming languages as if everything will work great the first time. Most beginner programmers get humbled very quickly. They get one compiler error after another, and they don't know why. They think they're stupid or just not cut out for programming. The truth is, it's very easy to break code, especially when you're still learning. Books should not just acknowledge this but tackle it proactively like this book does. Each chapter includes exercises where you purposely try to break it.
I also like that he emphasizes a simple coding style. For example, rather than teaching you some fancy unit testing framework, he uses "minunit," which is only 30 lines of code, after his tweaks. (The original is literally three lines of code!)
Speaking of which, I like that he includes unit tests for everything. Writing unit tests is so important and always ignored in programming books, which portrays them as trivial and unimportant. Including unit tests for the code, you will understand the code better because you will see how it's used. You'll also get used to seeing how to write unit tests in the language.
The Bad
He seems to use his new style of teaching programming as an excuse to be lazy about explanations. Often it feels very "arm wavey." He depends on the reader to be proactive and do some research and experimentation on his own, and as a result he seems to assume that it's fine to skimp on explaining things.
He uses a library called bstring, and completely skips explaining how strings work in C. He justifies this by dismissing C's strings as "broken." They're only broken if you expect C not to be a low-level, minimalist language. It is, and its approach to strings reflects that perfectly. C is an excellent C, but it's a lousy Java. Most criticism of it would go away if people accepted C on its own terms. Blowing off explaining C strings is a bad idea if for no other reason than beginners will be reading other code, almost all of which does not use the bstring library.
The writing style bugs me. The description of the book says he's "an entertaining and lively writer." To me, he just sounds like an arrogant hipster programmer. He thinks he is one seriously bad ass programmer, and he isn't, although he's pretty good.
Here's a good example of his obnoxious writing style: "You can thank me later when you realize how insanely awesome these macros are. Right now, you don't know how awesome they are, so you'll just have to use them, and then you can walk up to me one day and say, 'Zed, those debug macros were the bomb. I owe you my firstborn child because you saved me a decade of hardache and prevented me from killing myself more than once. Thank you, good sir, here's a million dollars and the original Snakehead Telecaster prototype signed by Leo Fender.' Yes, they are that awesome."
What follows is a handful of macros that just print errors and jumps to the end of the function. That's it. I've written these kinds of macros a few times in my own code. Usually I don't need them because I don't abuse the heap, so I can usually do an if-statement and a return statement on one line. This is clearer than some obscure macro defined elsewhere. It's good that this book presents these macros, because they can save some lines of code in some situations, but mostly because it demonstrates the preprocessor and the importance of creating abstractions rather than duplicating code all over the place. But they are not that "awesome."
The Ugly
In several chapters toward the beginning of the book, code and the output do not match. In exercise 7, several print statements from the code don't show up in the output. The output session for exercise 9 is actually the output session for exercise 10. Exercise 10 is about switch statements, but the example code doesn't actually have a switch statement. The book doesn't have any switch statements until exercise 13, which is actually about for-loops and string arrays. Exercise 13's output session is actually the output session from exercise 10.
These are enormous errors. I'm astonished they made it past the editing phase. And they happen at the worst possible place, when new programmers are still grappling with the basics of the language. They would get completely lost. This is practically a deal breaker for this book, and the reason I'm only giving it 2-stars. The good news is that it's only at the beginning. The problem doesn't show up later.
Disclaimer: This review is about the online version as of April 2014.
The 4 and 5 star ratings given to this book are clearly from beginners unqualified to rate the quality of a C book.
The book is riddled with errors (technical, not just typos) and the entire book basically discusses C in terms of what happens on the particular compilers and machines the author uses. This leads beginners learning C with entirely incorrect assumptions. The author rarely, if ever, points out when implementation defined behavior or undefined behavior occurs.
It could have been a really good book on modern C but it isn't because of many many things...
- The author has a really negative tone towards pretty much everything. - I like to read in bed, but thats a bit difficult when the author asks you to look up things on the Internet or go watch his DVD... - The book is full of mistakes (wrong output for the code, wrong chapters etc). - The author doesn't follow the standards and make up his own stuff. - The author complains how C strings are broken. They aren't broken, it's just the way they are in low level language like C compared to the higher ones like Python. - Sometimes the author jumps ahead and skips explaining things with the explanation that it's available on Wikipedia.
Great supplement to K&R, especially when it comes to introducing the basics of using C for OOP. Some of the "Extra Credit" is a bit overambitious, though--most of the time it's fine, but sometimes it's something like "Figure out how to do XYZ", when really figuring out all that stuff is why I'm reading a book in the first place.
If you want to learn the basics of C in 48 hours, do this. Zed also introduces coding styles and debugging skills that are modern and sadly lacking in most books.
This is neither a literary nor a software tutorial masterpiece, nor is it self-contained. It's gnarly, flawed, rough around the edges. It intermittently mixes up its own macros with standard library functions. Some stuff is just laziness - terms like "the CPP" and "cb" are not bothered to be defined even once (although they're self-evident to an experienced engineer). There's duplication all around in the code. The CNaming_style for functions is like a splinter in the eye. The book can be polished drastically. And yet, and yet it does make one work (if one decides to roll up their sleeves and get their hands dirty), has (mostly) fully working code, and one ends up picking up experience and knowledge nuggets along the way, e.g. fuzzing, Makefiles, and such. I'd have gone for 3.5 or even 4 stars but some of the typos and missing bits made life harder for me than it needed to be, the final few chapters were extremely rushed, and to top all that off I somehow lost access to the accompanying videos! It was a rough time, but I'm glad I went through it.
I just finished the draft version of "Learn C The Hard Way". I'm impressed how Zed Shaw introduces data structures (even more obscure ones like Radix Map and Ring buffer), unit testing, various ways to get into a new code base and a typical project skeleton for a C project.
This is a good beginners book to learning the c programming language. I read the free online version of this book which did, however, contained a couple of small mistakes. I don't know if the paid version also contains these mistakes. Be prepared the get your hands dirty since this book contains many hard exercises which are perfect to learn the language. In my opinion you can only learn programming by doing and this book fits perfectly into this philosophy. This is a good book to get the correct basics for the c programming language. Along with the book "the c programming language" by Kernighan and Ritchie this should be a way to get started with c.
The book starts with the very basics of c; how to compile c programs, how to debug, variables, statements, loops, arrays, pointers. But around exercise 20 you get to program your first real programs. The goal at the end of the book is to have a set of tools programmed which are used in programming languages very often. You will have to program dynamic lists, sorting and searching algorithms, hash maps, stacks, binary trees and many more. All of these are important data structures and I think it is a good choice to get them right immediately at the beginning of learning a new language. Most of the exercises are typing over the code which is presented in the book. Afterwards you often have to improve the code you just wrote.
I think that this is a good book to get the basis of the c programming language.
Interesting perspective on teaching programming language, this book is for people who don't have much experience with programming languages so if you are already have couple of languages under your belt this may not be for you.
The main reason I picked up this book was because I wanted some background knowledge about C after going through Stroustrup's C++ introductory piece Programming and Principles, which I hoped would reveal (some of) the reasons behind the design choices made while creating C++. Also, the table of contents of this book was promising, as it seemed to fill in some gaps quite well that were left by Stroustrup's book, like macros, build systems, unit testing, etc. So I went and bought the book and started to read it with quite the enthusiasm, but this enthusiasm was unfortunately eroded away step by step as I was going through it. I must stress here, that I really wanted to like this book, but I can't say that I feel that way any more.
The book starts pretty promisingly, as it introduces you to some of the basic C syntax, and then it gradually builds on previous chapters with some rather good and challenging extra exercises. But as you are progressing through chapters, the quality seems to deteriorate. The first problem comes with misaligned (if compared to the text) or completely missing line numbers for code, which issue persists throughout the entirety of the book. Later, "misaligned chapters" and "misaligned exercises" appear as well. Sometimes I was really wondering if some of the chapters (and/or exercises) were in the right position, or if they were needed at all. Code quality also seemed problematic a few times, especially after reading R.C. Martin's Clean Code and R. Osherove's The Art of Unit testing. I was also wondering about the choice of topics and the amount of explanations presented from time to time, but that, I know, is highly subjective.
So let's go into some specifics. The line number issue is pretty straightforward, so I'll just skip that and continue with "misaligned chapters and exercises". At the end of each chapter there are some exercises that are meant to make the information mentioned in the chapter sink in better, and a lot of them does a pretty good job at that at first, but later some exercises start to require of you to use and do things that will only be explained in the next chapter. Here one could really wonder which of the two is unnecessary, as if you manage to figure out the solution, then why do you need the next chapter, but if you have a chapter for it later, why require something like that beforehand? In an other instance, some highly interrelated topics (types of data structures) are fragmented because of some wedged in chapters.
Code quality also seemed to be an issue sometimes, as it went against what is considered to be good coding practice nowadays, at least according to the rather logical views of Uncle Bob. He clearly stated, that code must be as easily readable and comprehensible as possible, but this rule seems to be violated frequently in this book. Some examples include ambiguous variable naming, incomprehensible name abbreviations, being "too smart" about code (which is shorter to type, yes, but longer to understand), inconspicuous declarations (midfile single line macro definition hidden between large functions), etc. Some other type of code problems seemed to arise in makefiles and unit tests as well, like questionable variable assignment types (= vs :=) in the former, and interdependent unit tests (order of execution dependency) in the latter.
As mentioned before, I also had some issues with the topics themselves and the amount of explanations used. The title of this book says "Learn C the hard way", but interestingly enough only some part of the book deals with C itself, which I actually liked at first, but only at first. Initially, after getting through some necessary language basics, the book starts to introduce you to debuggers, makefiles, bash scripting, directory structures for development, programmer mindsets, unit testing etc., which I think is great, since you have to know what to do with your code after you wrote it.
But the problem with these are, is that the amount of explanation provided seems to be too short for most of the topics and the complete lack of figures in the book doesn't help either. Breaking the presented code down line by line will make one understand what the presented code does, yes, but it will not teach you how to write something, especially if design choices are not discussed at all. A good example of this is makefiles. There are two chapters about it, but apart from knowing what the presented makefiles do, I honestly couldn't figure out why the makefiles were written the way they were, because no background information was provided at all. And this is just one example, but the same could go for algorithms, data structures, unit testing, etc.
So the general consensus seems to be, that the author basically cherry picked certain parts from larger topics that made it possible to be able to progress from topic to topic, and then put these parts in the book with only short explanations that never go outside the boundaries of the presented code. And this is where I think it mostly fails as a teaching book. I literally had to spend at least half the time reading external resources to get enough background information about all the stuff. A few helper figures could've helped here immensely, just as every other resource I found used them (for a good reason).
What is even more puzzling, is why only certain data structures and algorithms were discussed and why many others were simply mentioned in a few words (directed to wikipedia basically) or omitted entirely. It must be stressed here, that a considerable amount of the book deals with these things, but what is presented here, is highly selective. So are these chapters needed at all in this fashion? Could these pages have been filled with better content (like having more on makefiles, translation units, gdb, gcc flags, etc.)?
Considering, that this book was meant to teach people, I think conveying information as smoothly as possible should be priority #1. I honestly think that the basic concept around which the book was made is really good, namely trying to be a hands on manual for people who want to program using C, but the implementation unfortunately is not really good. If one has to constantly read immense amounts of outside resources, then what is this book trying to achieve really?
To whom would one recommend this book and for what reason? Is it a hands on manual for C programming? Not really. Is it a data structure book? No. Will you learn some neat compilation tricks? Nope. Some nice debugging wizardry maybe? Nay. Maybe know about a nice set of recommended libraries you can use? Negative. So as you can see, I have a really hard time recommending this to anyone, as I just can't figure out what the major discussion topic is. If I was really forced to say something anyway, I'd say it is some C with some makefiles with some unit testing with some data structures with some algorithms with some programming advises with some explanations.
So all in all, even if you buy this book, you most certainly will not loose anything by going through it, but I can think of better resources (which are also free in many cases) to gain knowledge about the topics presented in the book. Thanks for reading.
As with most of the books in the Learn The Hard Way series, Zed does a great job with this one. It is reccomended that Learning C using this book is not your first programming language, and I strongly agree. In fact, I worked through this at the same time as Learn More Python 3 the Hard Way: The Next Step for New Python Programmers, which was extremely helpful for the Data Structures and Algorithms section of the book.
I will say that there is a lot of independent research/self-study in this book. If you rush through and don't do the extra credit exercises, you're doing yourself a disservice. Also, there were several times where the self study didn't quite get me all of the way, so I also have read The C Programming Language (K&R C) while completing the book, as well as starting on Expert C Programming: Deep C Secrets.
I can say with certainty, especially if you have less background with C, working through this book will make you a better programmer all around.
In serious need of editing. It looks like things have been cut or moved, but references to the missing things are still in the text. Technical issues crop up here and there. I even found a 'To Do' with a note reminding the author to add information here. I want to like this book, but I can't recommend in its current state.
One of the best books I've ever come across on C - Simple enough to digest with good examples and explanations. I found the content easier to comprehend than K&K. I enjoyed playing with the examples in each chapters.
it was interesting book and same time challenging, maybe most of us wont bother to finish this book. but trust me it worth it. but if you're a a person that new to programming don't make this book, first one to pick, maybe lot of people would recommended you to read it, but trust me, this book don't explain much and even force you to Linux terminal, if you never used Linux before or even asking yourself what's Linux, there's lot of Linux related books, dont read this book if you are new to programming. if you dont know what book to pick, as my opinion read "Let Us C' it explain everything you need to know, not just the boring staff even explain GUI. even it comes with video tutorials.
Pretty solid book and video course, best used as a complement to the traditional K&R "The C Programming Language", especially if you enjoyed "Learn Python The Hard Way" as your introduction to programming in general. You won't be able to follow along that well without a rudimentary understanding, or at least a few chapters of K&R. This book gives modern context on current best practices and idioms, whereas K&R is rather dry and a bit dated. If you like more opinionated/subjective programming books written more coloquially, go for this one, but don't diss the classics either - K&R is gospel.
This book introduced me to the idea of defensive programming.
Most examples are interesting. The last few are focused too much on algorithms.
It is slightly outdated in the sense that for Mac OS X Mavericks, lldb replaced gdb. The Apple documentation is as usual not that great. It is possible to install gdb through homebrew.
This is definitely the "hard way" of learning C without much background on other languages or computer science.
This seems great for beginners, as it goes nicely through the language and gives some very good exercises for people to do. It won't be that useful without the exercises, but still makes a nice read and collects some of the well-known problems of C for people to see. There seems to be some of the author's opinion in the book, but that doesn't spoil it.
Personally, I prefer this book and 21st Century C together over K&R, which is a bit crusty at this point in my opinion. I purchased this along with the videos and both are needed to get the maximum benefit. Not for copy/paste coders, this book is for you if you like a very hands-on approach and accruing the theory as you go rather than the other way around.
Final notes. Ex 27 to 31. Good chapters and a break from the exercises. The rest of the book is sample code on data structures and there's the final page about how the language is dead and I should get a move on. Yeah.
PS: I read the incomplete online edition.
This entire review has been hidden because of spoilers.