Live data from Hacker News

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

news.ycombinator.com

41–50 of 112 posts

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

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

I vaguely recall Visual Studio has this option where you can generate some sort of class diagram. It looked like shit the last time I used it (~2019) especially as your classes get more and more functions built into it. I also can't imagine how shitty it looks for codebases that have a significant coupling problem.

Furthermore, creating a UML diagram is a documentation process rather than something that should be automatically built in. I put it on the same level as writing a document in a word doc or something that's done as the project gets closer to being finished. Some places can live with it, a lot of places (actual software companies) probably do not as they move unreasonably fast (Agile) which does not even allow time for documentation or they just purposely neglect documentation.

> Why aren't code visualization tools more popular? The options out there seem outdated

Because they look like shit. I tried mermaid with markdown, I was not happy with the results, I tried plantUML back in 2019, I hated how it ended up looking, I hated how I have to install java for it, and I gave up on it pretty quickly.

The only code visualization tool I ever use is either draw.io or MS Visio. At lease there's a plugin for that for VS Code.

> Would you want to use these tools? What would be your ideal tool?

Markdown with vim option. It also must have an option to force a top-down flow approach and not freaking forcing it to be a left-right layout

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

#42

because a code diagram is no different than reading the actual code, it'll be just as confusing. the learning occurs when you create the diagram yourself.

The diagram can also be a view into the thoughts and motivations behind the implementation. Which can help the next programmer know the design and why certain design decisions were made.

But not everyone thinks about designs as 2-D pictures. I'd argue there's selection pressure that favors programmers being good spellers and symbol-manipulators. Some people find it intuitive to think of concepts as boxes and the relationships between those concepts as lines. Or maybe to think of a 2-D grid of actions/dependencies with deliverables on the vertical axis and work-steps on the horizontal.

But not everyone likes these kinds of visualizations. Some prefer a text-based description. And some designs don't fit any obvious pictorial representation.

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

#43
We have scripts that generate textual diagrams as part of our CI process (mermaid or PlantUML, depending on the case), so our Markdown documentation files (e.g. README.md) always have up-to-date diagrams and people don't have to complain "why did no one update this diagram in 6 months".

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

#44
post #12

Even a few very basic UML diagrams (Use Cases, Class, Sequence) can form a very effective introduction to a system. I feel that people have just embraced Agile blindly and simply forgot about basic modelling.

Absolutely this! Communication of design is an enormous gap that has emerged in the last could of decades.

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

#46
I am trying to answer a lot of these questions based on the idea of software literacy - so do we understand books using diagrams connecting pages and paragraphs? No, maybe concepts, maybe characters, but in the main any diagram involving time plus more than one other dimension has never been successfully written in a flat piece of paper.

Edit: another way of thinking about time is mutability so perhaps functional languages are more amenable to graphing.

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

#47
I'd say the question was "solved" by Prograph CPX in the 1990s, except the diagram WAS the code.

https://www.google.com/search?q=Prograph+CPX&rlz=1C5CHFA_enG...

You'd have high level classes, and low-level nitty gritty. You could edit your code as it was running (and then continue).

People prefer text (weirdly).

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

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

It's another thing that can break, another element that needs to be maintained. In my experience there are very few pieces of code that will be able to run indefinitely without ever being updated, fixed, or re-examined at some point. The cost of adding more processes is not one-time, and it can be difficult to figure out what the time bounds are.

- Why aren't code visualization tools more popular? The options out there seem outdated

People who are interested in the structure of code are typically engineers, capable of writing and reading the codebase of interest. A UML diagram may be a way to understand an element of the system, but things such as in-line comments in the codebase itself are often more instructive on structure and function.

- Would you want to use these tools? What would be your ideal tool?

When I was in high school, if I didn't want to read, say Crime & Punishment, I could buy the Cliff's Notes version, and get a chapter-by-chapter summary of major characters, events, and literary techniques. In many ways, it contained all of the information of the book without the substance.

But importantly, it took significantly less time to read and fully process than the book, while being written in the same language. In code, it is already extremely easy to look thru header files, or collapse every function in your IDE to get a high-level overview of what data and methods exist. You can then dive in immediately to anything you would like to understand better ("what does 'UpdateSignificanceValue' really mean") and there's no mental overhead in translating from an encoded diagram into whatever your mental model is. This is why I do not personally see value in code visualization -- outside of notes I take that are relevant to any specific problem I am working on.

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

#49
Diagram generation is plagued by the same problems as the "Rational Rose" fantasy of automatic code generation from diagrams: trivial applications are trivial to diagram, and non-trivial ones defy it, as the complexity (dependencies tend to form dense, multiply connected graphs in these applications) quickly outstrips any straightforward mapping to a visual representation.

I wouldn't use these tools anyway, to be honest. They have some limited utility when constrained to small components/parts of an application (e.g., self-contained libraries), but for understanding systems as a whole there is too much to have effective reverse-engineering into a visualization (in my opinion).

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

#50
post #33

Earlier quoted context omitted.

I really enjoy(ed) using c4. Still need to figure out how to protect against screenshots though!

Protect against screenshots? Could you elaborate please

I believe the parent commentator is referring to how screenshots of a diagram generated at build or runtime are almost always out of date.

It’s better to generate a diagram as needed than to archive an outdated artifact that could lead to confusion.

Post reply on HN