TI [Type Inference] is a feature in the SpiderMonkey Javascript engine which generates type information about Javascript programs through a combination of analyzing the program’s code and monitoring the types of values as the program executes.Related talk: “JavaScript JITs” by David Mandelin and David Anderson at JSConf.eu 2011.
...
With these projects, ... we hope to close the performance gap with Java completely.
2011-11-23
Type inference to make JavaScript as fast as statically typed languages?
Labels:
dev,
firefox,
javascript,
jsengine
“Type Inference brings JS improvements to Firefox Beta” by Brian Hackett:
Subscribe to:
Post Comments (Atom)
6 comments:
> close the performance gap with Java completely.
Is that possible?
It's like saying that InvokeDynamic will always be as fast as normal method invocation in the JVM...
Also performance is just one of the advantages of static typing.
But the main one is code maintenability.
(Probably that's why DART static typing is only used at compile type, not at runtime.)
“It's like saying that InvokeDynamic will always be as fast as normal method invocation in the JVM...”
InvokeDynamic helps the JVM with programs that have many dynamic aspects, type inference helps JavaScript engines with programs that have many static aspects.
“But the main one is code maintenability.” There are also experiments under way to use type inference in IDEs, to compute a method’s signature. Current results seem to be promising. Guards have been proposed for JavaScript (after ECMAScript.next) and will work much like Dart’s optional types:
http://wiki.ecmascript.org/doku.php?id=strawman:guards
“Probably that's why DART static typing is only used at compile type, not at runtime.” I do wonder why Dart doesn’t do that, I’d expect them to get performance advantages. You can use the type information as checks during runtime, but the compiler indeed ignores it. I suspect, though, that Dart profits from the shape of an object being immutable. AFAIK, Dart is still slower than V8, but its creators expect it to eventually be faster.
I see no reason not to believe them. Take away the type information from Java and it is not that different from JavaScript (for most programs). Thus, if type inference allows you to detect type information...
Yes, 'optional types' in JS would be _very_ useful.
Maybe with compatibility with old browsers with a tool like Mascara.
I think DART doesn't use static types at runtime because it makes this langage easier to translate to classic Javascript (and static typing is more important than raw perf for Google, at least on modern browser JS VM).
So I would prefer a translator:
Modern Javascript (with opt typing,...) --> old Javascript translator
rather than
DART (or Java, CoffeeScript,...) --> old Javascript translator
Me, too. There is Google’s Traceur, but from what I’ve heard, it has been mostly abandoned: http://www.2ality.com/2011/05/googles-traceur-compile-ecmascriptnext.html
Post a Comment