Live data from Hacker News

Difftastic: A diff that understands syntax

github.com

161–170 of 224 posts

Re: Difftastic: A diff that understands syntax

#161
post #139

Earlier quoted context omitted.

In another comment you're asking about vim support. So let me get this straight: You're using vim, yet you're unable to resolve the error message = note: /usr/bin/ld: cannot find Scrt1.o: No such file or directory /usr/bin/ld: cannot find crti.o: No such file or directory Have you tried googling for "ubuntu crti.o: No such file or directory" ?

>Have you tried googling for "ubuntu crti.o: No such file or directory" ? Depending on the project, there is a certain threshold of trying-to-make-something-work which I'm willing to undertake in order to test an app. But you are right. I'm sorry if my OG comment may come arrogant to the devs who do stuff for free. (♥ to the devs) [edit]: ok, I tried again, `sudo apt update && sudo apt install build-essential` before…

Funnily enough, the error is in a C dependency providing Haskell support.

    vendor/tree-sitter-haskell-src/scanner.cc

Re: Difftastic: A diff that understands syntax

#162
post #46
post #42

Earlier quoted context omitted.

I think it's wonderful that there's an explosion of new exciting languages, it can only improve the quality of all our tools. I for one am looking forward to replacing my eons of MATLAB experience with Julia. But I wish there was more of a convention in the F/OSS community that if your software isn't written in something universal (C, C++, shell and maybe python), then it also comes with a container of all that's nec…

>shell >universal * laughs in Windows, then cries *

FWIW I've had reports of people using difftastic on Windows successfully.

Re: Difftastic: A diff that understands syntax

#163

The documentation says: > Difftastic output is intended for human consumption Why not separate the human-consumption part and the underlying parsing part? Or at least provide both in the same utility?

The underlying parser is just tree-sitter, which is a reusable (and excellent) parsing library.

Difftastic then converts the tree-sitter parse tree to a simpler s-expression style format (see https://difftastic.wilfred.me.uk/parsing.html#simplified-syn...), and computes differences on that.

I'm just trying to clarify that I'm not generating conventional 'unified diff' patches, so I can provide a nicer interface (e.g. line numbers).

Re: Difftastic: A diff that understands syntax

#164

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

It's really hard! :)

(1) Parsing an arbitrary language is hard. Without tree-sitter, difftastic would probably be a lisp-only tool. You also want a parser that preserves comments.

(2) Inputs may not be syntactically well formed.

(3) Efficiently comparing trees is extremely difficult (difftastic is O(N^2) in time and memory).

(4) Displaying tree diffs is equally difficult. Alignment is particularly challenging when your 'unchanged before' and 'unchanged after' are syntactically the same, but textually different.

Re: Difftastic: A diff that understands syntax

#165
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.

https://github.com/andreyvit/json-diff works really well for JSON diffing in my experience.

It's more simplistic than difftastic though: it considers `1` and `[1]` to have nothing in common.

Re: Difftastic: A diff that understands syntax

#166
post #35

Earlier quoted context omitted.

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

Sure, but first I had to figure out wtf "cargo" is. :P Also, `cargo install difftastic` AIUI pulls it from a central location, if I'm gonna poke at software for the first time, I enjoy building it myself first, so I can get my hands dirty in the source. :) EDIT: Also, the build fails. :( "error: unexpected token: `include_str` --> /home/loxias/.cargo/registry/src/github.com-1ecc6299db9ec823/radix-heap-0.4.2/src/lib.r…

This looks like you're using a version of Rust older than the minimum required (1.56).

Re: Difftastic: A diff that understands syntax

#168
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,…

This is kind of like the problem of programmatically analyzing AWS IAM roles and policies to understand impact of changes. Very difficult to do in JSON format but worth tons of money to CISOs if it can be solved.

Re: Difftastic: A diff that understands syntax

#170
For easy git usage I created these two scripts in my PATH instead of using using git config:

git-difft:

  #!/bin/sh
  GIT_EXTERNAL_DIFF=difft git diff "$@"
git-showt:

  #!/bin/sh
  GIT_EXTERNAL_DIFF=difft git show --ext-diff "$@"
Then you can run "git difft …" or "git showt …" if you want to use it.
Post reply on HN