Responses inline:

On Fri, Oct 16, 2020 at 2:03 PM serg salo <[email protected]> wrote:

> so often we have a need to express small graph, but all at the client side
> (browser). it would be great to have tinkergraph working on js engine. I
> saw one project attempting to do that, but that was a long time ago and
> never came to completeness. https://github.com/jbmusso/tinkergraph-js


The benefits of having TinkerGraph (or the like) in Javascript (or any
non-JVM language) are pretty obvious so definitely agree that it would be a
good thing to have. The big "but" is coming....


> Would you have any suggestions on how to start that work? Or is there
> better way to have tinkergraph in browser.
>

I don't fully know your use case, but I think a common one could be
satisfied by subgraphing with store()[1]  (since you can't use subgraph())
and then piping that result to a native graph library. So in Python you
would maybe extract your subgraph with Gremlin then convert the subgraph
into NetworkX [2] form. Depending on your needs you could probably write a
small in-memory graph in a few hundred lines of code.

So, it's that last point where I think things fall apart in your case
because...


> The idea is to have an ability to use gremlin over the data structure in
> memory.
>

And this ties into my "but" from earlier. The issue is not in having a
TinkerGraph for javascript. The TinkerGraph part is pretty easy. If you
strip away all the GraphComputer/OLAP stuff out of TinkerGraph (and stupid
meta/multiproperties) the code itself is dead simple. The issue is more
with developing the code library to evaluate and execute Gremlin in
javascript over that graph. TinkerGraph plays little part in the actual
execution of Gremlin. What javascript would need to implement is
gremlin-core[3] (and perhaps other modules but I'm not thinking this
through in detail atm) and so the effort becomes non-trivial as we're
basically saying that we want to build a Gremlin VM natively in Javascript
or whatever language we wish to support. We have discussed this "Gremlin VM
for every language" idea and I'd say that there is consensus that it's a
good direction but it will also require a lot of additional discussion and
work.

This is basically the reason why non-JVM Gremlin Language Variants were
built to be "lightweight" and why they hold a variety of limitations
compared to their JVM counterparts. That, of course, leads to confusion
with users a lot of times and use cases that cannot be realized of the JVM.

As I spend a fair amount of time thinking about this from time to time, I
do think there are ways to stage things in a way where we don't have to get
to "full Gremlin VM" immediately while still delivering useful
functionality along the way. I personally think it will be hard to get
anywhere with this until we make a reversal on keeping structure in non-JVM
GLVs. As it stands, non-JVM variants only contain "references" to graph
elements. If you or anyone else wants to contribute meaningfully to this
discussion I highly recommend reading this post[4] which describes the
history of this design choice, the problems it solves and what problems we
bring if we reverse it (without new solutions). Without a graph structure
in non-JVM variants of Gremlin we won't get far on the bigger prize of a
Gremlin VM in every language.


> Also, I would suggest using Typescript to make this whole thing easier to
> deal with from the beginning.
>

We have an open issue for Typescript and there is some discussion there:
https://issues.apache.org/jira/browse/TINKERPOP-2027 - you might wish to
comment/contribute there.

Thanks for showing interest in the project and this major issue. I'm happy
to answer any questions you might have on the matter and keep the
discussion going.


[1] http://stephen.genoprime.com/snippet/2020/08/01/snippet-12.html
[2] https://networkx.github.io/documentation/stable/tutorial.html
[3] https://github.com/apache/tinkerpop/tree/master/gremlin-core
[4]
https://lists.apache.org/thread.html/e959e85d4f8b3d46d281f2742a6e574c7d27c54bfc52f802f7c04af3%40%3Cdev.tinkerpop.apache.org%3E

Reply via email to