koknat / callGraph

A multi-language tool which parses source code for function definitions and calls
GNU General Public License v3.0
245 stars 28 forks source link

Use GraphViz2 rather than GraphViz Perl module? #24

Open mohawk2 opened 7 months ago

mohawk2 commented 7 months ago

I just learned of this project today, and it's really cool!

Thought you'd be interested to know of the GraphViz2 module, which may make things easier/better in this script. Example usage:

From https://github.com/PDLPorters/pdl/blob/master/perldl#L335-L338:

  my $g = PDL::Core::pdumpgraph(PDL::Core::pdumphash($pdl));
  require GraphViz2;
  my $gv = GraphViz2->from_graph(PDL::Core::pdumpgraphvizify($g));
  $gv->run(format => $format, output_file => $file);

The general idiom is you make a Graph object, then annotate it (e.g. with a graphvizify procedure such as https://github.com/PDLPorters/pdl/blob/ac270e21cafeda8726dd64fa4b90e4a6e686c8c2/Basic/Core/Core.pm#L2394-L2439), then GraphViz2 can run with it.

koknat commented 7 months ago

Hi @mohawk2 Thanks for the feedback! I had considered moving from GraphViz to GraphViz2, but chose not to because of the additional Perl dependencies (Moo and 5.8.8 vs 5.6.0). My assumption is that the more steps are needed to install 'callGraph', the fewer people will spend the effort to install it. Installation of the Moo dependency is trivial for those of us experienced with Perl, but since callGraph supports many languages, most users may be completely new to Perl. For the same reason, I designed the callGraph code as a monolith, as it's then easier for a user to copy between machines or give to a friend

mohawk2 commented 5 months ago

Zooming out a bit, I think you'll struggle to find any Perls installed anywhere that are <5.8.8 (released ~20 years ago). Even if you decide to stick with GraphViz, you could eliminate a step for users by using https://metacpan.org/dist/App-FatPacker to package everything into one file. That would then also work with GraphViz2, albeit the file would be bigger.