4 ms·
What does "strong" mean as regards typing. I've heard a few different definitions so I'm curious what yours is in the context of this article.
by 1-more 3y ago
What does "strong" mean as regards typing. I've heard a few different definitions so I'm curious what yours is in the context of this article.
- bigstrat2003 3y agoAs far as I'm aware, the generally accepted definition of strong typing is: some object in memory has a type, and the compiler (or interpreter) will not let you treat it as another type without some kind of explicit instruction to do so. This is in contrast to weak typing, where the compiler/interpreter will happily try to treat a Bar object as a Foo object if you do some Foo operation on it.
- gpderetta 3y agoThat's the definition of type-safety (or memory safety that is pretty much equivalent). "strong typing" has no generally accepted definition.
- bigstrat2003 3y agoMemory safety is definitely not equivalent. Memory safety is more like not going past the end of an array, not doing use after free, etc. I agree that what I said is pretty much also the definition of type safety. But in my experience it is also the generally accepted definition of strong typing.
- 1-more 3y agoThat seems to be a subset of static typing. Is there an example of this that does not involve non-static typing?
- bigstrat2003 3y agoI think you mean "involves non-static typing"? If so, Python. You can't (for example) do something like '1 + "2"', because those types aren't compatible. It's dynamically, but strongly, typed.