IDE support?

Brendan Eich brendan at mozilla.com
Mon Sep 12 06:47:14 PDT 2011


On Sep 12, 2011, at 12:51 AM, Peter van der Zee wrote:

> On Mon, Sep 12, 2011 at 1:04 AM, Brendan Eich <brendan at mozilla.com> wrote:
>> Type Inference can do a lot. See http://doctorjs.org/.
>> 
>> We do not want people adding guards all over their code, IMHO. Anyway, we don't know have guards ES6.
> 
> While true, I've found that you can't really overcome the dynamic
> property access unless you can somehow infer that you're operating on
> an array of some fixed type or something like that.

Have you tried pasting code into DoctorJS? It infers monomorphic array types, parameter types, return types. It's a global analysis.

For example, on SunSpider's crypto-aes.js, DoctorJS figures out that

13: Cipher : function(Array[number], Array[Array[number]]) → Array[number]

given

function Cipher(input, w) {    // main Cipher function [§5.1]
 ...
}

Neat, eh?

Yes, eval and other dynamic code loading facilities require re-analysis. So a tool will have to use hybrid or JIT techniques. Still doable.


> And function calls
> and result types are actually far more difficult (though not
> completely impossible)

The difficulty is a challenge to the IDE implementor, not to all JS hackers to annotate their function signatures.

With Flash and AS3, developers over-rotated and annotated everything. Of course AS3 lacks inference of even a local or inside-function-only kind. But really, the IDE developers can take one for the team, IMHO.

/be


> to do in es than in a strongly typed language.
> Although I don't really see any clear way of getting around this,
> without some kind of annotation (be it in the language or in
> comments).
> 
> - peter



More information about the es-discuss mailing list