3 ms·
I think making a tool like that language independent is impossible. You have to start by making it a diff tool just for tree structured data (diff tools today a
by ulrikrasmussen 6y ago
I think making a tool like that language independent is impossible. You have to start by making it a diff tool just for tree structured data (diff tools today are special cases of this as they operate on list based data). You then need to extend it to work on specific languages by diffing "modulo equations", e.g. in Haskell two top-level definitions are allowed to commute, so `x = e; y = f` should be considered identical to `y = f; x = e`.
But I think that's fine. The diff tool should use the most specific diff mode that it knows is safe, and fall back to the "free diff" of tree structured data when working on an unknown language.
- fiddlerwoaroof 6y agoI looked into using tree-sitter as a bar for this once: parse code into an AST of sorts and then use the ast to define the diff boundaries. Didn’t think through all the problems, though