Thread: Why I hate c
View Single Post
  #9   Spotlight this post!  
Unread 26-02-2004, 14:33
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Why I hate c

Quote:
Originally Posted by gnormhurst
I'm going to a talk by Brian Kernighan next week -- I'll give him your regards!
If I recall correctly, K&R page 101 gives the derivation for the "canonical" string copy statement.
Code:
while(*t++ = *s++);
That's part of why I find c such an uncomfortable language to use. It wants me to think like a compiler. It encourages the use of simple shortcuts that a moderately well-designed compiler should be doing for me. My code is full of explicit tests for zero/nonzero. Although I know I could replace
Code:
if ( my_timer == 0 )
with
Code:
if ( !my_timer )
and get the same job done, I'm a programmer, and I want to be free to focus on the algorithms and let the compiler care about the details of the bits and bytes. Coding can be, and should be, done by machines.

And don't get me started on how numeric operations are performed using the smallest size that the operands will fit in, leaving me to worry about overflows even if I know the end result of an expression will always fit in the variable I'm putting it in. Oops, too late...

I apologize. It was a late night last night. And I must admit that the tool does get the job done, with little to no fuss, as long as I remember to use it correctly.