News for hackers. Stuff that matters.
Re:Dragon: A distributed graph query engine by hellofunk on Tuesday March 22, 2016 @10:09AM (#11336683)
It looks a lot like Clojure but I'm not sure it is. For example, this expression:

(filter (> age 20))

That second form to filter should be a function, but in this case it is an expression that returns a boolean and is not itself a function.

Re:Dragon: A distributed graph query engine by adsharma on Tuesday March 22, 2016 @11:48AM (#11337404)
Right, it's not Clojure, but we tried to borrow some syntactical elements for readability. More discussion here:

https://groups.google.com/forum/#!topic/clojure/P3eW6Vi2QcU

Re:Dragon: A distributed graph query engine by okram on Tuesday March 22, 2016 @01:08PM (#11338017)
It has a very similar look and feel to Gremlin (http://tinkerpop.apache.org).

   (->> ($alice) (assoc $friends) (assoc $friends) (filter (> age 20)) (count))
...in Gremlin is:

   g.V(alice).out("friends").out("friends").has("age",gt(20)).count()
Re:Dragon: A distributed graph query engine by j_m_b on Tuesday March 22, 2016 @11:16AM (#11337177)
>That second form to filter should be a function, but in this case it is an expression that returns a boolean and is not itself a function.

I'm pretty sure this is Clojure or something very close to it. ->> is the thread-last macro. What it does is take the first expression, ($alice) and inserts it as the last expr in the next form so that the second step (assoc $friends) would eval to (assoc $friends $alice). It continues this by inserting this expr into the last part of the next form. So the example would reduce to: (filter (> age 20) (assoc $friends (assoc $friends $alice)))

Re:Dragon: A distributed graph query engine by hellofunk on Tuesday March 22, 2016 @12:15PM (#11337603)
But as I mentioned, the second argument to Clojure's filter is a function, and (> age 20) is not a function; therefore, this is not normal Clojure (or Clojure or at all). You'd have to replace the standard library's filter function to get the syntax you see in this article, which I doubt they are doing. therefore: not Clojure.
Re:Dragon: A distributed graph query engine by emidln on Tuesday March 22, 2016 @02:59PM (#11339024)
You could also walk the ast and do something special with unknown symbols (and functions that contain them).

i.e. while walking, we notice a function (> age 20) and age isn't visible in scope. We thus rewrite that into something like (fn [age] (> age 20)) or (fn [x] (> (:age x) 20)).

I've taken this approach before with DSLs. It makes for extremely fast to write business logic where business users don't have to care as much about where their data comes from (they just need field names).

Re:Dragon: A distributed graph query engine by hellofunk on Tuesday March 22, 2016 @03:45PM (#11339423)
In general code, that would be very hard to read, not knowing if a form represented an actual value or a function. Clojure being dynamically typed makes things hard enough; changing the language syntax as you describe sounds pretty risky to me.
Re:Dragon: A distributed graph query engine by emidln on Tuesday March 22, 2016 @04:11PM (#11339618)
The purpose of such a DSL isn't to let you write generic clojure faster. The DSL isn't even targetted at traditional programmers. The purpose is to enable training people who have no idea what Clojure or Lisp to get things done that are complicated (or expensive) to design graphical UX for. These people might have some excel experience or maybe a programming class in college, but are mostly reliant on examples and documentation to get things done. Why teach them things like how to create a function when they don't need to know or care? There is a huge usability difference for these people between (fn [age] (> age 18)) and (> age 18).