News for hackers. Stuff that matters.
Re:Why I Write Games in C (yes, C) by sgt101 on Sunday September 22, 2019 @03:36AM (#21040134)
Oh come on, I was taught the difference between strong and weak typing with C (weak) and Pascal (strong) as the examples 30 years ago. You can cast a C entity to something else and NO ONE ELSE KNOWS.

Then THINGS happen.

BAD things.

Re:Why I Write Games in C (yes, C) by unnouinceput on Sunday September 22, 2019 @08:52AM (#21041138)
While Pascal is indeed strong typing and C is weak typing, casting is allowed on both at compile time and introducing bugs this way is not going to be stopped by compiler. Here is what a compile will behave in C vs Pascal:

C code:

int i = 1; char s = "1";

{

if (i == s) //<--- this will be allowed by compiler in C because C is weak typing, and will comeback later to bite you at runtime

{

//bla bla

}

}

Pascal code:

var

i : integer = 1;

s : string = '1';

begin

if i = s then begin //<--- this will not be allowed by compiler in Pascal because Pascal is strong typing

//bla bla

end;

end.