Live data from Hacker News

What do you want to see in Learn C The Hard Way?

news.ycombinator.com

31–40 of 127 posts

Re: What do you want to see in Learn C The Hard Way?

#31
I am not sure how applicable it is to an introductory text, but I would be interested in learning more about the internals of compilation and linking. What is the minimal necessary amount of work that needs to be done to interact with existing C libraries (header files, ELF format, and how that all fits together).

Re: What do you want to see in Learn C The Hard Way?

#32
post #21

whatever you do, make your examples bulletproof. even if it's not how you would normally write the code and it seems overly cautious, do your audience a favor and write the example that way anyway. if there are any buffer overflows, integer overflows, off-by-one's, signedness issues, failure to check return values of everything, use of typically insecure things like sprintf instead of snprintf, all of these problems…

I don't think the learner would appreciate the subtleties, and I don't agree that they'll learn anything from it. I can reinforce each lesson/problem you're describing one by one through the exercises, but a new person simply wouldn't know good code if it slapped them in the face. Confer with Learn Python the Hard Way to get a feel for the aesthetic and technique I'm working towards. I don't want to write bulletproof…

I don't think the learner would appreciate the subtleties, and I don't agree that they'll learn anything from it.

I can reinforce each lesson/problem you're describing one by one through the exercises, but a new person simply wouldn't know good code if it slapped them in the face.

that is my point: your readers might not understand everything you're doing, so they're just going to copy and paste parts of it into their new projects. if you give them sloppy code to learn from, they're going to copy that sloppiness into their code that makes its way into the real world.

there are a lot of things in c that new programmers have to be especially careful about that aren't relevant to python.

Re: What do you want to see in Learn C The Hard Way?

#33
My plan was to make people use valgrind all the time after about lesson 10. Rather than you having to teach them all the various errors, you just let valgrind teach them by telling them their stuff must be valgrind pure.

Other than that, pretty much the same style as I did LPTHW.

Also, read:

http://sheddingbikes.com/posts/1288945508.html

There's more advice there.

Re: What do you want to see in Learn C The Hard Way?

#35
post #30
post #21

whatever you do, make your examples bulletproof. even if it's not how you would normally write the code and it seems overly cautious, do your audience a favor and write the example that way anyway. if there are any buffer overflows, integer overflows, off-by-one's, signedness issues, failure to check return values of everything, use of typically insecure things like sprintf instead of snprintf, all of these problems…

I disagree. If I'm learning a new language, I'm too busy worrying about the commas and semi-colons, not whether or not I'm using strcat or strncat. Worrying about overflows, signedness, etc. is something you do once you're more comfortable with the language. It would be nice to provide links to articles and books on why one should use snprintf instead of sprintf or what is integer overflow and how do you deal with it…

paging tom ptacek... tom ptacek to the white courtesy phone...

Re: What do you want to see in Learn C The Hard Way?

#37
post #22

What I really miss is some C book that teaches the modern approach to "object-oriented" C (as done in Gtk, Apache, CPython etc.). Actually many programmers (presumably with only passing knowledge of C programming) even actively proclaim that you cannot program in C in this style.

I'll teach function pointers, and might expose them to some style of OO C, but I haven't made any decisions on it. My approach is going to be relatively unflavored by the Macro Hell of other projects. I'd rather not instill those habits. They can learn that on their own time. I want the learner prepared to write clean sysprog code. That's it, the rest they can learn having been taught proper C and make their own styl…

Why would you shy away from macros? Yes they are ugly, but they are an integral part of C and any system programming will rely quite heavily on macros, whether we like it or not.

If you're going to cover macros, please make sure to explain how they work and the multitude of pitfalls as well as how to deal with them; which is to wrap each macro in parenthesis.

Re: What do you want to see in Learn C The Hard Way?

#38
post #26

Why not base it on a project? If you want more people to do systems programming (I am assuming kernel and driver development), why not take something from http://kernelnewbies.org/ and turn it into a simple project or write a character driver. People will learn how to write code for the Linux Kernel, learn how to interact with that community and perhaps become more interested in systems development as a result, if th…

>Why not base it on a project?

There might be a project. I'm modeling it after Zed's approach to some degree regardless.

>(I am assuming kernel and driver development)

Not particularly.

>turn it into a simple project or write a character driver

Nah.

>People will learn how to write code for the Linux Kernel

That is in fact, the opposite of what I'm trying to do.

I want to teach C, not Linux.

>would be nice if you integrate TTD into the projects

I'll demonstrate how/why, it won't be an integral part of it. TTD is use-case specific, not a universal benefit.

>The number of C developers that I deal with who do not understand the concept of a unit test is amazing.

That's a cultural problem, not a pedagogical one.

>Also, please cover C99 and talk a little about compilers, linkers and assemblers.

I'm going to aim for implementation agnostic insofar as it's possible while keeping them aware of the caveats.

What you're advocating is a significant departure from Zed's example. Not my goal.

>explain a little bit about how your C code gets converted into machine format

Implementation specific, outside scope.

>"What makes my book on C different from all the other ones?"

Out of scope of what I'm worrying about, it's a book, not a startup.

>Why should I spend my time on reading your book instead of any number of other tutorials or K&R?

Pretty sure you're not the crowd I'm aiming for, but I'll be happy if you can glean value from it.

Most C books are provincial or overly prosaic. I'm not interested in explaining, I'm interested in whipping people into coders. They can get their compiler and language implementation from a Comp Sci program.

Re: What do you want to see in Learn C The Hard Way?

#39
post #33

My plan was to make people use valgrind all the time after about lesson 10. Rather than you having to teach them all the various errors, you just let valgrind teach them by telling them their stuff must be valgrind pure. Other than that, pretty much the same style as I did LPTHW. Also, read: http://sheddingbikes.com/posts/1288945508.html There's more advice there.

I sent an email after reading that post, was inspired to do this because of it. I planned on having them use valgrind as well.

Re: What do you want to see in Learn C The Hard Way?

#40
post #26

Why not base it on a project? If you want more people to do systems programming (I am assuming kernel and driver development), why not take something from http://kernelnewbies.org/ and turn it into a simple project or write a character driver. People will learn how to write code for the Linux Kernel, learn how to interact with that community and perhaps become more interested in systems development as a result, if th…

No, I disagree with most of this. A LTHW book covers just enough of the language that someone could then go learn the things you mention from another book. At the end you could lightly cover testing, but most people can barely get an editor installed. No way they can learn multi-threading, TDD, an entire project, and an RCS.

It'd also dilute the focus of the book.

Post reply on HN