Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: