News for hackers. Stuff that matters.
Re:JavaScript's sweet spot by ender7 on Sunday November 06, 2011 @03:55PM (#3203805)
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.
Re:JavaScript's sweet spot by mraleph on Sunday November 06, 2011 @04:31PM (#3203909)
It 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.