C sucks (RANT ALERT)

For everything that's not in any way related to PureBasic. General chat etc...
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

C sucks (RANT ALERT)

Post by Trond »

C sucks. Example:

Code: Select all

int *pint = 1234;
int *litre;
*litre = 1234;
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.

Code: Select all

int *ptr, notptr;
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:

Code: Select all

void myfunc(int *);
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.

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;
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?)
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Quite interesting to read this, but I think every language has small inconsequences.
Even PB:
I've always wondered why, if you want an infinite loop, the 'Repeat' must end with 'Forever'
and not 'EndRepeat' :lol:
Windows 7 & PureBasic 4.4
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Because EndRepeat means that the repeat should END. However, you want to continue with another iteration. :wink:
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

It's all about form and style, man.

As in GfaBasic's implementation:

Code: Select all

DO
  ....
LOOP
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

It's all about form and style, man.

As in GfaBasic's implementation:

Code: Select all

Do
  ....
Loop
... but Pure's looks better :-)

Code: Select all

Repeat
  ....
Forever
The command I still feel funny about is While ... Wend... I think the next version of PureBasic should restandardize and call it...

Code: Select all

While ...
  ...
GoBackToThePreviousLineWithTheWhileAndKeepTryingMate
Much clearer.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Well OK, actually you're right :lol:
Just needed an example and remembered that in the beginning
of my PB 'career' I felt confused about the 'Forever' :roll:
Windows 7 & PureBasic 4.4
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

This is something I've always wondered about: Why does a language need to be so complex as C/C++ and such? Seriously. It just seems that you could create a language that is allows for a high level of customization without resorting to so many hacks and 30 different ways to accomplish something. I look at some C code and cringe from how needlessly complex it seems.

Or DirectX. My god that is horrible to look at. Why can't it just be something like... "InitEnvironment()" or "SpotlightHere()" or "PlaySound()" rather than 500 lines to do something relatively simple.

Am I just being naive?
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

No, you're not naive. It's just, well...let your code look more complicated
then your wages will increase :lol:
Windows 7 & PureBasic 4.4
r_hyde
Enthusiast
Enthusiast
Posts: 155
Joined: Wed Jul 05, 2006 12:40 am

Post by r_hyde »

I'm in the middle of translating thousands of lines of C code into PB, and I honestly have to agree with Trond about C's usage WRT pointers. However, I will say that I prefer the ease of dereferencing using a single operator rather than PB's Peek/Poke functions. There has to be a way to make pointer usage both consistent and simple/wrist-friendly!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> For a new monitor nail here [x]

That's pretty funny. :)
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

And WHICH IDIOT made a SYSTEM programming language WITHOUT putting the BIT SIZES of the standard types into the standard?
:oops: OK it was me... :oops:
:D and if you believe that I have a dereferenced pointer set to localize!!!

Yes, there is a different sort of logic to C than Basic. I have trouble thinking in C, but little organizing my thoughts in BASIC.

However, as long as you are accurate in your pointage and ; use... you can do some amazing things... Look at the C code in the OBFUSCATION thread!

And then code more in PB... 8)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: C sucks (RANT ALERT)

Post by traumatic »

[SOLVED]
Good programmers don't comment their code. It was hard to write, should be hard to read.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

r_hyde wrote:I'm in the middle of translating thousands of lines of C code into PB, and I honestly have to agree with Trond about C's usage WRT pointers. However, I will say that I prefer the ease of dereferencing using a single operator rather than PB's Peek/Poke functions. There has to be a way to make pointer usage both consistent and simple/wrist-friendly!
But you don't need Peek/Poke. Just use a variable called *Pointer.LONG. *Pointer is the pointer and *Pointer\l is the value.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Yeah! Confirmed: C and C++ are crap :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: C sucks (RANT ALERT)

Post by citystate »

traumatic wrote:[SOLVED]
now, don't let's start THAT again... :lol:
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
Post Reply