Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/17/05 01:15
Read: times


 
#85059 - singer, not the song
Responding to: ???'s previous message
Craig Steiner said:
And that's C's fault? I'd blame the programmer. I'm pretty darned sure that if Windows were written in Pascal it'd be just as bloated as it is today.


I agree. I always recommend the O'Reilly book, "Practical C Programming," to anyone who asks. One of author Steve Oualline's main points is that a lot of the common problems associated with C programming can simply be avoided if one doesn't try to be clever.

For example, the common string copy function is usually implemented like this:

void strcpy(char *dest, char *src)
{
    while (*dest++ = *src++);
}


is common enough, but face it, it's one of those functions that's too damn clever for its own good. (Yes, I know, it's in the K+R book.)

In the section, "How not to use pointers," Oualline recommends being clear as a bell when coding:

void strcpy(char *dest, char *src)
{
    while (1)
    {
        *dest = *src;
        if (*dest == '')
            return;

        ++dest;
        ++src;
    }
}


Sure, it's more verbose, but it's easier to debug and maintain, and there's no run-time (speed) penalty for this verbosity, nor does it increase the size of the executable.

-a

List of 36 messages in thread
TopicAuthorDate
simple serial programs examples            01/01/70 00:00      
   Hello, World            01/01/70 00:00      
      Well, yes but            01/01/70 00:00      
         very basic            01/01/70 00:00      
            My point            01/01/70 00:00      
               basic            01/01/70 00:00      
                  but...            01/01/70 00:00      
         Dear oh dear            01/01/70 00:00      
            Impossible!            01/01/70 00:00      
               Avoiding mistakes            01/01/70 00:00      
                  'C' - the sloppy programmers choice            01/01/70 00:00      
                     bloatware in Pascal, too!            01/01/70 00:00      
                        Go on then....            01/01/70 00:00      
                     Horrible C            01/01/70 00:00      
                        Horrible programmer            01/01/70 00:00      
                           If that's you...            01/01/70 00:00      
                     Author, not the language            01/01/70 00:00      
                        Caveat            01/01/70 00:00      
                        language wars            01/01/70 00:00      
                           Bloat or bugs            01/01/70 00:00      
                        singer, not the song            01/01/70 00:00      
                           verbosit/clarity            01/01/70 00:00      
                              Poor, deluded hackers...            01/01/70 00:00      
                              Commented! :-)            01/01/70 00:00      
                                 re commented            01/01/70 00:00      
                                    Comments good and evil            01/01/70 00:00      
                                    comments            01/01/70 00:00      
                                    A quote from some wise people            01/01/70 00:00      
                                       Good but...            01/01/70 00:00      
                                          why...            01/01/70 00:00      
                                             Very true            01/01/70 00:00      
                                                been there, done that            01/01/70 00:00      
                                    Correct comments :-)            01/01/70 00:00      
                                       fishing in Minnesota            01/01/70 00:00      
                                 Author, not the language            01/01/70 00:00      
                                    bounds checks, error testing, comments            01/01/70 00:00      

Back to Subject List