Domanda

Quoting from this academic paper: Syntactic and Semantic Prediction in Dynamic Languages:

IntelliSense is practically based on the knowledge of variables type. Hence the symbols describing variables have to contain their type if it's known and if it could be resolved Moreover in dynamic languages one variable can carry different type instance in different parts of the code and in different program executions. Also the variable can be initiated dynamically, and its type can be known only at runtime. Therefore the symbol should contain some list of possible types resolved within semantic analysis. But in general it cannot be resolved definitely in dynamic languages; even single program execution won't help.

Where can I find more resources on this, I am interested especially on the emphasized statements in the above block-quote, eventually some statistics on the rate of prediction on static analysis of code.

È stato utile?

Soluzione

What this says is essentially the famous Turing incomputability result: in general, you can't know the answer to what a computation does (or generates as a type).

While this is true in general, it says nothing about specific circumstances. A little thought should convince you that if programmers didn't have some idea what the type of some identifier was, they probably couldn't write any code that used it. So the original coders know (unless they wrote buggy code). But they know by making assumptions about the rest of the system, and then enforcing those assumptions (often elsewhere).

A static analyzer doesn't know what assumptions the programmers made, so it can't be as precise. But in many specific circumstances a static analysis can infer the type. The question is, how much of the code does it have, and can it interpret that code using the deep semantics that make the languages behind the code?

I'm always bothered by the concept that "analyzers can't be (as) good (as humans)". If an analyzer has access to the same information the human has, it should be at least as good, and often better; it can keep track of interactions in ways people cannot. More importantly, if the static analyzer hasn't got access to key assumptions behind your code, how can you expect other programmers to work on that code? What a proiri reason exists that insists they know all the background/assumptions used in some block of code?

So I think much of the limitation of static analyzers, even applied to dynamic languages, is caused by our unwillingness or inability to write down the assumptions that we use when we write the code. (After that, there's the problem of the energy to engineer a suitably strong analyzer).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top