Gremlint JavaScript library included in TinkerPop 3.5.0

34 views
Skip to first unread message

Øyvind Sæbø

unread,
May 12, 2021, 8:05:22 PM5/12/21
to gremli...@googlegroups.com
Hello:) As many of you may be aware of by now Gremlint has recently become part of the TinkerPop project. TInkerPop 3.5.0 which was released earlier this week is the first release to include the Gremlint JavaScript library, so I'm taking the opportunity to write this post to give an overview of what Gremlint is, how it came to be and what may be in store for it now that it resides within the TinkerPop project.
Lowpoly Gremlin with Text 512x512.png

What is Gremlint? Reachable through gremlint.com Gremlint is an online Gremlin code formatter I've been developing. It lets you paste a piece of Gremlin code and get it back with line breaks and indentation adjusted to adhere to a standardized set of formatting rules.

I write a lot of Gremlin in my dayjob at Ardoq, so Gremlint was developed as a means to enforce a standardized way to achieve consistent formatting, and spend less time doing so. It has also proven to be a convenient tool to quickly turn large unreadable pieces of Gremlin code into something more digestible.
gremlint-demo.gif

Bringing it into TinkerPop
Gremlint eventually reached a point where it was well aligned with the TinkerPop style guide[1] and got some traction in the community. Ardoq recently donated Gremlint to TinkerPop so that it could serve as TinkerPop's official living style guide. It is my hope that having Gremlint managed by TinkerPop will make it more visible to the Gremlin community, which in turn will make it easier to crowdsource feedback and perhaps even development help. It would also be cool to see Gremlint used to enforce consistent formatting in TinkerPop’s Gremlin documentation.
Can Gremlint's logic be reused in other projects?
For a long time Gremlint’s formatting logic was somewhat trapped behind the graphical interface of gremlint.com with no easy way to reuse it in other projects. To alleviate this I’ve extracted the logic used by gremlint.com to a standalone JavaScript library. I am happy to announce that as of TinkerPop version 3.5.0, this library is included in TinkerPop and can be found here[2]. This means that the logic used to format queries on gremlint.com can now be used by Gremlin tool builders to incorporate formatting into their products.

What's on the horizon? The first step to making Gremlint easily accessible to JavaScript tool developers is to get it published to npm. This will require getting it into TinkerPop's Maven build structure, presumably in a similar fashion to how we do it for gremlin-javascript[3]. If you're eager to start experimenting with the library already it is possible to install it directly from GitHub, as described in the README[4].

Further development
The initial intention with Gremlint was to keep it somewhat language agnostic, the assumption being that all Gremlin dialects are so similar that it is sufficient for the formatter to be able to format a union of all the supported dialects. That being said, Gremlint has primarily been tested with Groovy-Gremlin, so there may be language specific edge cases that are not yet supported. It may also be worth looking into developing dialect-specific formatters. If we choose to go down that route Gremlint could possibly also be utilized as a translator between different Gremlin dialects.

Although Gremlint has been in development for over two years, it has gone through some major rewrites, and much of the code as it exists today was developed over a relatively short period of time. Formatting gremlin queries is already a complex problem, so there is some work to be done to ensure that the current code is as simple and understandable as possible before we start extending the current functionality. I made an effort last year to add an extensive set of test cases to cover the current functionality and I think the project has finally reached a point where code refactoring can be done with confidence.

Øyvind
Reply all
Reply to author
Forward
0 new messages