Funny side note: I had a flat mate once who was on a working holiday from Japan. He was in love with and endlessly curious about English slang, it’s basically all we talked about. I remember explaining to him why my uni friends and I referred to things as being “craptastic”, starting with American marketing’s love affair with the portmanteau. He got it pretty quickly and enjoyed using it in conversation. The saying t…
Difftastic: A diff that understands syntax
201–210 of 224 posts
Re: Difftastic: A diff that understands syntax
#202Re: Difftastic: A diff that understands syntax
#203Re: Difftastic: A diff that understands syntax
#204This 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…
Re: Difftastic: A diff that understands syntax
#205This 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…
$ cat /usr/local/bin/difftastic
#!/bin/sh
source $HOME/.nix-profile/etc/profile.d/nix.sh
nix run nixpkgs.difftastic -c difftastic "$@"
and then it'll install on first run: $ difftastic
these paths will be fetched (1.17 MiB download, 9.38 MiB unpacked):
/nix/store/wn74xn0w60xcwsly6nqaibn205hh2qms-difftastic-0.8
copying path '/nix/store/wn74xn0w60xcwsly6nqaibn205hh2qms-difftastic-0.8' from 'https://cache.nixos.org'...
Difftastic 0.8.0
Wilfred Hughes
A syntax aware diff.
USAGE:
[etc.]Re: Difftastic: A diff that understands syntax
#206Is 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…
But why? Shouldn’t the code you push into a repository be at least syntactically correct? And even if it is not, one can simply fallback to textual diff.
> 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.
I don’t see how it is a blocker.
Re: Difftastic: A diff that understands syntax
#207Re: Difftastic: A diff that understands syntax
#208Earlier quoted context omitted.
Not OP, but the docs call out some "Tricky Cases" [1]. [1] https://difftastic.wilfred.me.uk/tricky_cases.html
I’d imagine there’s some challenging judgement calls that such a tool would have to make. Like, in Go, you can reorder the members of a struct definition. In many cases this is just diff noise to reviewers. HOWEVER, it does impact the layout of the struct in memory, so it can be semantically meaningful in performance work.
Just thinking about it makes my head spin. I spend a lot of time working out font/color hierarchies, supplementary to coding and data viz. Arguably what you're bringing up is a case for a carefully colored diff that visually cues whether something is a true semantic change or indicative of a lower level issue. I'm comfortable with reading a plain ol' diff that just shows me what changed, superficially, and interpreting it. While I think OP's idea is awesome, it also might create more confusion than it resolves; and resolving confusion is the point of a diff.
Re: Difftastic: A diff that understands syntax
#209Earlier quoted context omitted.
PHP long stated that associative array sorting order was unstable and not guaranteed (especially when the union (+) operator or array_merge function were involved) - that doesn't mean ten bazillion websites wouldn't instantly break if they ever actually changed the ordering to be unpredictable. Language designers need to contend with the fact that the ultimate final say in whether a thing is or not is whether that be…
Didn't ruby actually do exactly this though? And it broke a million websites and they changed it back in the next version and have made it explicit ever since? To me that is much stronger evidence than what we think would happen if php did it.
> If one or more of the communications can proceed, a single one that can proceed is chosen via a uniform pseudo-random selection.
https://go.dev/ref/spec#Select_statements
In an early implementation it would pick in lexical order, IIRC (and the specification did not mention how a communication should be picked). Not only could this lead to bugs, apparently some people were relying on it and they didn't want that.
Re: Difftastic: A diff that understands syntax
#210For 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.