Hacker News new | ask | show | jobs
by quietbritishjim 1064 days ago
I can highly recommend PlantUML as a simple language for creating sequence diagrams. It also supports other UML diagram types, which, despite what the article says, are also useful sometimes (so long as you don't worry about every last silly detail that's specified in the standard).

   @startuml
   Alice -> Bob: Authentication Request
   Bob --> Alice: Authentication Response

   Alice -> Bob: Another authentication Request
   Alice <-- Bob: Another authentication Response
   @enduml
https://plantuml.com/sequence-diagram
11 comments

I would like if PlantUML would be implemented in some lighter language. JVM size and startup time is atrocious. You can easily notice latency caused by it even on modern hardware when rendering diagrams locally. In CI/CD it takes too much time to install JRE and run PlantUML. Probably, I can optimize it to some extent, but if it were implemented in another language, I wouldn't have to spend my time on it. Everything Java related is a monstrosity in size and consumed resources (CPU, RAM).
I believe PlantUML was basically the inspiration for MermaidJS. A huge advantage of MermaidJS is that it can run in the browser, though.
And if you start a markdown codeblock like

    ```mermaid
    graph TD;
      A-->B
    ```
Many things that support markdown (e.g. github, gitlab, typora, ...) will render the resulting graph.
That features is also a feature Mermaid/Markdown renderers have borrowed from existing uses of PlantUML. You've been able to embed PlantUML in a Markdown block in Gitlab (and have it rendered inline as an image) since before MermaidJS ever existed. Github's embedded MermaidJS feature is years late.
unfortunately, you need a PlanetUML server when using a self hosted gitlab install.

running directly in the browser is, imho, the best feature of mermaidjs

https://sequencediagram.org/ is the best sequence diagram tool like that. It does diagram-to-text to if you draw a line etc with mouse. Can right click and have context options too.
That looks nice but it's a shame that it uses its own proprietary language (not PlatUML or MermaidJS) and the code isn't even available. So if you use it then you have to cross your fingers that the website continues to be available otherwise your diagrams will suddenly become unmaintainable.
More examples of sequence diagrams with PlantUML, with renderings of dividers, actors, databases, etc.:

https://github.com/joelparkerhenderson/plantuml-examples

Checkout kroki as well which is collection of various tools including plantuml, tikz, mermaidjs, graphvi etc.

As a bonus, niolesk is a very good frontend on top of kroki. You get an editable link of your diagram which you can share with teammates.

You can find docker image on github running kroki and niolesk.

I came to say the same thing; kroki is the powertool of choice in this space.
It does look nice, and covers most things, except for life lines. Is there a way to add life lines?

And why do so many tools choose to ignore life lines and provide incomplete sequence diagrams? Perhaps it gets really complicated to express in such a simple way as the examples do?

It has those! They're under "Lifeline Activation and Destruction" on that page:

https://plantuml.com/sequence-diagram#5cc0040514e70f7b

You can even have two active on the same lane at the same time, as shown in the second example on that page.

I've used PlantUML. It's very nice.

However, it gets to be difficult to use if you've got complicated scenarios. It's very difficult to depict parallelism with PlantUML.

+1 for Plantuml. It has a great ecosystem, but there are certainly tradeoffs vs using mermaidjs, because of their different compilation models. Mermaidjs seems to look nicer out of the box as well, but usually that's not the point for a sequence diagram.

I'd use whichever works for your ecosystem and diagram lifecycle. The syntax is similar enough that I think the diagram creation constraints are often a bigger difference.

PlantUML also has a nice library for C4 model diagrams available [0], which I've found very useful.

[0] https://github.com/plantuml-stdlib/C4-PlantUML

This is my go to diagramming tool. It takes a lot of little tricks to get things to turn out exactly how you want, but they're not required. It communicates information just fine. The tricks are only required if you care about aesthetics.
Cool, I'll check it out.