3 ms·
What kind of performance increases could we see if we simply added type annotations to Javascript? Would this give the VMs a significant boost? Something like
by ender7 15y ago
What kind of performance increases could we see if we simply added type annotations to Javascript? Would this give the VMs a significant boost?
Something like AS3 (Harmony) syntax:
var foo:int = 3;
var bar:string = "A nice string";
var baz:Array = ["a", "polymorphous", 4, "array"];
var v:Array.<int> = [2,3,4];
function f(a:int, b:string):string {
return a + " " + b;
}
Sidenote: I really want someone to write a Coffeescript compiler that supports type annotations like the above. It can strip them out when it compiles the code; I just want it to yell at me if I violate one of my declared types.
- mraleph 15y agoIt really depends on the semantics of those annotations. For example: how is v:Array.<int> enforced (and is it enforced at all)? Type annotations can be a good to seed type inference analysis or adjust collected type feedback. But unless they guarantee stability of objects shapes (e.g. Array.<float> can contain only floating point numbers) they'll give little.