Live data from Hacker News

Difftastic: A diff that understands syntax

github.com

81–90 of 224 posts

Re: Difftastic: A diff that understands syntax

#81
post #60
post #5

This looks absolutely amazing. One thing I do find interesting (and a wish were different) is that only programming languages are supported, rather than data formats as well. For example, two JSON documents may be valid but formatted slightly differently, or a common task for me is comparing two YAML files. Comparing config files that have a well defined syntax and or can be abstracted into a tree (JSON, YAML, TOML,…

I would naively expect that this problem is easiest to solve for languages like JSON that have an unambiguous way to be pretty printed.

Indeed. One could just do `diff $(jq . $fileOne) $(jq . $fileTwo)` and you'll end up with a "nice enough" diff even if $fileOne and $fileTwo were very differently formatted.

Re: Difftastic: A diff that understands syntax

#83
post #12

Is there a good reason why diff tools generally don’t use AST?

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…

> Because it is much easier, you don't have to build and maintain parsers for hundreds of languages.

Seems there's a good open market for such a lazy reason.

Re: Difftastic: A diff that understands syntax

#87
post #78

Earlier quoted context omitted.

Using ubuntu 20.04, I first installed cargo: curl https://sh.rustup.rs -sSf | sh Restart shell to get $HOME/.cargo/bin in PATH, then did: cargo install difftastic And ~4 minutes later, difft executable is ready. Agree though that some pre-built binaries would be fantastic!

Ah, well, if you're willing to accept having a frankensystem with a mix of packaged and unpackaged software, sure. ;) I used to do that, back in Slackware days. It's considered really sloppy and unmaintainable to admin a system like that. Things quickly get out of hand. That strategy _does_ work if you isolate it to a chroot or a container, but littering /usr/local with all sorts of locally compiled upstream is just…

I agree it leads to problems but isn't the entire purpose of `/usr/local` to be a dumping ground for locally administered (unpackaged) programs?

Re: Difftastic: A diff that understands syntax

#88
post #79

Unfortunately it's closed source, but https://www.semanticmerge.com/ has been around for a few years and works similarly, but can also merge.

I just spent a few minutes on that site and I can't even figure out how to try it out, or their pricing, or anything other than some very superficial docs, really. Is this just a pretty website, or is the software actually available anywhere?

That pages is just the technology primer. The tools are XDiff & XMerge:

https://www.plasticscm.com/pricing

Looks like no locally-run-binary/non-SaaS version. I was hoping it'd have SublimeText like model. I have no interest in trying to get my team to switch nor having to deal with the security team when it turns out I was using a free cloud account.

Re: Difftastic: A diff that understands syntax

#89
post #43

This is written by the same guy who wrote Helpful, an enhancement package for the Emacs Help buffer. I highly recommend checking out Helpful if you haven’t seen it. https://github.com/Wilfred/helpful

EDIT: Wilfred IS the original author [3]; my apologies.

Not to discredit Wilfred (it looks like he's taken over the project as the maintainer), but, based on the historical contributions [1], it looks like it was originally developed by Max Brunsfeld, who also created Tree-sitter. [2]

[1]: https://github.com/Wilfred/difftastic/graphs/contributors

[2]: https://github.com/tree-sitter/tree-sitter

[3]: https://github.com/Wilfred/difftastic/commit/958033924a2dea7...

Post reply on HN