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

Despite the passing years, programs or some of their parts written in C remain as large as life. The code of these programs is much more subject to 64-bit errors because of less strict rules of type checking in the C language.

Yeah, because a language with 4 different typecast operators is type safe.



As far as I know, C only has one; perhaps you are thinking of C++?


I'm making fun of C++ programmers that think C++ is better than C, like the authors of this article.


The problem with C++ casting isn't that there are 4 different typecast operators. On the contrary, that allows you to more clearly state your intent to the compiler and prevent unexpected bugs. The problem with C++ casting is that they allow you to do C-style casting at all.


The C++-style casts are pretty nasty, too. Want to un-const something? const_cast it! Want to make that int * a FooObject *? reinterpret_cast it! What could go wrong!

C++ pretends to be a safe language with features like encapsulation. The problem is that it isn't. One bad strcpy later and your "encapsulated" class's data is now "HELLO WORLD\0".

C, on the other hand, makes no effort to pretend that the abstraction being offered is anything other than a big block of RAM and some functions.

(If you want a safe language, use Haskell. Notice how nobody ever needs "unsafeCoerce :: a -> b"?)




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

Search: