Guessing what may be: Static Analysis of Dynamic Languages
In cooperation with our research partners in academia, we offered a bachelor thesis in the field of program analysis.
The recently finished thesis of a Bachelor student who was supervised by Axivion investigated static analysis of Python programs by creating a program dependency graph. Features like "late bound everything", "monkey patching", missing entry points or the fact that "everything is a mutable object" pose a challenge in static modelling of dependencies and make it hard or impossible to create an exact dependency graph.
Anyway, a useful approximation of the program structure of Python code can still be easily achieved if we make the assumption that runtime modification of the code is possible but not the first thing programmer's think about when coding. With this assumption in mind, a full analysis of Python projects was build based on Python's AST module and Axivion Suite's API and GUI in less than three months.
The fun part of this thesis was the iterative and incremental approach allowing visual feedback to the student by using Axivion's extensible GUI. As soon as the implementation of the first bits of the parser were ready, the results could be visualized and inspected. And by implementing the static analysis itself in Python, continuous self-application was possible... "if it is worth doing it, do it to itself".
The performance of the basic analysis steps was surprisingly good. Even though it is an interpreted language, it takes just minutes to analyze the entire Python Standard Libraries. First impressions on the software erosion aspects show that architecture analysis, dead code, or cycle detections in Python programs were successful and also give insights to Python programmers.
We are looking forward in evaluating and extending the prototype and analysing Python code in the future.
And of course - looking forward to the future thesis' results.
To get more insights into my work at Axivion, register for our newsletter, visit our blog or follow us on LinkedIn and Twitter.
Consultant - Helping engineers to efficiently monitor theirs projects
4 年Really interesting ! I would be interested to try this on my own python code !
we are stopping software erosion
4 年Beeindruckend, wie ihr das in so kurzer Zeit hinbekommen habt. Bin schon gespannt, was für tolle Projekte noch kommen werden, die auch immer unsere Produktentwicklung bereichern und inspirieren. Weiter so!