The more I learn C the more I hate it. At first it seems simple and easy but reading "Expert C Programming" is reading a laundry list of what's really messed up with the language. 80% of the problems would be solved by some sane syntactic sugar that compiles down to C
I would say generally I feel that way about any language I've learned. Initially they are pretty easy and the examples given include slick solutions to contrived problems. Then you get into wanting to do real work and you learn about all the corner cases and ambiguities and landmines that are hidden farther afield. Can anyone name a language that they've grown to like more the more they learned about it? I would gues…
To become a good C programmer (2011)
51–60 of 106 posts
Re: To become a good C programmer (2011)
#52Earlier quoted context omitted.
I think the style should be avoided; code shouldn't be compact and variable names should be descriptive. Artificial example: for( int i = 0 ; i should be: for( int count = 0 ; count It may be allowed to use i in place of count here, but this is the only place where single name variables should be permitted and only if i is really just a simple array index iterator.
Even "i" can be changed to "index". My rule of thumb is this: If you wouldn't use the abbreviation when speaking, don't use it when coding. I don't understand why 'i' has been given a pass. The argument boils down to saved keystrokes. Typing is not the bottleneck.
But apart from that, I think using i,j,k as index variables in for-loop has become such a de-facto standard that I would only prefer long names such as "count" or "index" in situations where multiple indices may cause confusion. But then I'd probably use even more specific names than "count" or "index".
Re: To become a good C programmer (2011)
#53Earlier quoted context omitted.
No the representation model is fine. It's where C tries to be something other than portable assembly where it goes awry. E.g. C has more syntax for arrays than actually exists at runtime, which leads to surprising behavior. The problem with array arguments discussed in the LKML thread posted above is a great example.
I am having trouble identifying "the LKML thread."
Re: To become a good C programmer (2011)
#54Earlier quoted context omitted.
I disagree: no static typing --> annoying runtime errors, no 'use strict'..
While I like static typing, there's a lot more that goes into making a language good or bad than that. On the whole, python seems pretty good to me. I'd take it over Java 90% of the time.
Re: To become a good C programmer (2011)
#55Learning C syntax is pretty easy. Learning to use the standard library is mostly a matter of reading man pages and other people's code. But I found understanding pointers and memory management completely opaque until I read that book. It definitely brought me from "beginning C hacker flailing about" to "intermediate C hacker flailing about in a more dangerous way".
Re: To become a good C programmer (2011)
#56Earlier quoted context omitted.
I think he means that he works like this: 1. Write some C 2. Dump the corresponding assembly code 3. Modify the code by hand
4. Assemble 5. Load into assembly debugger 6. Learn There is "C", the language, which can be relatively simple. Or hopelessly opaque depending on the author. I think of C the language as just a shorthand for assembly. Only because that's how I use it. http://www.lysator.liu.se/c/bwk-tutor.html But then there is "C" in practice: the specifications, the "standard" libraries, preprocessors, Makefiles, autoconf, etc.
Re: To become a good C programmer (2011)
#57I found that, after learning the basics of the language via K&R or a similar book, the best way to get a good understanding of C and its weird corner cases and eccentricities is just to go through the comp.lang.c FAQ page. http://c-faq.com/index.html It's pretty comprehensive, and I found the level was pretty good for a "not total newbie, but still not familiar with the subtilties" level that can be kind of hard to f…
Making a blogging engine in C would be very informative (though difficult).
Re: To become a good C programmer (2011)
#58Re: To become a good C programmer (2011)
#59Earlier quoted context omitted.
Making a blogging engine in C would be very informative (though difficult).
If you build it on ribs2 (with garbage collection) it wouldn't be too hard.
Re: To become a good C programmer (2011)
#60I found that, after learning the basics of the language via K&R or a similar book, the best way to get a good understanding of C and its weird corner cases and eccentricities is just to go through the comp.lang.c FAQ page. http://c-faq.com/index.html It's pretty comprehensive, and I found the level was pretty good for a "not total newbie, but still not familiar with the subtilties" level that can be kind of hard to f…
Making a blogging engine in C would be very informative (though difficult).
[1] https://github.com/spc476/mod_blog
[3] https://github.com/spc476/CGILib
[4] gopher://gopher.conman.org/