Live data from Hacker News

Difftastic: A diff that understands syntax

github.com

21–30 of 224 posts

Re: Difftastic: A diff that understands syntax

#21
post #18
post #12

Earlier quoted context omitted.

Because it is much easier, you don't have to build and maintain parsers for hundreds of languages. And you don't need need just any parser, you need very robust ones that can deal with malformed files well. Or, if you only pick a small set of supported languages, your diff tool will not work on most files or have to fall back to a structure-agnostic algorithm. Also not all text files even follow any useful grammar at…

This tool is built on tree-sitter ( https://tree-sitter.github.io/tree-sitter/ ), so presumably it doesn't need to maintain parsers at all. I've thought before this is how diffing should be done, and speculated that tree-sitter would make it more feasible. At this point, whenever I think some language-aware tool ought to exist, my first thought is "Does the language server protocol or tree-sitter make this more feasi…

Someone still has to build and maintain the parsers, you are just outsourcing this. And I added a bit to my comment, I tend to believe that parsing is the easy part, but that is admittedly more a gut feeling and not based on any real knowledge of that problem space.

Re: Difftastic: A diff that understands syntax

#22
This looks really cool and I can't wait to try it, tho... a bit of a PITA to get running. ;) Took a while to figure out how to build, and had to install 400MB of dependencies first....

Edit: And after installing cargo, watching it fail to build, then determining I must need a newer version of cargo, so I built that from source... it fails. Apparently I need to install `rustc-mozilla` and not `rustc`. "obviously".

This is all a testament to how much I want to try this tool...

MOAR EDIT: even with rustc-mozilla cargo fails to build. running `cargo install difftastic` gives me an error about my version of cargo being too old ;.;

Dear author: Let us run your tool.

Re: Difftastic: A diff that understands syntax

#24

If you have consistent code style and formatting this tool is unnecessary. I think that solution is better, you get a more consistent code base that is easier to read for humans. (Also diffs will be faster to compute)

Even if you are consistent, having unchanged indented text show up differently is very clever. I often end up reviewing a diff that moves a basic block into a conditional branch and have to scan each line to see if it changed.

If you're using a language that doesn't depend on indentation (C, Java, Go, Rust etc), try "diff -b" or "git diff -b".

The indented basic block won't show as a difference, only the start and end of the block.

Re: Difftastic: A diff that understands syntax

#25

I really like the idea of focusing on producing patches for human consumption. I studied the problem of merging AST-level patches during my PhD ( https://github.com/VictorCMiraldo/hdiff ) and can confirm: not simple! :)

Can you give a little color on where the difficulties lie? Is it an efficiency question, or is determining "which changes" hard in the first place?

Re: Difftastic: A diff that understands syntax

#26
post #14

Looks really cool, but there was no instructions on how to install it. I would recommend putting an installation guide in your readme, and it being a full installation guide. I followed the link to your manual and then it told me to install your tool using a tool called "cargo" with no reference on how to install cargo. At this point I gave up. Lazy, maybe, but for a convenience tool like this I want a convenient ins…

I agree with all your points.

Only diff is I got to the point where it said I needed "cargo", On a whim, I typed "aptitude install cargo", and it did something. Now waiting for the >1GB source repo to clone to see if it works.... ;)

Re: Difftastic: A diff that understands syntax

#27
post #22

This looks really cool and I can't wait to try it, tho... a bit of a PITA to get running. ;) Took a while to figure out how to build, and had to install 400MB of dependencies first.... Edit: And after installing cargo, watching it fail to build, then determining I must need a newer version of cargo, so I built that from source... it fails. Apparently I need to install `rustc-mozilla` and not `rustc`. "obviously". Thi…

Used `cargo install difftastic`? Finished in a minute for me.

Re: Difftastic: A diff that understands syntax

#28

I paid and used SemanticMerge quite successfully when we had a complex Git workflow with lots of conflicts. https://semanticmerge.com/ Since moving to short lived feature branches it is less useful to me.

I don't need SemanticMerge often, but when I do I'm incredibly thankful that I have it.
Post reply on HN