Earlier quoted context omitted.
Right, but I've never seen it used with integers. %.2d is probably the most common format I've seen. Messing up your format strings is a common exploitation vector, so I was wondering if he had typo'd that or otherwise used it accidentally.
You mean %.2f ? %d is for integers, %f is for reals (yo).
Learn C The Hard Way
61–70 of 260 posts
Re: Learn C The Hard Way
#62Has anyone actually used "Learn Python the Hard Way" in a beneficial way? I started it several times but never got very far and just learned Python from other sources. I didn't really care for the approach.
For people who already know programming, the official tutorial is the fastest and the best way to start: http://docs.python.org/tutorial/index.html
Re: Learn C The Hard Way
#63I always had an idea of a 'for programmers' series of books for those who know how to program in one language (say, C++, Java or PHP) and wish to pick up a new language eg. 'python for programmers' would not need the first half of it dedicated to explaining strings, loops etc. and could get straight into it from a programmers perspective - a bit like K&R. You could then dedicate more content to explaining philosophy,…
> this would also be a good format to learn new paradigms Or you could have books dedicated to a paradigm, such as functional programming, and have examples in many languages that all serve to drive home a specific point (this is how you make something tail-recursive, perhaps), pointing out how each language is both similar and different. "The Practice of Programming" by Kernighan and Pike is somewhat close to what I…
Re: Learn C The Hard Way
#64It should say "Learn C and make the hard way".
Oh, there's a lot more tools on the way. C is one language that you could spend whole books on just the tools.
Re: Learn C The Hard Way
#65Do 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.
Re: Learn C The Hard Way
#66Earlier quoted context omitted.
I'm hoping to make this book ramp up faster than LPTHW, since I'm assuming people have either read that book or know one programming language already. However, I'm also a big proponent of practicing the syntax even if you think you're an expert already. It just makes things way easier later on.
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.
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 trivial examples. Or else, I simply forget how to use them. For example, you have list comprehensions in Python, Racket, F# and if you ask me to do a list comprehension right now without looking up the reference, the only one I will get right is Python. I recently started learning F# and didn't type much code; so the concept is known, but since I didn't practice the syntax, I will have to learn it again.
That's what he means by practicing syntax.
Re: Learn C The Hard Way
#67Good luck, I'm all for more programmers understanding C but I wonder if the wonderful days of programming close to the hardware are ancient history. "[P]eople are deathly afraid of C thanks to other language inventor's excellent marketing against it." Maybe, but I think the raison d'être for C is not apparent to programmers who started with Java, Python, or Ruby.
Re: Learn C The Hard Way
#68Earlier quoted context omitted.
It'll crash and potentially allow code execution if the rest of the args are user coercible. Check out the first few chapters of The Shellcoder's Handbook for examples. Thanks for the explanation. I've never seen/had to use %d with integers. I've only used it with %.Nd for floats/doubles.
Leaving it at "crash and don't do it" is enough for a beginner C book. Mentioning code execution and shell code isn't really in the scope. If he mentions code execution, then it sort of warrants mentioning modern architecture prevent executing data as code, or the code segment is not writable on many architectures...and shell code is basically the op code that your machine executes, and injecting shell code in absenc…
Another important point to mention is that the format string itself should not be user coercible! XCode/LLVM/whatever Apple is using nowadays actually treats non-constant format strings as a compilation error, which is pretty cool.
Re: Learn C The Hard Way
#69I'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…
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 for a programming beginner - should be fine for someone who already knows programming in some other language.