[HN Gopher] D2: A new declarative language to turn text into dia... ___________________________________________________________________ D2: A new declarative language to turn text into diagrams Author : snikolaev Score : 177 points Date : 2022-08-30 16:33 UTC (6 hours ago) (HTM) web link (d2-lang.com) (TXT) w3m dump (d2-lang.com) | JohnHaugeland wrote: | It's interesting. | | This notation is pretty similar to the notation in the FOSS tool | (admittedly that I wrote) over here: | https://stonecypher.github.io/jssm-viz-demo/graph_explorer.h... | | Fortunately, no need for accounts or payment there. | wongarsu wrote: | Mermaid also does this, and is integrated in github/gitea/gitlab. | | To try it out, just open a new github issue and add | ```mermaid graph TD; A-->B; | A-->C; B-->D; C-->D; ``` | | Or try the live editor: https://mermaid.live/ | jbreckmckye wrote: | Mermaid has heaps of problems. I discovered this when I tried | extending it myself. | | Firstly, neither its parser and its visualiser can be extracted | from the library. You can't process a grammar on a backend and | then render out an SVG. You can't generate an SVG as part of a | CLI tool - not without spinning up a web browser in automation | mode. | | Secondly, the grammar is messy. Really really awkward. | Flowcharts are OK because they were the first Mermaid usecase, | but other grammars are quite weirdly written, brittle, and try | to be a mismash of other DSLs. Which in turn leads to very | awkward token choices to avoid stepping on the toes of parts | that are UML-like, parts that are DOT-like, etc etc | | My impression reading Mermaid's issues is that it was built | from scratch by a JS developer who hadn't any previous | experience with DSLs, parsers, or language design, and largely | learned as he went along. That's acceptable for a proof of | concept. But as a finished product Mermaid is a lumbering mess | Terretta wrote: | See also: | | https://structurizr.com/ - diagrams as code | | https://c4model.com/ - C4 model for visualising software | architecture | | The consistency of structurizr + c4 is great for sharing | information across scaled teams of teams. | michaelsbradley wrote: | also: | | The XState Visualizer generates nice looking statecharts. | | https://stately.ai/viz | | Click _See an example_ in the left pane, then click _Visualize_ | at the bottom of the right pane. | | On the roadmap are visualizations for XState's actors facility, | i.e. multiple statecharts interacting with one another. | | If you login, you can save/fork statecharts and get shareable | links for them. There doesn't seem to be a way to export the | diagrams (as PNG or SVG) but maybe that will be added in the | future. | howeyc wrote: | also: | | https://pikchr.org/ | keepquestioning wrote: | Does this use Stable Diffusion? | whalesalad wrote: | Something was posted here recently in a similar light - does | anyone recall what it was? | jrib wrote: | there are a few of these tools but | https://news.ycombinator.com/item?id=31273777 was a recent | reference to https://mermaid-js.github.io/mermaid/#/ | tonerow wrote: | This was up yesterday | https://news.ycombinator.com/item?id=32637689 It's similar in | that it's a diagramming DSL | ducktective wrote: | Is there a declarative language or framework for creating ad-hoc | GUIs that consume structured data from stdin stream and spit-out | a GUI? | | Like feedgnuplot [1] but not only restricted to graphs. | | [1] https://github.com/dkogan/feedgnuplot | ajstarks wrote: | Not a GUI, per se, but there is decksh [1] and dchart: [2] | | [1] https://speakerdeck.com/ajstarks/decksh-object-reference | [2] https://speakerdeck.com/ajstarks/dchart-charts-from-deck- | mar... | keyboardclicker wrote: | Time for someone to copy the good parts and implement them as | FOSS. Good luck getting enterprises to pay for diagrams. | stuart78 wrote: | At the end of the video the presenter mentions that they plan | to open source the language when it reaches a greater stage of | maturity. | clcaev wrote: | A code dump does not make it an open source project. | Sustainable OSS projects are developed publicly. | sharkster711 wrote: | That's probably why they're doing a code dump | stragies wrote: | The language spec, or the rendering backend code? And | even if the "complete package", if the "locally runable | version" is an afterthought of the OnlineWebVersion, have | previous situations like that not regularly resulted in | *Paks wrapping an electron instance with some blobs under | the hood? | zactato wrote: | Lucidchart has entered the chat. | dalager wrote: | https://plantuml.com/ is free and nice. Plays well with Markdown | and C4 diagrams. The only UML-specific diagram type I use is the | sequence diagram but that is very useful IMHO. | be_erik wrote: | It can be a bit clunky setting up the jar (or hosting it | yourself), but it's still the best worst option. It scales | pretty well and can draw some very complex flows, while still | giving you the best in just plain ole text editing. | | I could have never maintained the diagrams I used for other | developers on my teams or folks on the audit/regulation side of | thing without it. | | The default styles are really unprofessional looking and I | think a lot of folks look the other way once they see that. C4 | diagraming with PlantUML is also a breeze for systems diagrams. | | https://github.com/plantuml-stdlib/C4-PlantUML | nerdponx wrote: | A declarative language for diagrams without so much as a passing | mention of Graphviz, or even Mermaid.js anywhere in the docs? | | It does look like a material upgrade from Graphviz, but even | so... | stragies wrote: | graphviz svg output can be (with some tricks) CSS-styled + JS- | animated, so the sky is the limit w.r.t. how fancy you want to | make you DOT graphs, and their elements. | convolvatron wrote: | actually the effective limit seems to be around 50 nodes | stragies wrote: | Limit of what exactly? I've made much bigger than 50 nodes | SVG-graphs using GV, and styled them with probably 50+ CSS | styles and animated more than 50 nodes. | | So, could you please elaborate? | deltree7 wrote: | Sadly, any start-up tool firm can't have any other business model | other than subscription. | sharkster711 wrote: | Does anyone know what the clipboard tool that was being used in | the youtube demo is? | jacobra2 wrote: | I believe FlyCut. | rgrieselhuber wrote: | Looks cool. Any inherent limitations or performance issues with | graphs that are very large? (20M+ elements) | mkl95 wrote: | Unless you use instanced rendering via some GPU API it's going | to take some galaxy brain code to make that work. | jbreckmckye wrote: | Forget about rendering, just doing the layout would be | extremely challenging. | stragies wrote: | Some of the graphs (near the bottom) of the GraphViz | example page are quite large: https://graphviz.org/gallery/ | | And there's a link to a gallery with even bigger ones, so | #NumberOfNodes alone does not seem to be the main limiting | metric. Maybe combined with the choice of rendering layout. | samatman wrote: | Why uh. Would you expect that to work? | | How much of your life were you planning to dedicate to | scrolling from one side of the image to another? | guhidalg wrote: | I think he expects to be able to zoom out. | rgrieselhuber wrote: | Yup for zoomed out views. It's handy when visualizing large | websites. | abeppu wrote: | The last question in the FAQ makes it clear that this can only be | used in the context of their account-based online tool. Their | free offering literally says "3 diagrams". Above this, the FAQ | tries to compare their tool to Mermaid, Graphviz, PlantUML which | are all open source, locally runnable, etc. Their comparison | totally skips the fact that, because D2 can only be used in their | service, a broad number of use cases (including programmatically | generating diagrams inside some other application) basically | aren't supported. | | Seems like it could have been cool, but likely will not seriously | try it because of these limits. | kevmoo1 wrote: | Agreed! Interesting idea, but charging for this is not going to | get them very far. | | Gotta find a way to do an "open core" or similar. | geodel wrote: | Agree. To be honest, I'd find it useful if it were closed | source but native installable tool that can convert text to | diagram which then could be exported to image/pdf etc. | geraldwhen wrote: | Yup. I use many paid, local tools. And because there's no | network service nonsense it's not a problem at work. | rvense wrote: | Services as a software substitute... | alixanderwang wrote: | Those tools are mature 10-20+ year and we're just getting | feedback for our little ol' alpha born ~yesterday. The | limitations are temporary -- we are working on an offline, | locally runnable experience (it's in the roadmap), but, alas, | engineering bandwidth of a 6 person team. | | edit: I've updated the docs to make this clear | BarryMilo wrote: | How is this different/better than, say, Mermaid? | sieabahlpark wrote: | Would you believe me if I said this was just an ad and you | wasted time on it? | | Just because HN isn't Reddit doesn't mean ads aren't thrown in | with all the curated "content" | armchairhacker wrote: | May be an ad but this is something I would actually use if it | wasn't paid. | | Like other said, maybe it will inspire someone to take this | and make an open-source version | rch wrote: | If it was open source with a permissive license I'd start | paying immediately, like I have with other projects. | | > if it wasn't paid. | | Maybe you intended to say 'if it wasn't _closed_ ', or | similar. | jacquesc wrote: | Wow, thanks for the clarification. Totally missed this part. | After having already evangelized this with my coworkers, I may | need to take it back. | | If they made the core open and allowed users to use this | language independently of their online service, there's still a | ton of value they could have added with premium services on top | of this. For writing the docs, sharing with teams, comments / | versioning, etc. Visual figma type features essentially. A team | bought into the specification would very likely pay for this. | | But it's hard to imagine it taking off being completely locked | into their service. Ah well, a fine idea and looked pretty well | executed. | | EDIT: maybe that's on their roadmap "When the language is more | stable, we intend to open source D2. This will happen sometime | in 2022.". Ok, back on board | abeppu wrote: | Also, to me this was a reminder of the importance of context | and assumptions in good communication. Never having heard of | this org, I clicked the link for this post, saw the top-level | blurb describing the project and assumed that a 'language' | which generates diagrams from declarations would be something I | could _run_. I clicked on the 'Getting Started' section and was | annoyed that there was no 'Installation' section. I started | from a context that inclined me to think of this as a stand- | alone project which ought to have certain characteristics. | | I think the author of this page started with the assumption | that of _course_ given their business and product, a 'language' | for diagrams is only giving users access to something that maps | on to whatever internal representation their tool already uses, | and allows technically inclined users to work with text and | fewer clicks. To them, the assumption seems to have been that | readers will already be users of their product, and the | assumption that the 'language' is built into their tool _and | nowhere else_ is so far in the background that it's only | somewhat obliquely addressed as the last question in a FAQ. | Per_Bothner wrote: | People seem to be missing that this is a preview, not a product | (yet). And that: "When the language is more stable, we intend | to open source D2. This will happen sometime in 2022." | setr wrote: | In D2 Tour video, at 4:30, they say | | > When it's more stable, we will be open-sourcing the | _language_. | | If thats the case, that only the _language_ will be open- | sourced, not the visualization, then I 'm not entirely sure | what that really gets you, beyond perhaps alternative | editors? | | But its the layout algorithms that are actually notable. | [deleted] | stragies wrote: | Perhaps then "Preview/Beta online service" should be part of | the Headline/title. | sophacles wrote: | Perhaps reading the article is a useful way to get | information? If the headline contained everything everyone | would conceivably want to know, it would be the article. | It's not like the headline was misleading: "a new $tool" is | a common phrase for software in alpha and beta stages. | stragies wrote: | So, to you, "Tool" or "Language" do NOT imply that you | can use it independently of a specific online service? | | I mean, I agree, that "new" is marketing speak for | "alpha/beta", but -to me- there is a difference between a | "language/tool" and a "Single-Vendor-WebService". Or is | my understanding of the semantics of the English language | outdated? | geraldwhen wrote: | This is a complete non starter for any regulated industry. | | Shame. Mermaid works almost okay and often looks like garbage. | I wish there was an open source effort somewhere to do better, | or even a paid locally runnable tool that has no service | connections. | JohnHaugeland wrote: | Here's an option: https://stonecypher.github.io/jssm-viz- | demo/graph_explorer.h... | cush wrote: | It's why I keep falling back to excalidraw over tools like | mermaid with auto-layout. When I need to communicate an idea, | often I really need to fuss with layout in order to get my | point across, and having the control to drag things around is | the only way to get there. | tonerow wrote: | It won't work for every use case but https://flowchart.fun is | one open-source alternative | alixanderwang wrote: | Hi all, creator of D2 here. I posted this on Reddit to get some | feedback but was hoping to improve the docs and offer a | playground environment before posting on HackerNews. Ah well. I | wanted to clarify some things: | | 1. D2 will be open source and usable outside of Terrastruct. | Terrastruct will remain the best interface to D2, with | bidirectional updates from GUI, but we already have vscode and | vim plugins ready for local editing. We're a small team and | working on one thing at a time. | | 2. We're aware of PlantUML, Graphviz, Mermaid, of course. These | are mature offerings, but I see plenty room for improvement that | we intend to tackle with D2. https://d2-lang.com/tour/faq#how- | does-this-compare-to-mermai... | | Feel free to ask any questions! | kaladin_1 wrote: | Nice intro video on the landing page. I liked the capabilities | shown. | | I do think you could have made it obvious in the Getting | Started section that this is not a local runnable language. I | spent some time looking for how to install it only for me to | realise that it is some form of SaaS. | alixanderwang wrote: | Thanks! The caveat is on the intro/home page. We very much | intend to support a high quality locally runnable experience | before we'd call it a v1. | flashgordon wrote: | By the way do you have a BNF grammar (or something more of a | formal spec for this?). The cheat sheet does look good though. | alixanderwang wrote: | No unfortunately not yet. The docs are like 75% caught up to | all the language right now and it's still changing not | infrequently, so we'll make some formal specs once it's | stable. This reveal caught us off guard =). | mdaniel wrote: | > I posted this on Reddit to get some feedback | | > This reveal caught us off guard | | Hmmm | alixanderwang wrote: | hah, so the line of logic was: "let's post on reddit to | get some low stakes feedback in preparation for a HN | launch" | [deleted] | kgm wrote: | I am taken a little aback by the name. There is, of course, | already the D programming language, which has even had a major | version number of 2 for quite some time. | | It also brings to mind the JavaScript library d3, which, while | not _strictly_ for making diagrams, can easily lend itself to the | purpose. | | Calling this thing "D2" seems potentially confusing. | snowcorn wrote: | We have: | | "D" the programming language [0] | | "D" the data language specification [1] | | "D" the programming language for DTrace [2] | | "D3" the javascript library [3] | | "D4" library/tool for Declarative Data-Driven Documents[4] | | "D4" implementation[5] of the data language specification[1] | | Overall, I think "D2" is objectively the best choice here. We | have at least three "D"s, two "D4"s, and one "D3", so it makes | sense to put it in as "D2". I certainly wouldn't want another | "D" or, heaven forbid, a "D5". | | [0]: https://en.wikipedia.org/wiki/D_(programming_language) | | [1]: | https://en.wikipedia.org/wiki/D_(data_language_specification... | | [2]: https://en.wikipedia.org/wiki/DTrace#Description | | [3]: https://d3js.org/ | | [4]: https://github.com/joelburget/d4 | | [5]: https://en.wikipedia.org/wiki/Dataphor#Languages | tomwojcik wrote: | As a gamer, after reading just "D2" my brain immediately | assumed it's about Diablo 2 Resurrected. | Ancapistani wrote: | I thought of the D-2 extract on Reserve in Escape from | Tarkov. | MaxBarraclough wrote: | Calling it now, someone will make a tool for automatic | documentation of R codebases, and call it R2D2. ___________________________________________________________________ (page generated 2022-08-30 23:00 UTC)