TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Octopus – a directed acyclic graph for app development

84 点作者 bbsimonbb超过 1 年前
Directed acyclic graphs are muched discussed in comp-sci, but octopus appears to be the first reusable, turnkey, ready-to-wear, off-the-shelf implementation of a DAG for application development, in any language, that I&#x27;m aware of.<p>This is remarkable because DAGs hit a sweet spot in the middle of the three common programming paradigms (OO, event-driven, functional). Let&#x27;s have a DAG as the top-level structure of our applications. Data-fetching and onChange handlers live in DAG nodes, next to the data they act on. The UI flows out from the DAG with fine-grained reactivity. Our app state is effortlessly consistent, because any outside change (user action, api result) unleashes a graph traversal. Our UI components become much simpler, because they just need to dumbly reflect values in the graph.<p>I&#x27;m putting this up for a second time. Absolutely no-one bit the first time, which can&#x27;t be right :-)

15 条评论

kokanee超过 1 年前
How is React state not a DAG out of the box? What problems does this solve? The pitch appears to be:<p>&gt; any outside change (user action, api result) unleashes a graph traversal. Our UI components become much simpler, because they just need to dumbly reflect values in the graph.<p>But that sounds the same as the reasoning behind React&#x27;s one-way data flow.
评论 #38649042 未加载
efnx超过 1 年前
&gt; Directed acyclic graphs are muched discussed in comp-sci, but octopus appears to be the first reusable, turnkey, ready-to-wear, off-the-shelf implementation of a DAG for application development, in any language, that I&#x27;m aware of.<p>I wrote one for Rust called moongraph: <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;moongraph" rel="nofollow noreferrer">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;moongraph</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;schell&#x2F;moongraph">https:&#x2F;&#x2F;github.com&#x2F;schell&#x2F;moongraph</a><p>It powers my configurable renderer and my ECS. I&#x27;m sure lots of other folks have written their own and they might not even know it&#x27;s a DAG.
catapart超过 1 年前
Like others are saying: I think a lot of modern frameworks already fit this mold, or are so close that people can&#x27;t quite tell the difference. But for a near 1-1 example, maybe look at XState? Especially given that XState has a visual, graph view which interactively indicates state in real time.
评论 #38649468 未加载
bbor超过 1 年前
A) I agree with many of the comments here arguing that this is not necessarily a new technique, and<p>B) you’re gonna go far in this life, I’d bet! I know nothing about you but this whole README just <i>reeks</i> of a bright young thinker who’s not afraid to question existing paradigms and can follow through on their conceptual vision. Plus it helps that you’re a very dramatic and effective writer. I encourage you not to let any of this feedback get you down!<p>Will sit down with the repo myself later, just for me it’s not an angle of HCI I’ve examined explicitly, at least for very long.
评论 #38647610 未加载
评论 #38647966 未加载
w10-1超过 1 年前
The DAG framing might miss the key points and attract contention.<p>The &quot;law of Demeter&quot; is a design rule that says to only work with data you directly know about - i.e., friends, but not friends of friends. It make local reasoning tractable and forces any (friendly) use to be surfaced as such, which gives a better way to assess global complexity. (By contrast, the DOM is just, well, global state, whatever the data structure.)<p>But who or what is &quot;you&quot;? In this case, the node, which is responsible for (local) data liveness; a UI as simply derived nodes from that, with cross-node validation dependencies represented as graph dependencies.<p>Modeling overall system activity as graph updates does provide nice separation to permit concurrent programming, with graph structure as the arbiter of conflicts, but you&#x27;ll need a more specific notion of &quot;consistency&quot; that can distinguish the use cases this would work for.<p>The comparison and question would be with various UI and data component systems, which handle data mapping to the back-end, cross-component aspects like themes or device constraints, user id and security, etc.: how are these higher-level concerns managed with an iterative graph structure?<p>Serialization is a nice sample concern, but your (attractive) approach exemplifies the issue: to make it work entails tracking some conventions&#x2F;responsibilities, which are not captured by the DAG framing.<p>For me, frameworks work when the types basically constrain developers into doing the right thing. Local reasoning and responsibility translate directly to local code, and proof relates directly to compliance, preferably at the language level at build time.<p>These kind of local-reasoning models shine when the code is federated, e.g., when hosting multiple services and contributions. The whole app should just work if the participants can be validated on load&#x2F;launch, and any failures should be restricted to the local nodes instead of cascading. So if you target an app requiring some specific collaborative domain (with a promising business model), this proposal might draw more attention, and you can work through issues concretely.<p>So perhaps target a killer app, build understandable constraints into the code, and demo key features.
评论 #38649249 未加载
hobofan超过 1 年前
Almost every modern framework is implicitly modeled as a DAG? It just rarely used that nomenclature. Heck with Elm a whole language exists for that principle.<p>I&#x27;m really not sure what&#x27;s supposed to be different here. As is evident from the repository you obviously know about React and Vue, so maybe try to contrast it to them, or how it fits in in relation to them? To me it looks like you are building a system-in-a-system, where you are rebuilding the primitives that already come with React (or any of its peers).
评论 #38649236 未加载
wavemode超过 1 年前
I remember working at a company where we had a backend web framework that was essentially a DAG. You could use it to create API&#x27;s where the caller simply specifies what they want, and the server figures out, through graph theory, what series of processing steps and API calls to other services should be performed (some of which can have dependencies on the results of other API calls and&#x2F;or processing steps), and the optimal way to parallelize them.<p>It struck me as being both a very intriguing framework, and also exceptionally over-engineered for the kind of problem it was solving (since an async-await architecture gets you all the same benefits).
评论 #38651003 未加载
评论 #38649489 未加载
archibaldJ超过 1 年前
I don’t really understand what values such design pattern can bring worth (that will outweigh its own complexities)<p>my experience working with DAGs programmatically (ie not as an abstraction (like in React) but actually handling the edges&amp;nodes of a graph-based abstraction in code) is that it looks nice theoretically but in practice top-down (conceptual) approach like this often tends to over-complicate things<p>would love to see some real-world examples where an actual dev team, etc, find values in graph-theortical-based abstractions like this
评论 #38649413 未加载
评论 #38649358 未加载
评论 #38652983 未加载
mdaniel超过 1 年前
well, partially because there&#x27;s no license in your repo so unless you&#x27;re selling it to someone ... what outcome are you <i>expecting</i> to happen?
评论 #38647380 未加载
kitd超过 1 年前
&gt; Directed acyclic graphs are muched discussed in comp-sci, but octopus appears to be the first reusable, turnkey, ready-to-wear, off-the-shelf implementation of a DAG for application development, in any language, that I&#x27;m aware of.<p>I may be misunderstanding what this is, but back in the J2EE days ISTR Struts having something very similar to this, ie a flow from page to page declared apart from the actual page logic itself. Edit: and all done in XML, so obviously doesn&#x27;t count!<p>Cool project though!
评论 #38647011 未加载
speps超过 1 年前
Isn&#x27;t this what Dash[1] does? You can see a very similar graph in the built-in debugging tools.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;plotly&#x2F;dash">https:&#x2F;&#x2F;github.com&#x2F;plotly&#x2F;dash</a>
reactordev超过 1 年前
The browser is already a graph. Or am I missing something?
评论 #38647627 未加载
20after4超过 1 年前
LinuxCNC is an old and proven application based on a DAG as the core architectural paradigm.
machiaweliczny超过 1 年前
How is that better than MobX?
评论 #38660622 未加载
atlassubbed超过 1 年前
Ah interesting, a trip down memory lane! I made something very similar 5 years ago: <a href="https:&#x2F;&#x2F;github.com&#x2F;atlassubbed&#x2F;atlas-relax">https:&#x2F;&#x2F;github.com&#x2F;atlassubbed&#x2F;atlas-relax</a>. It was an attempt to build a &quot;stronger&quot; version of React (using DAGs) in under 2.5kb, and completely decouple the diffing&#x2F;rendering engine from the DOM. So think &quot;nodes that can return JSX templates in their compute functions&quot;, but the JSX templates don&#x27;t need to represent the DOM. They could represent anything, like Terraform config since JSX is just a syntax for javascript objects, similar to the hyperscript function `h`. To create React with my framework, I used a plugin (one such plugin <a href="https:&#x2F;&#x2F;github.com&#x2F;atlassubbed&#x2F;atlas-mini-dom">https:&#x2F;&#x2F;github.com&#x2F;atlassubbed&#x2F;atlas-mini-dom</a>) which registers listeners on nodes&#x27; create&#x2F;update&#x2F;destroy lifecycle methods. The simple idea is when a DAG node is added and corresponds to a DOM node, add the corresponding DOM element to the DOM. When removed, remove the element, etc. The cool thing was that the &quot;build your own react&quot; plugin is like 20 lines of code since the base diffing&#x2F;rendering is abstracted away by the underlying DAG engine, so the interface ends up being similar to an AST crawler interface, where you&#x27;re just implementing listeners as you encounter new&#x2F;changed tags.<p><pre><code> const { diff } = require(&quot;atlas-relax&quot;); const DOMRenderer = require(&quot;atlas-mini-dom&quot;); const App = () =&gt; ( &lt;div&gt; Bonsly evolves into Sudowoodo after learning mimic. &lt;&#x2F;div&gt; ) &#x2F;&#x2F; create a DOMRenderer plugin const rootEl = document.getElementById(&quot;root&quot;); const renderingPlugin = new DOMRenderer(rootEl); &#x2F;&#x2F; mount &lt;App&#x2F;&gt; against the &quot;null&quot; DAG and render it to the DOM. diff(&lt;App&#x2F;&gt;, null, renderingPlugin); </code></pre> The cool thing is you could diff two different DAGs against each other and listen to the delta, like `diff(&lt;App1&#x2F;&gt;, &lt;App2&#x2F;&gt;, consoleLogPlugin)`. The base library could be used to generate application frameworks as long as your application framework can be thought of as a DAG operating on data. React is an example of such a framework, but so is something like Airflow, so you could write a plugin that lets you build your own kind of Airflow. That was the motivation behind my DAG abstraction -- to make it easy to create DAG frameworks for frontend and backend. Let the base library do all the hard reconciliation work, and you can build application frameworks on top.<p>Anyway that was all mostly an exercise. I didn&#x27;t end up using my framework for anything more than a state management solution for React. It handles global data perfectly, although these days React context or hook management is usually enough.
评论 #38653084 未加载