C sucks (RANT ALERT)
Posted: Wed Oct 03, 2007 8:51 pm
C sucks. Example:
Now why the HELL does *pint = 1234; set the value of the POINTER while *liter = 1234; sets the value of the DEREFERENCED POINTER???
And WHICH IDIOT made a SYSTEM programming language WITHOUT putting the BIT SIZES of the standard types into the standard? A valid 32-bit C compiler for x86 can, while following the standard, have an 8-bit int and a 64-bit long long (as long as a short and char is no more than 8 bits either). Only conventions keeps the programs running, not the standard.
C's pointer "system" (where's the system?) is a total mess. The * belongs to the variable, not the type, so notptr will not become a pointer. However, even though the * belongs to the variable and not the type, it can also be specified when you specify only a type and no variable, like in a function prototype:In one declaration the * belongs to the variable, in the next it belongs to the type. What were they thinking? (Were they even thinking?)
When to use the * is confusing for starters because it means the EXACT OPPOSITE in different parts of the program.
Maybe the other features of C are good, then? (Does C even have other features than pointers?) C features a rich set of operators, that's good. But wait a minute! Did I just say a "rich" set? Can anyone tell me why on earth C lacks a non-bitwise XOR operator? (And C++ as well.)
C has 15 levels of precedence (C++: 17). How many C programmers remembers the relative precence of bitwise and compared to bitwise or? Not many.
To be "consequent", C does not use = for equality testing, it uses ==. This is a huge source of hard-to-detect program errors for programmers. But at least it's consequent, right? Not really. Because when you type a <= b you actually do use = for equality testing, even though = means assignment. If this system was truly consequent then <= would be to < as += is to +, and do an assignment of the boolean value of a less-than comparision.
Yep. += adds and assigns.
-= subtracts and assigns.
*= multiplies and assigns.
/= divides and assigns
%= does modulo and assigns
>>= shifts right and assigns
<<= shifts left and assigns
&= does bitwise and and assigns
^= does bitwise xor and assigns
|= does bitwise or and assigns
<= does NOT do a less-than comparison and assigns.
And they did this to be consequent? (By the way, why is there no &&= operator?)
Code: Select all
int *pint = 1234;
int *litre;
*litre = 1234;
And WHICH IDIOT made a SYSTEM programming language WITHOUT putting the BIT SIZES of the standard types into the standard? A valid 32-bit C compiler for x86 can, while following the standard, have an 8-bit int and a 64-bit long long (as long as a short and char is no more than 8 bits either). Only conventions keeps the programs running, not the standard.
Code: Select all
int *ptr, notptr;
Code: Select all
void myfunc(int *);
When to use the * is confusing for starters because it means the EXACT OPPOSITE in different parts of the program.
Code: Select all
int * here_it_means_i_want_a_pointer;
Code: Select all
*however_if_i_use_it_here = it_means_i_DONT_want_the_pointer_but_the_value_it_points_to;
C has 15 levels of precedence (C++: 17). How many C programmers remembers the relative precence of bitwise and compared to bitwise or? Not many.
To be "consequent", C does not use = for equality testing, it uses ==. This is a huge source of hard-to-detect program errors for programmers. But at least it's consequent, right? Not really. Because when you type a <= b you actually do use = for equality testing, even though = means assignment. If this system was truly consequent then <= would be to < as += is to +, and do an assignment of the boolean value of a less-than comparision.
Yep. += adds and assigns.
-= subtracts and assigns.
*= multiplies and assigns.
/= divides and assigns
%= does modulo and assigns
>>= shifts right and assigns
<<= shifts left and assigns
&= does bitwise and and assigns
^= does bitwise xor and assigns
|= does bitwise or and assigns
<= does NOT do a less-than comparison and assigns.
And they did this to be consequent? (By the way, why is there no &&= operator?)