Show HN: I ported Tree-sitter to Go
222 points| odvcencio | 4 days ago |github.com
A suite of tools that help with semantic code entities: https://github.com/odvcencio/gts-suite
A next-gen version control system called Got: https://github.com/odvcencio/got
I think this has some pretty big potential! I think there's many classes of application (particularly legacy architecture) that can benefit from these kinds of analysis tooling. My next post will be about composing all these together, an exciting project I call GotHub. Thanks!
sluongng|4 days ago
Now perhaps we can get rid of the CGO dependency and make it pure Go instead. I have pinged some folks to take a look at it.
dilyevsky|4 days ago
odvcencio|4 days ago
unknown|4 days ago
[deleted]
up2isomorphism|4 days ago
Essentially you use AI to somehow re-implement the original code base in a different language, made it somehow work, and claim it is xx times faster. It is misleading.
odvcencio|4 days ago
silverwind|3 days ago
shayief|4 days ago
I imagine this can very useful for Go-based forges that need syntax highlighting (i.e. Gitea, Forgejo).
I have a strict no-cgo requirement, so I might use it in my project, which is Git+JJ forge https://gitncoffee.com.
odvcencio|4 days ago
silverwind|3 days ago
3rly|4 days ago
Thaxll|4 days ago
odvcencio|4 days ago
pronik|4 days ago
herrington_d|4 days ago
nnx|4 days ago
As you mention WASM-readiness, did you consider using the official Tree Sitter WASM builds nicely packaged with wazero (pure Go WASM runtime) ?
It may help staying sync with upstream for the long term and, while probably a bit slower, has nice security and GC advantages too.
trickypr|4 days ago
There are at least some use cases where neither queries nor walks are suitable. And I have run into cases where being able to regenerate and compile grammars on the fly is immeasurably helpful.
At least for my use cases, this would be unusable.
Also, what the hell is this:
> partial [..] missing external scanner
Why do you have a parsing mode that guarantees incorrect outputs on some grammars (html comes to mind) and then use it as your “90x faster” benchmark figure?
odvcencio|4 days ago
your use case is not one i designed for although yeah maybe the readme has some sections too close. the only external scanner missing atm is norg. now that i know your use case i can probably think of a way to close it
CodeCompost|3 days ago
acedTrex|4 days ago
Better title
AlexeyBelov|2 days ago
thebackup|4 days ago
odvcencio|4 days ago
red_hare|4 days ago
gritzko|4 days ago
My design docs https://replicated.wiki/blog/partII.html
I used tree-sitter for coarse AST. Some key parts were missing from the server as well, because I expected problems (had lots of adventures in East Asia, evil maids, various other incidents on a regular basis).
When I saw "tree-sitter in go" title, I was very glad at first. Solves some problems for me. Then I saw the full picture.
gritzko|4 days ago
I use CRDT merge though, cause 3-way metadata-less merges only provide very incremental improvements over e.g. git+mergiraf.
How do you see got's main improvement over git?
odvcencio|4 days ago
it does this via gotreesitter and gts-suite abstractions that enable it to: - have entity-aware diffs - not line by line but function by function - structural blame - attribution resolution for the lifetime of the entity - semver from structure - it can recommend bumps because it knows what is breaking change vs minor vs patch - entity history - because entities are tracked independently, file renames or moves dont affect the entity's history
when gotreesitter cant parse a language, the 3way text merge happens as a fallback. what the structural merge enables is no conflicts unless same entity has conflicting changes
monster_truck|3 days ago
conartist6|4 days ago
odvcencio|4 days ago
jbreckmckye|4 days ago
Are these pretty up-to-date grammars? I'm awfully tempted to switch to your project
How large are your binaries getting? I was concerned about the size of some of the grammars
odvcencio|4 days ago
kopirgan|4 days ago
mojifwisi|4 days ago
[0]: https://microsoft.github.io/language-server-protocol/specifi...
irishcoffee|4 days ago
odvcencio|4 days ago
skybrian|4 days ago
odvcencio|4 days ago
brodouevencode|3 days ago
yumosx|4 days ago
[deleted]