Live data from Hacker News

Ask HN: Why aren't code diagram generating tools more common?

news.ycombinator.com

91–100 of 112 posts

Re: Ask HN: Why aren't code diagram generating tools more common?

#91
> - Why isn't diagram generation automated as part of the build process (UML or otherwise)?

This is very hard. And since it's hard, it's not automated. And since it's not automated, it goes out of date very quickly. I think that's the fundamental issue: keeping around evergreen documentation is a lot of overhead. There is no connection between the code and the diagrams, so it's too easy to change the code and not realize that the diagram needs to be updated too.

Another thing is that it's really the most useful for new members. If you've been working on the infra for a while, you already know the structure and you don't need the diagram. So teams tend to just avoid the diagrams altogether.

Re: Ask HN: Why aren't code diagram generating tools more common?

#93
They can't even really diagram databases effectively, and that's "just" data.

Maybe you'd need a three dimensional model (really it's likely n-dimensional/hyperdimensional), 2D might not be enough.

Programming models get so convoluted with regards to state and interactions, both in-memory/in-process state and the stored state in databases/files.

Jurassic Park's 3D filesystem was a pie in the sky idea, what, 30 years ago? Holy crap it was 29 years ago or so. We've had REVOLUTIONS in 3D processing and games, and never even stratched the surface of basic 3D visualizations of code or data or filesystems or machine networks or the like.

And then even if you represent a diagram, it's useless without time visualization/traces, as kind of referred to by the RR debugger post. So for active code, you'd need simulation or actual run data to show what it does visually to be effective.

Really what's being dealt with here is probably related to theory of computation, and various results like the undecidability of the halting problem. The halting problem shows that even for very basic languages that are minimally Turing complete, the complexity shoots VERY QUICKLY to massive degrees of infinity/uncomputability.

So some catch-all visualizer for even general classes of Turing complete languages is probably impossible.

Maybe something like "this is a java spring app with well regimented separationg of data/domain classes and service classes"...

Even then once you get to database persistence ... wow.

And the amount of data you'd need to store for test runs.

Spring + TDD enforces a certain simplicity to a codebase, so perhaps you could make effective classes of visualization and tracing/replay visualization for that.

But it is telling these tools don't really exist, and attempts like UML were largely abandoned.

Re: Ask HN: Why aren't code diagram generating tools more common?

#94

I think UML (etc...) was one of those things that look great on the surface but once you start diving deeper all the problems hidden under the surface become overwhelming. If a thing has been tried many times in the past and even with a lot of money thrown at it, yet it still disappeared into obscurity, then it's a pretty good sign that the idea wasn't great to begin with. In practice it's the same problem as "noodle…

It's hard because programming is hard :-). I still believe UML is great, but the difficulty is to make the diagrams so precise that they convey crucial understanding, yet so abstract that they hide as much detail as possible.

That is nontrivial, and it is very hard to do well. But it is also the essential job necessary when designing software and then communicating the essence of that design.

My favourite tool btw is plantuml. It lets you describe diagrams (class, sequence, deployment) with text/algebra. Plantuml works well up to a point where the diagrams becomes to complex for the layout algorithm to do well.

I used to think of this as an annoyance, but now I think of it as a feature: It is a way for the universe to tell me that the model is becoming too complex. The layout algorithm serves as a proxy for everyone else that should parse the diagram, and if I can make the diagram better by simplifying, so be it.

Now, a human can do diagram layout better than plantuml, so a human can easily concoct diagrams that are both more complex and better looking than plantuml, but it is my firm belief that this usually not a good thing: It more often than not means that the message is lost in the complexity of the diagram.

Keep it simple!

Re: Ask HN: Why aren't code diagram generating tools more common?

#95
A while back I did a demo and wanted a diagram to show what was going on. I stumbled on http://www.plantuml.com which did exactly what I wanted: it took mark up and turned it into an image that could be embedded in a github markdown document.

That said, diagrams can either be rare, focused, and useful; or common, unfocused, and distracting. Automated processes tend to generate the latter.

Re: Ask HN: Why aren't code diagram generating tools more common?

#96
post #90

Because no one has created a good enough one yet. Maybe you can. I am in desperate need for something like that and often just write diagrams on a piece of paper for code paths I am trying to understand or debug. Many things were just ideas for decades until someone figured out the right way to do it. This is one of them. You'll know you're close when coding with the diagram is faster/better/easier than without.

Not sure which language you need, but I worked on a tool called Codemap that visualizes any Javascript/Python codebase. I also made a Hacker News post which may be interesting to you. - Codemap https://codemap.app - HN post https://news.ycombinator.com/item?id=24241998

Let me know if that works in your scenario :)

Re: Ask HN: Why aren't code diagram generating tools more common?

#97

At one time I had a diagram of our database schema. Every table with its columns and data types was in its own now with arrows indicating foreign key relationships. Each table was color coded and then then grouped into related areas of concern (user tables over here, retailer tables over there, etc.) We had our print shop print it out at the largest size they could (about 3x5 feet) and hung it on the wall. We referre…

Full ERDs have always been more valuable to me in the making than in the having largely for that reason. But I've gotten a lot of mileage out of generating ephemeral slices of the foreign key graph from the "viewpoint" of a given table, as here: https://di.nmfay.com/exploring-databases-visually

Re: Ask HN: Why aren't code diagram generating tools more common?

#98
post #28

I’ve had this need a few times. Just a couple weeks ago I needed to quickly understand the set of package dependencies within a codebase and wrote some scripts that extracted a report as well as a graphviz file. I’ve done that a few times over the years. The biggest obstacle to a general purpose tool usually is the compiler front end that is needed to correctly parse the code to get the entities and relations you nee…

I agree that dependency graphs are the way to go - they show the structure of the code better than anything else. And yes, the problem is that the graphs show all of the details, whether they are important for gaining a good, overall picture of the system or not.

What you need is the ability to filter the graph. Narwhal and the nx mono-repo toolset has a pretty cool dependency graph feature built in. Here's a video of how they use it:

https://youtu.be/KTGKpoiLE0k?t=253

Re: Ask HN: Why aren't code diagram generating tools more common?

#99
If there was software for automated code diagramming to help me quickly wrap my head around a new codebase, I would buy it instantly (assuming it was licensed like, say, Sublime Text and not like Adobe Creative Cloud).

I keep bookmarking threads like this one, but I haven't found anything useful for me. The closest one was SourceTrail, which is unfortunately not developed anymore.

With so much hiring and onboarding going on, I am surprised there isn't a market (or an offering) for such tools.

Re: Ask HN: Why aren't code diagram generating tools more common?

#100

> - Why isn't diagram generation automated as part of the build process (UML or otherwise)? This is very hard. And since it's hard, it's not automated. And since it's not automated, it goes out of date very quickly. I think that's the fundamental issue: keeping around evergreen documentation is a lot of overhead. There is no connection between the code and the diagrams, so it's too easy to change the code and not rea…

Completely agree. And what ends up happening is that when generating diagrams doesn't turn into tradition, it does end up being forgotten and contributes to more time spent by members in understanding the entire codebase. I find it hard to believe that there isn't a tool that is being built for this though so I know we'll eventually have it.
Post reply on HN