Live data from Hacker News

Learn C The Hard Way

learncodethehardway.org

71–80 of 260 posts

Re: Learn C The Hard Way

#71
post #10
post #3

I look forward to the content. As a beginning C++ instructor I find there is something lacking between the truth of the language and the conventions for presenting it. Nobody, AFAIK save for the truly hardcore student, has nailed it.

Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.

I'm not sure if this is going to be pure C or a mix of C/C++, but if you're sticking to pure-C, here's a chapter idea: using containers in C.

This is the big selling point for C++ : the convenience of STL. In all the projects that I worked, it was one of the important reasons to choose C++ over C.

Yes, this focuses less on the language itself and more on the ecosystem around it, but I figured if you have an entire chapter dedicated to "make", then this makes sense as well.

Re: Learn C The Hard Way

#72
It must be nice to be so established as Zed Shaw such that all it takes to get to the top of HN is a couple C exercises. It's almost like if a mathematician could get publicity for talking about addition and subtraction.

With that said, when I first saw Learn Python The Hard Way, it immediately reminded me of the time I spent reading K&R2. Its exercise rich style is what programming books are lacking these days. K&R2 taught me how to program.

Re: Learn C The Hard Way

#73
post #21
post #10

Earlier quoted context omitted.

Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.

My experience as an interviewer showed that in addition to the things you listed, people often fail to grasp binary representation of numbers in a computer at all. This most often comes up when people are asked to do some binary manipulation of numbers, i.e.: unsigned u = 19; unsigned v = u >> 1; "v" is now 9, and to really understand it one must grasp how numbers are represented in binary under the hood. People also…

> "v" is now 9, and to really understand it one must grasp how numbers are represented in binary under the hood.

Correct me if I am wrong, but I don't think C guarantees anything about the binary representation. Depending on the architecture, `v` can have different value.

Re: Learn C The Hard Way

#74
I hope this book will show lots of new C programmers the beauty of pointers in hand-holdy detail ('cause that's the level needed, I feel). Maybe basic stuff about VM, so all the pointer operations make sense (everything is a byte at some offset etc.).

At least I didn't fully appreciate C until I understood some of the underlying concepts.

Looking forward to reading this!

Re: Learn C The Hard Way

#75
post #66
post #51

Earlier quoted context omitted.

Moving from Python to C is a very good move. It allows you to go from programming to inner workings, everyone should have a solid knowledge of C since it give you the tools to identify and correlate aspects of other languages to reality. I don't understand what "practicing the syntax" means (language barrier?), but I'm not suggesting that I've stopped learning, which I never will.

Different people learn differently. Some people don't like to practice the trivial practice stuff, and prefer to breeze through the beginning, read through new material, and then take on some real project. Rich Hickey, recently in an interview, said he doesn't do programming exercises - he is not interested in programs which don't make the computer do something useful, interesting, or both. I, for one, type the trivi…

Got it.

I wouldn't however say that the complexities of C is it's syntax (unless you're playing around with macros : ) ). But I guess the concept can be applied broadly, like remembering functions, headers and other language specifics.

Re: Learn C The Hard Way

#76
post #69
post #67

I'll be interested to see how this compares to K&R, which not only teaches the C language but also C idioms and the reasons for using them. K&R is still one of the very best programming books. Every other C book I've read is inferior. Peter van der Linden's "Expert C Programming" is the only book on C besides K&R that I've learned anything from. Good luck, I'm all for more programmers understanding C but I wonder if…

K&R won't work for someone beginning programming. This book is specifically targeted towards teaching programming to programming virgins. The examples and exercises K&R uses will be very hard for beginners. When it builds a recursive descent top down parser to read the declarations in English(and vice-versa), that will be totally lost on the beginners. K&R wasn't written for beginners and I doubt it will work well fo…

I knew time-shared BASIC before learning C in 1978. I was definitely a beginning programmer then, still in high school. Many (probably most) of the programmers I know from the same era learned programming from books that would be dismissed today as too hard for beginners. In the preface to the first edition Kernighan and Ritchie wrote: "This book is not an introductory programming manual; it assumes some familiarity with basic programming concepts like variables, assignment statements, loops, and functions. Nonetheless a novice programmer should be able to read along and pick up the language, although access to a more knowledgeable colleague will help." Of course that was before the internet, when access to a "more knowledgeable colleague" was harder to come by. In 1978 the only other languages someone would know were Fortran, BASIC, COBOL, Pascal, assembly language, etc.

Chapter 1, A Tutorial Introduction starts at the same place Zed's book starts: hello world. Looking at it now I don't see any reason my 13-year-old son (who knows a very little bit of Python) couldn't learn C from K&R with me explaining things here and there -- the same way I learned C. The recursive descent parser doesn't come up until the end of chapter 5 (out of 8), right after quicksort is implemented with pointers to functions. By then the reader has built up some skills and presumably developed enough curiosity to refer to other books for more explanation of sorting and parsers. For me those were Knuth's "The Art of Computer Programming," especially the third volume with all of the great example code which I busily translated to C.

If you think K&R is too hard for beginners consider how many programmers learned programming from the badly-typeset and somewhat inscrutable "Pascal User Manual and Report" (1974). That was the programming 101 text used at the local university when I was there.

Re: Learn C The Hard Way

#77
post #10
post #3

I look forward to the content. As a beginning C++ instructor I find there is something lacking between the truth of the language and the conventions for presenting it. Nobody, AFAIK save for the truly hardcore student, has nailed it.

Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.

[deleted]

Re: Learn C The Hard Way

#78
post #73
post #21

Earlier quoted context omitted.

My experience as an interviewer showed that in addition to the things you listed, people often fail to grasp binary representation of numbers in a computer at all. This most often comes up when people are asked to do some binary manipulation of numbers, i.e.: unsigned u = 19; unsigned v = u >> 1; "v" is now 9, and to really understand it one must grasp how numbers are represented in binary under the hood. People also…

> "v" is now 9, and to really understand it one must grasp how numbers are represented in binary under the hood. Correct me if I am wrong, but I don't think C guarantees anything about the binary representation. Depending on the architecture, `v` can have different value.

If 19 is represented differently in binary on your platform than (leading zeros)10011, you are already quite screwed.

You might be thinking of character representation for the later example.

Re: Learn C The Hard Way

#79
post #5

Do people really think C is some mysterious, inscrutable language? "To many programmers, this makes C scary and evil." Is this actually true for people? I find C code generally very easy and straightforward to understand; there's not any magic behind the scenes, like there is in any language that's more "high level" than C.

I haven't perceived that people think C is significantly scary (or evil). There are however many compelling reasons not too choose C in the present RAD/Web/Cloud/Solution Business world.

Re: Learn C The Hard Way

#80
post #18
post #5

Do people really think C is some mysterious, inscrutable language? "To many programmers, this makes C scary and evil." Is this actually true for people? I find C code generally very easy and straightforward to understand; there's not any magic behind the scenes, like there is in any language that's more "high level" than C.

Yes, actually people are deathly afraid of C thanks to other language inventor's excellent marketing against it. There's a few things that you need to really nail to be good at C, and they're difficult things, but it's not "dangerous" like people keep claiming.

The negative connotations of the word aside, it seems perfectly reasonable to call C dangerous. Without that "danger", you couldn't write an OS kernel, a language runtime, or various other low-level code we need on our systems; on the other hand, when writing higher-level code that doesn't need that level of raw access, it seems useful to remove the possibility of a broad class of mistakes.

See also Rusty Russell's rules about "easy to use versus hard to misuse". I find C easy enough to use, but also easy to misuse.

Post reply on HN