135 points · by nothrowaways · 4y ago · 17 comments
Since this program just walks the statically apparent callgraph, you'll get an under-approximation of the behavior of your program. If you'd like an over-approximation, something like control-flow analysis can handle cases with anonymous functions. [^1] [^2] [^3] There are still some limitations, but CFA is really powerful.
(Anyone curious can contact me (see my blog) if you want more information on CFA.)
[^1]: https://lambdaland.org/posts/2021-05-20_cfa/
[^2]: https://en.wikipedia.org/wiki/Control_flow_analysis
[^3]: https://www.ccs.neu.edu/home/shivers/papers/pldi88.pdf
The next thing that would be great is hyperlinks to the source code from each node in the graph
It's worth noting that it's impossible in the general case to generate a perfect callgraph for static languages as well. Function pointers in C are the obvious example, but more generally anything that converts control-flow into data-flow (like a dispatch table) causes the same problem.
Also, I suspect there's going to be a correlation between a preference for spatial vs. lexical reasoning and a preference for visual vs. textual development.
That might be superior, if done right.
On the surface - there is a difference in languages. Sourcetrail explicitly supports C/C++/Java/Python while Code2flow supports Python/JS/PHP/Ruby.
I would love to give code2flow the capability of Sourcetrail but would need to feel very good about it making money before I devoted that time to it.