|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Code:
void User_Autonomous_Code(void)
{
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
/* Add your own autonomous code here. */
// [state machine implementation]
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
Process_Data_From_Local_IO;
}
}
|
|
#2
|
|||
|
|||
|
Re: Why I hate c
I totally agree. I'm a professional software engineer with 20 years experience. C is such an unforgiving language. It is difficult to read, easy to make simple errors in syntax, and most compilers won't warn you about things like:
Code:
Process_Data_From_Local_IO; Code:
if (myvar=0)
{
dosomething();
}
|
|
#3
|
||||
|
||||
|
Re: Why I hate c
Quote:
Code:
if(0 = myvar)
{
dosomething();
}
|
|
#4
|
||||
|
||||
|
Re: Why I hate c
also the reason
Code:
Process_Data_From_Local_IO; Code:
x++; |
|
#5
|
||||
|
||||
|
Re: Why I hate c
Using a utility like Lint can help with those sorts of errors. Just run it and it will warn you of anything that you probably didn't mean to do.
|
|
#6
|
|||||
|
|||||
|
Re: Why I hate c
Quote:
I'm going to a talk by Brian Kernighan next week -- I'll give him your regards! ![]() |
|
#7
|
|||||
|
|||||
|
Re: Why I hate c
Quote:
under the MPLAB C18 tab "Diagnostics level" you can chose "errors, warnings and messages" and get more dianostic info, but it won't catch it all. |
|
#8
|
||||
|
||||
|
Re: Why I hate c
Quote:
|
|
#9
|
|||||
|
|||||
|
Re: Why I hate c
Quote:
Code:
while(*t++ = *s++); Code:
if ( my_timer == 0 ) Code:
if ( !my_timer ) 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. |
|
#10
|
|||||
|
|||||
|
Re: Why I hate c
Quote:
|
|
#11
|
||||
|
||||
|
Re: Why I hate c
Quote:
--EDIT-- P.S. Sorry for double posting there. ![]() |
|
#12
|
||||
|
||||
|
Re: Why I hate c
Quote:
Quote:
Quote:
all in all, most of the faults you described are with this specific implementation of C. Chances are you would find programming for a regular computer with C much nicer. |
|
#13
|
|||
|
|||
|
Re: Why I hate c
C is one of my favorite languages. While it can be VERY unforgiving at first, it's not too difficult once you get used to the language. I used to make lots of simple errors (forgetting parentheses, failing to end statements with semicolons, etc.), but the frequency of that sort of error decreases significantly once correct C syntax becomes habitual. C is tremendously powerful without being nearly as arcane as assembler; it allows one to easily combine useful low-level operations with high-level procedural and algorithmic code in a syntax that's clear and human-readable. It took me a long time to get used to C, but I now find that it's my language of choice for many programming tasks. Don't blame the language because you made an error. Certain errors may look like obvious mistakes once you find them, but those errors are often similar or identical to operations that one might perform in order to obtain useful results.
For example: Code:
if(file_handle = fopen("foo.bar","r"))
{
herr_doktor_function();
}
Last edited by velocipenguin : 26-02-2004 at 19:15. |
|
#14
|
|||||
|
|||||
|
Re: Why I hate c
Quote:
Yes, c is very capable. It is also very terse. In sufficiently skilled hands, that's a powerful combination. In just slightly less skilled hands, it's a recipe for subtle errors. As for me, I prefer to use a language which is a bit less terse, with syntax that doesn't make it quite so easy to shoot yourself in the foot. |
|
#15
|
||||
|
||||
|
Re: Why I hate c
Your inability to detect problems is in all likelyhood related to the self rather than the language. Personally, if I can't solve a C/C++ bug within 5-10 minutes, I ask someone who also knows it to look over the language, because they find things I miss. And good compilers do make a good deal of difference. Personally, I like C++ because I like object-oriented language, but C is better than visual whatever they were using before. You can do so much more with so much less. Plus, knowing it has broader practical applications.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I Hate It When... | sanddrag | Chit-Chat | 77 | 25-12-2003 10:57 |
| I hate the BCS and i really ha te KANSAS ST. | Jon Reese | Chit-Chat | 10 | 11-12-2003 12:09 |
| GRRr.... I hate webpages... | XRaVeNX | Chit-Chat | 4 | 15-03-2002 12:28 |
| Why I hate Logic | EnderofDragon | Chit-Chat | 2 | 19-02-2002 21:02 |