Hacker News new | ask | show | jobs
by jpadvo 4993 days ago
This sounds very useful. I'm having trouble understanding the nature of the system, though, because I don't really understand lisp / clojure. Is this a pattern that could be applied in any language with first class functions, or does it require a lisp to be practical?
2 comments

Sure! This particular way of expressing declarative structure may be specific to Clojure, but the basic ideas should be useful in any (especially dynamic) language with first-class functions.

The first idea is to take a complex system and express the set of components and their relationships declaratively, rather than procedurally. This is an old idea, and makes it possible to reason about the system, mock out components for testing, map over the components for monitoring, and more.

The second idea is simplicity. By making this declarative language as simple as possible, it becomes trivially easy to do all the things I just mentioned using the existing tools in the language, without needing to write complex library functions to support each use case.

For another example of a declarative system for composition you could look at 'react' in JS, which can be used in similar ways to Graph (and also supports things like async composition): https://github.com/jeffbski/react

Thanks! That makes a lot of sense, and react looks like a really interesting project. I'll have to go back and reread the article with an eye for applying its ideas in Javascript / Coffeescript.
react looks interesting, although man, the stringly-typed bit sorta reinforces a lot of the Lisp quotes about being able to modify the language, etc. (Disclaimer: I've only just started studying Clojure in earnest over the last month or two. No zealot like a convert, eh?)
You can do it in any language with first class functions and reflection.

Here's a stupid simple js implementation of their example:

https://gist.github.com/3874826

Edit: Loaded the page and got interrupted by lunch. Shows me for not refreshing.

That's awesome -- thanks for posting
Thanks for writing it up. I've thought about dataflow programming before but building the dependency graph up was always annoying and the idea of sticking everything in a map and building the dep chains by introspecting the argument names hadn't occurred to me. With the ease of use solved this is handy enough that I'll probably turn it into a real promise-based utility.
Awesome, I'm excited to see what you come up with. If you do end up making something, please email me a link (I wrote you earlier) since I'm sure there's lots to be improved in our implementation.