Discussion about requirements and design for Program Query Languages
1. What is the general
purpose of the language? Is it information extraction, code transformation,
(i) Information extraction: specific purposes
Bug finding, code visualization, code anaylsis, code exploration/understanding.
(ii) Code transformation: specific purposes
Translation, code correction, restructuring, rephrasing, strength reduction,
2. AST (or other intermediate
representation) based, or program trace based?
(i) AST based systems can take advantage of existing compiler infrastructure for producing intermediate representations and also for generating executable code from ASTs.
(i) Trace based systems can capture execution relevant behaviour. They may, however, require large amounts of space to store trace data. Program trace based systems can be static (offline) or dynamic. Dynamic systems use runtime information to answer queries. The use of runtime information has advantages and disadvantages. One advantage: users can write unusual queries; for example, users can ask how much time elapsed between events A and B. Disadvantages include repeated executions for new queries which may have a high time cost (particularly on instrumented programs), and also the fact that dynamic execution traces are not guaranteed to be complete (A buggy execution path may occur very rarely).
3. What compiler information
Traditionally compiler information is geared towards code generation. However, some of this information can be helpful to bug finders and other users. (pointer analyses, dataflow, etc). Based on the answers to (1) Program query language developers must decide what compiler information will be used.
4. Who is the target audience?
Systems developers are not compiler experts. Compiler experts do not necessarily have system specific knowledge. Ideally, for systems developers, (as per the PQL paper) program query languages should leverage powerful compiler information and technology to aid systems developers, while at the same time not require them to be compiler experts. i.e. the query language should provide the power but hide the complexity.
5. What syntax is appropriate?
The answer to this question depends in part on answers to questions 3 and 4. Concrete syntax support (programmers can express queries in a form that is syntactically similar to the target program), provides a familiar and intuitive mechanism that tends to make queries more concise and readable.