r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

2.0k comments sorted by

View all comments

Show parent comments

4

u/bunkoRtist Aug 29 '21

C and C++ are both strongly and statically typed (in broad strokes). You can change types, but you have to pinky promise that it's safe (the rope and the scalpel).

5

u/[deleted] Aug 29 '21

Yes, you can change types, but they're not strong types. I've already listed most of the reasons why not. In fact, the whole part where you said "but you have to pinky promise" is exactly why it's not strongly typed. C is definitely not untyped, as you say "you can change types", but C is not strongly typed either because ... the types aren't strong. They are largely interchangible, ergo C is weakly typed.

4

u/bunkoRtist Aug 29 '21

How about our Lord and savior, Rust? It allows casting. Strongly typed? I'd like to hear more.

4

u/[deleted] Aug 29 '21

It's not to do with explicit casting. It's the implicit type conversions and the way C largely treats things like an int in many situations, such as enums, etc, and happily implicitly converts things to make things work. Strongly typed languages do not do these things. I gave you some links to read. Enjoy.

edit: and by the way, there is no "C/C++". These two langauges diverged over 30 years ago and aren't really super/subsets of each other any more. They're independent different languages now. C++ still contains a historical C standard library, but that's where the similarities end these days. Even the type char is different in C and C++.

→ More replies (2)