in the name of zero

January 25, 2006

intermission

i find it absolutely hilarious whenever someone starts talking about things that are way above his/her head. a stroke of ego? or perhaps a noble attempt to boost foolish zealotry, their reasons always elude me.

anyway, here’s my take on some things he said. (keep newbies away from c)

To actually do anything useful, you have to teach them pointers— and even seasoned programmers have a hard time with pointers;

it’s actually very convenient to use pointers in every C program. the only problem i see here is that in C, one has to explicitly employ garbage collecting for every dynamic allocation he makes. learning other languages first (that don’t employ pointers) cannot in any way be helpful to anyone when he first tries to learn pointers. those who can’t speak C prolly shouldn’t be programming anyway.

There is no real string library, and strings are not real first-order types (i.e. char * is simply an array of characters, and you should really remember that);

what kind of dumbfuckery is this? first and foremost, char * is abso-fucking-lutely NOT an array of characters! where the hell did you learn about this stuff? char * is a 4 byte pointer to a memory location that holds a 1 byte value. it isn’t and will never be, an array of characters!

consider this snippet: (will spit out a warning about incompatible pointer types)

int main(int argc, char **argv)
{
        unsigned short number;
        char *pointer;
	
        number = 0x100A;
        pointer = &number;
	
        printf("0x%02x\n", *pointer);
        printf("0x%02x\n", *(pointer+1));
	
        return 0;
}
as for string libraries, C has lots of them. mix and match. use your imagination. a string in C is an array of (null terminated) characters which are primitive data types. as such, all operations must be done at an atomic level. the contention about a real string library here is overrated and biased over an object oriented implementation.

Teaching C to beginners will keep such bugs as memory leaks and buffer overflows alive, and cause even more problems for future generations of users;

on the other hand, shielding them from these abominations just makes them overly dependent and trusting to libraries. “hey! i write memory leak and buffer overflow free programs coz [language] libraries are free from them!

C is quite low-level, and unless you have a firm grip on data structures and how they are used, learning C won’t help.

how come? data structures are used in every programming language and sooner or later, a student will eventually realize that he already needs to use them (like if he wants to return two values from a function at the same time). the only difference is abstraction. anyone must have a firm grip on data structures regardless of the language.

Worse, thinking in C forces you to think at such a low level, you won’t really learn how to think in terms of the problem space

this might be true to some extent. especially since the biggest win of C is being able to point to memory locations and meddling with atomic, low level, insignificant elements. but that is why algorithm studies are coupled with any programming courses. that is, after the student has gained a little insight and confidence with the language at hand (C or any other language for that matter). anyone can write equally bad implements on any language.

it boils down to this statement: “all i’m saying is that C is as good a first language as any language.”

Comments »

The URI to TrackBack this entry is: http://gnurbs.blogsome.com/2006/01/25/intermission/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Get free blog up and running in minutes with Blogsome | Theme designs available here