Open AndrewHuffman opened 10 years ago
Honestly, I have never been completely sure about how to tell if a language is strong or weakly typed. And from the looks of some searching, it is a hard concept for everyone.
There's some contention about the issue. For some languages there seems to be a consensus (Haskell is strongly typed, PHP is weakly typed). For my part, I think any language with what amounts to void pointers (e.g. C, ObjC, dynamic languages) must be considered weakly typed in general. Some would argue that a language with nullable variables (Java) is weakly typed as well.
In any case, it's clearly wrong that * is a magic identifier that makes things strongly typed in Objective-C. It's probably best to pull out any business about strong or weak typing and just say what it is. Of course, I'm not really qualified to do it. Does anyone know if id
is effectively the same as void *
?
weakly typed => has implicit conversions and "Object"-like (or void *
-like) objects.
strongly typed => doesn't.
Then there's just statically vs dynamically typed, which is very different, but nicely summed up here.
I would agree that given the ambiguity of what is meant by "weakly" vs "strongly" typed it would make sense to remove references to those terms and more explicitly describe what is occurring here.
There's some differences between id
and void *
, namely how the GC handles them and that id
has some advantages that prevent runtime errors.
@AndrewHuffman, when you have a moment, you can go ahead and implement the changes you wish on the file and make a PR for it!
The page states the following:
However, this is misleading if not completely incorrect. The
*
is the same as it is in C, it means it's the variable is a pointer. It's not clear what is meant by 'strong' or 'weak' typing here, but it's my understanding that, like C, Objective-C is a weakly-typed language (though statically enforced at compile-time).Rather, I think what is being said here is that
myObject
is referencing an explicit (statically-checked) object of typeMyClass
whilemyObject2
is referencing any Objective-C object.I would fix this myself, but I'm just learning the language and would prefer to defer to someone with more expertise.