Live data from Hacker News

Learn C The Hard Way

learncodethehardway.org

141–150 of 260 posts

Re: Learn C The Hard Way

#141
post #33
post #17

Earlier quoted context omitted.

how about 'if you are proficient at another language, feel free to skip to chapter x'? and put the generalized stuff at that point

If you really are that proficient, you should be able to figure out what you can skip.

I'm not so sure about that. The devil's in the details - you might think you know something well enough to skip it, but get caught out later.

Re: Learn C The Hard Way

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

He is not criticising you; he's criticising what others that undertook this kind of project have done.

Re: Learn C The Hard Way

#143

Earlier quoted context omitted.

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 le…

I’m saddened by the number of grown men I meet who worship guys like the persona found in this rant. Too frequently men (especially younger men) will by default listen to whoever “talks tough” rather than the people who make the most reasoned arguments. They will listen to blow hards and pundits all day and blindly follow their “leadership” on fad after fad, never really questioning whether these people are worth listening to in the first place.

-- Zed Shaw, backpedaling when his angry schtick gets called out by the community

Re: Learn C The Hard Way

#144
post #129

Earlier quoted context omitted.

> Oh my god so many configuration settings! There are many alternatives for you that offer 1click build/deployment.

There are so many, in fact, that choosing one becomes a confusing array of choices in itself.

Use cmake, no fuck this, try JAM. WTF? Why not simple Makefiles, better yet manually written projects for XCODE, VCPROJ.... Oh fuck no.... At the end of the day you wrote something to get your shit out. Simple as that :)

Just google for "msvcrt_win2000.obj" and see the madness (yes, it's about using MSVCRT.DLL instead of later MSVC libs, and still get your shit working on 2000 or XP). I did that just last few hours :)

Re: Learn C The Hard Way

#145
post #127
post #85

Earlier quoted context omitted.

C shouldn't be used for anything other than low level programming these days. There are other higher level programming language that would make your job a whole lot easier. Some programmers, like me, are stuck maintaining legacy C application code, but I wouldn't wish that fate for new programmers looking to learn C as another tool in the belt.

Other uses of C besides low level programming is: 1. Building static libraries. 2. Building so and dll. 3. Binding those so/dll with higher level languages like Ruby, Python, Perl and PHP. That is my main use of C these days. I always write the IO, user interface code in higher level languages and put all processing code in a so or dll written in C.

Yup. Same here.

Having not to deal with exceptions, STL libs, makes life a bit easier.

Re: Learn C The Hard Way

#146

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.

That's how I was taught assembler. One of our first assignments was to draw a circle on the screen. Second was an etch-a-sketch like drawing programme where you controlled the pixel via kbd. We used int 10h[0] a lot

[0] http://en.wikipedia.org/wiki/INT_10H

Re: Learn C The Hard Way

#147
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 was taught C at Uni, but this was after having done a semester of x86 assembly language so we already had a good grounding in pointers, how addresses work etc. This was our textbook http://oreilly.com/catalog/9780937175231

Re: Learn C The Hard Way

#148

Earlier quoted context omitted.

K&R chapter 5.5, Character Pointers and Functions, explains pointers and shows how they are used in C. It's probably the clearest explanation of pointers ever written, and it doesn't require any understanding of hardware or assembly language (though that would help). I remember reading those three pages over and over and experimenting with the code until I got it. I probably spent several days studying the pointer ch…

Getting it or not is one thing, but I'd advocate keelhauling anyone who wrote that sort of thing in production. The "notational convenience" is more obnoxious than anything. But, then, I'm not particularly a fan of terseness for the sake of being terse.

I'm not a fan of wordiness for the sake of being wordy. If you think the code is terse just to show off you are missing the point. There's a difference between writing obscure code and writing concise idiomatic code -- see "The Elements of Programming Style" by Kernighan and Plauger. I'd rather Kernighan, Ritchie, Thompson, Pike, et al. write my production code than someone who thinks C pointer idioms are a punishable offense.

"That sort of thing" has been in production in the C libraries, the UNIX kernel, and all of the brilliant utilities that make up UNIX for over 30 years. It's also very much in production code at Google.

You might want to read Paul Graham's thoughts on succinct code at http://www.paulgraham.com/power.html and Rob Pike's "Notes On Programming in C" at http://doc.cat-v.org/bell_labs/pikestyle.

Re: Learn C The Hard Way

#149

Earlier quoted context omitted.

K&R chapter 5.5, Character Pointers and Functions, explains pointers and shows how they are used in C. It's probably the clearest explanation of pointers ever written, and it doesn't require any understanding of hardware or assembly language (though that would help). I remember reading those three pages over and over and experimenting with the code until I got it. I probably spent several days studying the pointer ch…

Getting it or not is one thing, but I'd advocate keelhauling anyone who wrote that sort of thing in production. The "notational convenience" is more obnoxious than anything. But, then, I'm not particularly a fan of terseness for the sake of being terse.

I imagine terseness was a lot more valuable when everyone was programming on an 80x25 (or smaller) terminal or even punch cards. I've seen a few examples of code like this from early libc implementations of functions like strcpy, malloc, etc. Take a look at the source code of BSD libc -- some of that stuff is historic.

I myself never got much into the terseness game, since apart from a brief stint using gwbasic and later QuickBasic at 80x25, I learned programming using DJGPP in DOS with the RHIDE IDE. The IDE could trick the VGA into displaying something like 132x60, leaving plenty of room for descriptive code.

Re: Learn C The Hard Way

#150

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.

You can do something similar now using SDL. In fact, unless you are blitting bitmaps or using additional libraries, it is the only way to get stuff on screen. SDL gives you a pointer that corresponds to the video memory and you stick colors into it.

Here is a tutorial for using SDL for 'old school' graphics programming:

http://sol.gfxile.net/gp/

Of course this would require the student to install SDL and write a makefile to link it all together. I feel that is something worth covering though, since most books just do a bunch of hand waving when it comes to linking external libraries.

Post reply on HN