Live data from Hacker News

Create system diagrams with Go

github.com

41–50 of 70 posts

Re: Create system diagrams with Go

#41
I love the simplicity for K8s diagrams, this is a neat tool.

package main import ( "log"

"github.com/blushft/go-diagrams/diagram" "github.com/blushft/go-diagrams/nodes/k8s" )

func main() { d, err := diagram.New( diagram.Label("Kubernetes"), diagram.Filename("k8s"), diagram.Direction("TB"), ) if err != nil { log.Fatal(err) }

ingress := k8s.Network.Ing(diagram.NodeLabel("nginx")) svc := k8s.Network.Svc(diagram.NodeLabel("http"))

d.Connect(ingress, svc)

g := diagram.NewGroup("pods").Label("Deployment").Connect(svc, k8s.Compute.Pod(diagram.NodeLabel("web server")))

d.Group(g)

if err := d.Render(); err != nil { log.Fatal(err) } }

Re: Create system diagrams with Go

#42
post #10

For someone who doesn’t care language, what’s the difference between this and the original diagrams tool?

I probably wouldn't use this tool often enough to memorize the API, in which case the type checking and autocomplete that a typed language like Go enables could come in handy

Re: Create system diagrams with Go

#43

Very nice, but IMHO this should be the engine behind a file that could easily be parsed such as YML / JSON. I really don't see the point in having to write a Go snippet to describe the architecture: in the end you're providing only data as an input. I guess I'll try to do what I just described because I feel like this could have a lot of potential for my system diagrams

Given that this uses Graphviz, you may as well just write you diagram using that if you want something declarative.

Without the added value of good quality PNGs that you'll have to add yourself (:

Re: Create system diagrams with Go

#44
post #31

Go-Diagrams is a Golang port of diagrams [1], an Internal DSL for Python. Diagrams (the name of a software project) models cloud IaaS resources as network graphs and exports DOT [2] files that can be processed by Graphviz compatible tools. Neither Python nor Go are ideal languages for implementing an Internal DSL, compared to say Ruby or Groovy, so the first question is why an Internal DSL vs. the DOT language (or an…

I'm not sure if you've ever tried to maintain diagarms in plantuml or dot, but it becomes difficult over time to keep them up to date.

I haven't used Python or Go diagrams but I have been a big user of plantuml for over a decade now. Off the top of my head, here are the main logistical problems with it:

  * It sits on its own
  * Hard to "share" metadata
  * Difficult to manipulate once put into the DSL
  * PlantUML has 12 different languages in one tool
I took a look at Python diagrams and a light bulb went off. Something that would make it so much easier for _everyone_ to contribute. Most people don't want to use PlantUML. But a DSL in Python? Could pay dividends.

I will seriously consider Python diagrams for my next project.

Re: Create system diagrams with Go

#45
post #39
post #32

Earlier quoted context omitted.

Curious, what's wrong with graphviz?

I was thinking about writing a markdown extension that would render a code block into an image using this and this extra system dependency is also what turned me off. It's just an extra roadblock for users and whole block of extra instructions for each platform that users have to figure out. It would be better if it would just work out of the box.

Your extension idea sounds similar to this that was posted yesterday:

Pikchr: Documentation https://pikchr.org/home/doc/trunk/homepage.md

Pikchr – PIC-like markup language for diagrams in technical documentation | Hacker News https://news.ycombinator.com/item?id=24601971

I don't know if you're referring to Go or GraphViz as the extra dependency (or both). It looks like Pikchr doesn't have any external dependencies, it's just a C library.

Re: Create system diagrams with Go

#46

Every time I have to create a diagram I struggle. If I want something quick and dirty the options are out there. But if I want to create a diagram for a serious project, I have trouble. Ideally, I would love a solution that integrated with templates and allowed me to define my diagrams at a "higher-level". It should also integrate with Latex to look consistent. Does anyone know of a better alternative to TikZ for my…

PlantUML may be of interest for some kinds of diagrams.

https://plantuml.com/

Re: Create system diagrams with Go

#47
What's the benefit of coding a visual diagram over drawing it?

I was at first thinking of automated verification rules that force your diagram to commute over a set of rules you specify but even drawing tools can specify this.

Any people who diagram a lot have an opinion on this?

Re: Create system diagrams with Go

#48
post #31

Go-Diagrams is a Golang port of diagrams [1], an Internal DSL for Python. Diagrams (the name of a software project) models cloud IaaS resources as network graphs and exports DOT [2] files that can be processed by Graphviz compatible tools. Neither Python nor Go are ideal languages for implementing an Internal DSL, compared to say Ruby or Groovy, so the first question is why an Internal DSL vs. the DOT language (or an…

Simple DSLs are sort of Haskell's bread and butter, I'm actually somewhat surprised there isn't a decent flowchart DSL in Haskell (I know about https://diagrams.github.io/gallery.html, but it didn't seem straightforward enough to get a simple flowchart going).

Re: Create system diagrams with Go

#49

What's the benefit of coding a visual diagram over drawing it? I was at first thinking of automated verification rules that force your diagram to commute over a set of rules you specify but even drawing tools can specify this. Any people who diagram a lot have an opinion on this?

It depends. When I have a good idea of what I want to draw, and I want to put it in a document, I like to use TiKZ in LaTeX because it is fairly easy (depending on the domain) to produce something pretty that is consistent with the style of the document and easy to change if the surrounding text is edited. The overhead of going through an external diagramming tool is often not worth it in this case, unless it's a quick one-off note.

If I want to get an overview of a data structure, I like to write code that generates dot, which I then render using graphviz. I have successfully used that for debugging a few times.

When I use diagrams as a tool for thinking, I prefer paper and pencil, or, if I need to make many changes, yEd. I also use the latter for system diagrams (I prefer loosely following the C4 ontology) or for quick dissemination of ideas to colleagues when we can't be in front of the same physical whiteboard.

The only text-based diagramming tool that I use for thinking is plantUML, although I have only used it for sequence diagrams.

I don't have a lot of experience with using embedded DSLs for diagramming. I have used 'diagrams' in Haskell which is nice, although knowing the host language didn't mean that it was faster to learn the DSL compared to, say, graphviz or plantUML. It doesn't take a lot of time to learn the syntax of these things, it's all about learning how the primitives work and how they can be combined. An EDSL is mostly convenient if you need to programmatically generate the diagrams from data structures, since you can call the diagram library directly and avoid icky string interpolation.

Re: Create system diagrams with Go

#50
post #31

Go-Diagrams is a Golang port of diagrams [1], an Internal DSL for Python. Diagrams (the name of a software project) models cloud IaaS resources as network graphs and exports DOT [2] files that can be processed by Graphviz compatible tools. Neither Python nor Go are ideal languages for implementing an Internal DSL, compared to say Ruby or Groovy, so the first question is why an Internal DSL vs. the DOT language (or an…

I'm not sure if you've ever tried to maintain diagarms in plantuml or dot, but it becomes difficult over time to keep them up to date. I haven't used Python or Go diagrams but I have been a big user of plantuml for over a decade now. Off the top of my head, here are the main logistical problems with it: * It sits on its own * Hard to "share" metadata * Difficult to manipulate once put into the DSL * PlantUML has 12 d…

Just curious, do you always create a new HN account to comment?
Post reply on HN