Hello everyone, Please see the section entitled "Host Language Embedding" here: http://www.planettinkerpop.org/#gremlin (3 sections down)
When I was writing up this section, I noticed that most of the language drivers that are advertised on our homepage (http://tinkerpop.incubator.apache.org/#graph-libraries) know how to talk to Gremlin Server via web sockets, REST, etc., but rely on the user to create a String of their graph traversal and submit it. For instance, here is a snippet from the Gremlin-PHP documentation: $db = new Connection([ 'host' => 'localhost', 'graph' => 'graph', 'username' => 'pomme', 'password' => 'hardToCrack' ]); //you can set $db->timeout = 0.5; if you wish $db->open(); $db->send('g.V(2)'); //do something with result $db->close(); $db->send(String) is great, but it would be better if the user didn't have to leave PHP. Please see this ticket: https://issues.apache.org/jira/browse/TINKERPOP-1232 I think for non-JVM languages, it would be nice if these drivers (PHP, JavaScript, Python, etc.) didn't require the user to explicitly create Gremlin-XXX Strings, but instead either used JINI or model-3 in the ticket above. Lets look at model-3 as I think its the easiest and more general. For instance, they would have a class in their native language that would mirror the GraphTraversal API. *** I don't know any other languages well enough, so I'm just going to do this in Groovy :), hopefully you get the generalized point. *** public class Test { String s; public Test(final String source) { s = source; } public Test() { s = ""; } public Test V() { s = s + ".V()"; return this; } public Test outE(final String label) { s = s + ".outE(\"${label}\")"; return this; } public Test repeat(final Test test) { s = s + ".repeat(${test.toString()})"; return this; } public String toString() { return s; } } Then, via fluency (function composition) and nesting, you could generate a Gremlin-Groovy (or which ever ScriptEngine language) traversal String in the backend. gremlin> g = new Test("g"); ==>g gremlin> g.V().outE("knows") ==>g.V().outE("knows") gremlin> gremlin> g = new Test("g"); ==>g gremlin> g.V().repeat(new Test().outE("knows")) ==>g.V().repeat(.outE("knows")) gremlin> From there, that String is then submitted as you normally do with your driver. For instance, with Gremlin-PHP, via $db->send(String). Of course, if your driver is already on a JVM language, there is no reason to do this (e.g. Gremlin-Scala), but if you are not on the JVM, this gives the user host language embedding and a more natural "look and feel." Moreover, if your language doesn't use "dot notation," you would use the natural idioms of your language. $g->V->outE("knows") If anyone is interested in updating their non-JVM language driver to use this model, I would like to write a blog post about it. Or perhaps, a tutorial for for language designers. Thoughts?, Marko. http://markorodriguez.com