3 ms·
> Is it even possible for the program to know at compile-time if the types will be violated at run-time? I mean, that's kind of the whole point of static typin
by ragnese 5y ago
> Is it even possible for the program to know at compile-time if the types will be violated at run-time?
I mean, that's kind of the whole point of static typing, right?
If you're speaking to TypeScript/JavaScript, specifically, then yeah, the compiler can't guarantee anything because someone can hop into the running program and start modifying objects as they please (at least for web page code).
But the compiler could still make the weaker guarantee that "the code that I can see is soundly typed". And for 99% of us that's effectively the same thing.