10 ms·
Learn C The Hard Way
- deleted 15y ago[deleted]
- kevinalexbrown 15y agoI recently started working through Learn C the Hard Way, and after doing a few chapters I wrote down what I liked about it in a notebook. Digging it up, here it is: "Why I like Learn C the Hard Way: - Opinionated. I think opinionated textbooks are great because they limit their scope and focus on something. Rather than being an authoritative reference (who uses text references anymore?), it's a framework for learning. - Emphasizes reading and editing which contributes to overall understanding - It's lean. Goes with opinionated, but it's nice that it doesn't repeat what's been done, but sends you there directly, i.e. don't waste time writing about "strcmp", send me to "man 3 strcmp" since I need to get familiar with it anyway." Disclaimer: I'm a bit new to low-level coding, so feel free to point out why these reasons for liking the text might be naiive.
- oblique63 15y agoI too just started reading this one. For me, my first foray into 'low-level' programming was during my freshman year in a CS101 course that used C++. That first course on it's own wasn't too bad, but the subsequent 'introductory' courses for more C++ and Data Structures + Algorithms were just terrible. I couldn't absorb anything useful from them because I was just overwhelmed with the constant bombardment of Segmentation Faults everywhere. Poor teachers + high learning overhead as a result of using a low-level language, just made me want to stray as far away as possible from ever using a 'C-langage' again. If it wasn't for me discovering Python around the same time, I probably would've just given up and pursued music or audio engineering instead. Fast forward to last year, having now learned a ton more languages, I decided to go back and start reading K&R. I didn't manage to get through a whole lot, but from what I read, I liked it. The problem was that I didn't really feel motivated to keep plowing through it. Looking through the snippets of code in it, more and more I began wondering if some things were just outdated practices, or if they were in fact crazy idioms that I would have to get used to when dealing with C. That doubt (as silly as it might sound) did put me off a bit. The explanations in the text were top notch, but again, the code just didn't compel me to type it in like I knew I should. Now I started reading LCTHW just a few days ago, and I have to say, it is quite awesome. It's a lot more minimal and sparse than I'm used to for a book, but I have been seriously surprised at how effective that method is. At first I was a bit annoyed that a lot of parts were basically saying 'just google it', cause I look to books to present me with a more coherent explanation of things than I can find scattered around the web or in arcane documentation. But as I went on with it, I noticed that the things he makes you look up on your own are generally specific enough that it makes the task of filtering out all the nonsense much easier than if you were researching it on your own. I quickly got into the groove of the book, because it just builds your confidence that you can be pretty self-sufficient in a new environment, even at the early stages of your learning. Combine that with his 'code first, explain later' format, and that book is surprisingly motivating. In just 2 days, I went through the first 17 chapters (currently stuck on the extra credit for the Database exercise), and I just want to keep on going. I think this is the first time I've ever experienced this level of enjoyment and drive from a programming tutorial. I have no idea why this is, but it's damn impressive. I can't wait to get to the K&R portion at the end. Thanks Zed!
- zedshaw 15y ago> I noticed that the things he makes you look up on your own are generally specific enough that it makes the task of filtering out all the nonsense much easier than if you were researching it on your own. That's my trick. I actually go googling and make sure that it's something you can find easily with a little nudge. Part of the goal of my books is to teach basic research skills so you can survive on your own. Glad you got that. And, you're welcome. I'm still working on it, but feel free to fill out comments with problems you hit.
- bretthopper 15y agoThis should be titled: Learn C The Hard Way It's for the C version, not the top level domain. edit: titled was fixed. Thanks!
- jc-denton 15y agoYeah that dumbass Zed Shaw, looking at not even half done freetard stuff is a waste of time. There is K&R and a lot of good contributions to stackoverflow [1]. [1] http://stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c http://stackoverflow.com/questions/4810664/how-do-i-use-arra...
- justicefries 15y agoThat's nice, except you just seem to have it out for Zed Shaw - the quality of it doesn't really matter to you, does it?
- zedshaw 15y agoNothing is more enjoyable than watching idiots like you imagine that the world is a fully formed perfect thing that can't possibly be a work in-progress. I watch you guys never put anything out there for fear that someone will think it's just not quite perfect enough. Meanwhile, I crap things into my toilet better than anything you'll make mostly because I put stuff up while I'm working on it so I get immediate feedback. To me, the new artist is about showing the process, not just the final work.
- 16BitTons 15y agoZed, I admire you immensely. Please don't feed the trolls.
- gabaix 15y agoAgreed. I really love your work Zed. Let haters hate and keep doing what you best do.
- zedshaw 15y agoThe rise of the internet fanboi has brought a large number of young and/or impressionable people who confuse hubris and verbal violence with competence and depth. After years of "ignoring the trolls" I now prefer to thrash them to warn the good people away from their stupidity. Also, it's a pretty fun way to practice my creative writing. :-)
- babarock 15y agoWasn't this same book on the front page of HN just a few weeks ago? It just seems so random to see it appear again today? Was there a special release announcement that I'm not seeing?
- farslan 15y agoThe page that was on the front page a few weeks ago was just a respond to K&R's C book from the author itself.
- deleted 15y ago[deleted]
- Locke1689 15y agoHmm, I've always viewed K&R as kind of a paragon of C perfection -- I first learned C from K&R when I was 16 or so and have used it as a trusty companion to systems C programming all the way through grad school. Not only do I view it as a good book to learn C, I also view it as one of the best computer science textbooks ever written, partially because it manages to encompass so much of the C and UNIX style along with the programming language itself. So I guess my question is: why not K&R? Learn Python and Learn Ruby always made sense to me because there's a serious lack of definitive texts on learning those languages, especially if you've never programmed before. However, in my opinion C is not the best first language and there already exists a fairly definitive text on it. So I would love it if someone could let me know what I'm missing.
- nikuda 15y agoYour question is addressed by the author at the end of the book: http://c.learncodethehardway.org/book/learn-c-the-hard-waych55.html http://c.learncodethehardway.org/book/learn-c-the-hard-waych...
- Locke1689 15y agoGreat, thanks! I'll admit that I don't think I've ever used K&R C code verbatim[1] so I never saw how outdated all the stylistic code was. I would never recommend this primitive style in modern projects. Thanks for your insight Zed! [1] Really, if you start dealing with the complexities of C at all K&R will no longer do it. First you'll need to read the ANSI C specification to understand what's supposed to be going on, then you'll need to read your compiler's documentation to figure out how they have actually done what the specification says they should do.
- pantaloons 15y agoHe brings no pedagogical issues to bare, it's simply a facile critique of "style", I don't think that answers the question why not K&R at all. Some may consider the points well taken, not surprisingly K&R had the foresight to respond in kind, two decades earlier: Our aim is to show the essential elements of the language in real programs, but without getting bogged down in details, rules, and exceptions.
- drucken 15y agoCaveat: only scanned the structure and read the final chapter. Regarding the final chapter: K&R, like most programming books (especially those for new language) shows pedagogical code, not for productive use. I highly doubt it was ever intended as the equivalent of the modern-day "Code Complete"! The value of LCTHW, apart from the intro and availability, is its unusual dissecting/analytical approach, which I welcome and am grateful, and for this reason will read it in its entirety.
- o2sd 15y agoOK. NOT TROLLING, but can I ask why anyone would want to learn C, other than to develop device drivers, kernel modules or other arcane software that is yet to be replaced by C++? I asked this question of a younger programmer the other day, because it seemed to me, that to HIM, learning C was a rite of passage, and that he was less of a man for not knowing it. I find macho philosophies in software development both amusing and counter-productive.(If you really want to be macho, become a lisp hacker). My amusement may be personal, but the counter-productivity of using C, when better abstractions (i.e. programming languages) already exist, is real. It creates fiefdoms and priesthoods that are counter-evolutionary and hard to maintain, and leads the death of much software. Personally, I would rather std::string be pored over by many eyeballs and evolved than change strcpy to _strcpy or strlcpy. Unless I am working for NASA on an embedded device for a satellite, I would rather Moore's law or SMP or DSMP give me the speed I need, than give up productivity to squeeze every last CPU cycle. Developer time is a lot more expensive than hardware (except on satellites and space stations). Apologies if it is your ambition to work for NASA on embedded devices in space stations, I just think you may as well learn C++. You get most of C, plus some really useful and productive abstractions as well. If you want speed, learn inter-process communication and the principles of symmetric multi processing. With C++, you also get to abstract away the problems of strcpy and strlen, replace Byzantine function references with class methods, and 35 parameter functions with polymorphism. Best of all, most of the programming world will still think you are manly if you know C++, so you get that too.
- Peaker 15y agoNot all of us see C++ as an improvement over C. Sure, C++ has great advantages, but it also great disadvantages. I use C for many things not because of "macho", but because C is good enough. I can work around the disadvantages using standard techniques. The result is code that is easily FFI'able from any language, quicker to compile, has a smaller footprint, sane error messages, easily debuggable in gdb, etc. Also, there are some advantages in the abstractions that C encourages you to use. For example, lack of templates pushed C programmers to discover intrusive data structures, and those are better in many ways than templated containers ala STL. Another example: "virtual" methods may fail to override a base class method if you make a typo - resulting in potentially cryptic bugs. Using a simple macro in C: #define MAKE_VTABLE(prefix) { prefix##foo, prefix##bar } I can make vtables that are safer than C++, and require no more boilerplate than C++ code. The compiler will guarantee that I implement all of the required vtable methods. If I want to get speed via multi-core rather than pure uniprocessor speed, why use C++? I can use Haskell and get much easier and safer parallelism with many other advantages.