Live data from Hacker News

Learn C The Hard Way

learncodethehardway.org

101–110 of 260 posts

Re: Learn C The Hard Way

#101
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.

C allows differences in how negative integers are represented (at least, C89 did---I'm not sure about C99 as I don't have the standard in front of me). There are three different ways to represent negative numbers in binary, sign magnitude, one's complement, and two's complement (these days, most computers are two's complement). The upshot is that you might end up with two type of zeros (sign magnitude, one's complement) or an unequal range of negative numbers (two's complement has one additional negative number) and taking the absolute value of an integer may not be possible for some values (given a 16-bit integer on a two's complement system, you cannot get the absolute value for -32,768, which is a valid integer on such a system).

Re: Learn C The Hard Way

#102
post #37

Earlier quoted context omitted.

The arrow operator and identifiers with leading underscores seem to be glossed over or skipped fairly often in education. It's intimidating to look at code that uses them if you don't know what they are.

Identifiers with leading underscores? I use those for member variables... (this makes more sense in C++ without the arrow notation.)

The C Standard reserves identifiers starting with a leading underscore for the system implementation (C standard library, Posix libraries, etc). They aren't meant for use by user code (or rather, you can use them, but they might conflict with system defined identifiers).

Re: Learn C The Hard Way

#103
post #38

Earlier quoted context omitted.

Oh right, I forgot they added that to the C6.283185307179586 standard.

I'm amused you took the time to put in 2pi there.

Google bid pi billion for the patents.

Intelligent people support Tau: http://tauday.com/ This is the least Zed could do.

Re: Learn C The Hard Way

#104
post #73

Earlier quoted context omitted.

> "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.

No, I was thinking binary 19. Does C say the implementation is going to be 1s complements, 2s complements or whatever?

Is there anything that says, for example, it can't be BCD?

Re: Learn C The Hard Way

#105
post #82

Ohloh says I've changed at least half million lines of C code ( https://www.ohloh.net/accounts/rhp/positions/total ) Play me a tiny violin ;-) What kinda bugs me is that whenever people go to teach C, they make out like it _has_ to be a low-level exercise, as if writing in C suddenly means you can't use abstract data types or object-oriented style or name your functions properly or have Unicode support. For example,…

I'm glad you got so much about how my book is written from a few paragraphs in an unfinished manuscript for it.

Re: Learn C The Hard Way

#106
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…

[deleted]

Re: Learn C The Hard Way

#107
post #82

Ohloh says I've changed at least half million lines of C code ( https://www.ohloh.net/accounts/rhp/positions/total ) Play me a tiny violin ;-) What kinda bugs me is that whenever people go to teach C, they make out like it _has_ to be a low-level exercise, as if writing in C suddenly means you can't use abstract data types or object-oriented style or name your functions properly or have Unicode support. For example,…

I'm glad you got so much about how my book is written from a few paragraphs in an unfinished manuscript for it.

I was just going off on a generic tangent, obviously I don't know what your book will be like. Just talking about C since it's 1am and vaguely on-topic.

Re: Learn C The Hard Way

#108

Zed, your level of productivity is truly inspiring. The best of luck to you.

I think the level of self-promotion and/or other-people-promoting-him is the key factor. Not really the supposed productivity. I know many people who get a lot done, both for day jobs, for contract work, as a hobby, as entreprenurial ventures, etc. but 99.9% never hits the front page of HN on a regular basis like Zed's activity seems to. Which doesn't lessen what he does and his skills, but it does pull back the came…

I personally have no idea why this stuff hits this site that often. Take this for instance: It is a half-finished manuscript that I announced in a tweet to people who follow me on twitter and asked for it. Already at the top of this set of comments is a dickhead saying he's such a bad ass 'cause he's changed "half a million lines of C code" and he thinks I'm not writing the book correctly because I'm being too low level. He gets all of this from three exercises and three paragraphs in the introduction.

Frankly, I consider hackernews kind of irritating and not useful as a promotional tool. It amounts to about 5% of my traffic for 1 day at best, and I only have to be here because if I'm not answering the petty little idiots who troll here then the rumors spread through my professional circles.

In other words: I could live without this kind of promotion, so it's definitely not "self-promotion".

Re: Learn C The Hard Way

#109
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…

Nope, this book isn't for total beginners. I mean, it might work, but I'm actually telling the total newbs to go read http://learnpythonthehardway.org/ first. My thought is teaching "computational thinking" is easier with a language like Python, so people should start there.

Re: Learn C The Hard Way

#110

When I first learned C, I did so under DOS, an environment in which you could declare a pointer to video memory, make a magic call, and start drawing graphics. I found that a memorable way to learn pointers. Sadly, doing that in the modern world requires quite a bit more setup.

Hmmmm, I wonder if you could do that in a similar way...
Post reply on HN