4 ms·
It was my understanding that most/all of this unsoundness can be removed by telling the compiler to disallow a bunch of stuff using command line args, is this s
by tbrowbdidnso 10y ago
It was my understanding that most/all of this unsoundness can be removed by telling the compiler to disallow a bunch of stuff using command line args, is this still not the case?
Also even if you can't statically determine the types of some variables typescript seems to be able to determine it for most. If most of the objects are statically known would it give you a large part of the speed up of a totally static system? In Java and C# there's still some intentional holes in the type systems like the dynamic keyword or casting to object
- the_duke 10y agoAll of this is not really relevant for TypeScript, as it just transpiles to Javascript and ends up running on the used Javascript VM. Sure, sometimes you might be able to generate more efficient code by tailoring the emitted Javascript to the VM behaviour or using something like typed arrays for low level operations, but if the target language doesn't have support for certain things like type hinting, there is not much that could be gained.
- munificent 10y ago> It was my understanding that most/all of this unsoundness can be removed by telling the compiler to disallow a bunch of stuff using command line args, is this still not the case? Nope, it's never been the case, even with all the flags on. It's not about implicit casts, it's about soundness in the actual type rules. Here's an example: function append(array: Array<Object>) { array.push("not a number"); } var nums: Array<number> = []; append(nums); console.log(nums[0].toFixed()); If you run this, it throws an exception because String does not have a "toFixed()" method. > If most of the objects are statically known would it give you a large part of the speed up of a totally static system? Maybe, but it's hard to say. Once you have a single hole, if you can't check it at runtime right at the hole, then values of the wrong type can spread anywhere in the program. > In Java and C# there's still some intentional holes in the type systems like the dynamic keyword or casting to object Right. In the above example, Java and C# would throw an exception when you added the string to the array. This check has some runtime cost, but works. I believe TypeScript is also unsound around function types, which is harder to address because there's no easy place to know where to add the check.