Learn c the hardway của zed.a shaw.

     
I did learn C the hard way -- from the book by Kernighan và Ritchie (its creators), when that was the only book about C that existed.What is clalặng to lớn hardness of this one?


Bạn đang xem: Learn c the hardway của zed.a shaw.

*

BradA better word than "Hard" for this book's title might have been "Painstaking". In addition to lớn the C language itself, there's a lot of "defensive progr…moreA better word than "Hard" for this book"s title might have been "Painstaking". In addition lớn the C language itself, there"s a lot of "defensive sầu programming" (the author"s words) lessons on recovering from bad inputs and avoiding undefined behavior in C.(less)
*
*
*
*
*



Xem thêm: Dictionary Attack Là Kiểu Tấn Công, Brute Force Và Dictionary Attack

*
*
*
*
*

*

*

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 và 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 lớn break it. Then you read about what each line does. Rather than going through each new từ khoá separately, it just dumps a dozen or two on you at o This is a very different approach to lớn learning a programming languages. It turns the traditional approach on its head. Rather than first explaining a new concept và 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 lớn 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 & asks you to memorize them. Later, you understand what they vì.I have mixed feelings about this book.The GoodI think this new approach is a better way to lớn learn a new programming language. So often, in other books, I read all this explanation that I have trouble grasping because I need to lớn see it to lớn underst& it. So I power through the explanation first, & then once I see it in action it all starts to lớn become clear.With the "hard way" approach, you see a bunch of code you don"t understvà at first, but that"s fine. You just need lớn type it in và 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 khổng lồ do. This seems especially appropriate for such a minimadanh mục language lượt thích C. You"re already doing pointers by page 62 và heap and stack memory allocation by page 74. The language proper, advanced topics & 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 và algorithms. So, by the time you"re done with this book, you"re pretty much done. You"ll understvà not just the language but how to bởi full projects, và how khổng lồ use it for real work. You"ll have practiced with tons of actual code, not just coding it but changing it và 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, và 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 lớn 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 lớn 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 lượt thích that he includes unit tests for everything. Writing unit tests is so important và always ignored in programming books, which portrays them as trivial & unimportant. Including unit tests for the code, you will underst& the code better because you will see how it"s used. You"ll also get used to lớn seeing how lớn write unit tests in the language.The BadHe seems lớn use his new style of teaching programming as an excuse khổng lồ be lazy about explanations. Often it feels very "arm wavey." He depends on the reader to lớn be proactive và vày some research and experimentation on his own, và as a result he seems khổng lồ assume that it"s fine to lớn 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 lớn be a low-màn chơi, minimalist language. It is, và its approach to lớn 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, và 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 sầu khổng lồ use them, and then you can walk up khổng lồ me one day và say, "Zed, those debug macros were the bomb. I owe you my firstborn child because you saved me a decade of hardabịt và prevented me from killing myself more than once. Thank you, good sir, here"s a million dollars & 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 & jumps lớn the kết thúc 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 vì an if-statement và 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 sầu some lines of code in some situations, but mostly because it demonstrates the preprocessor và the importance of creating abstractions rather than duplicating code all over the place. But they are not that "awesome."The UglyIn several chapters toward the beginning of the book, code và 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 sầu a switch statement. The book doesn"t have sầu any switch statements until exercise 13, which is actually about for-loops và 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, và 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. ...more

Chuyên mục: Domain Hosting