This is cool. I work with a large Python codebase that's been around for a while (hasn't been that long since it's been completely off Python 2). It's not a bad codebase, but naturally it has almost no typing annotations, and other devs are just starting to come around to the idea. I love `mypy --strict` but it produces way too much noise with all the other code, so I've been using a tool I made that runs mypy over t…
This sounds well in line with what I have been building - a tool to take syntax-aware diffs across git commits: https://github.com/bugout-dev/locust It currently supports Python, Javascript, and Java. I like the idea of mypy changes, as well.
Difftastic: Syntax-aware structured diff tool
41–50 of 62 posts
Re: Difftastic: Syntax-aware structured diff tool
#42This is cool. I work with a large Python codebase that's been around for a while (hasn't been that long since it's been completely off Python 2). It's not a bad codebase, but naturally it has almost no typing annotations, and other devs are just starting to come around to the idea. I love `mypy --strict` but it produces way too much noise with all the other code, so I've been using a tool I made that runs mypy over t…
So, I hacked together a pre-commit hook that blocked the commit only if the configured style checker registered errors on lines being added by the diff.
It never got very polished, but I wound up using it in two codebases over the years.
Re: Difftastic: Syntax-aware structured diff tool
#43code review is a necessary but painful part of releasing good code on a team; anything that makes it slightly easier is a force multiplier for companies whose main bottleneck is software
Re: Difftastic: Syntax-aware structured diff tool
#44Re: Difftastic: Syntax-aware structured diff tool
#45To ease the pain in conventional differs, we use a pre-commit hook to format the source code (prettier). This way we only see differences if something _actually_ changed.
Given the code:
foo(one, two, three);
If you add an argument and reformat: foo(
one,
two,
new,
three
);
A line-based diff can make it hard to spot what's changed.Re: Difftastic: Syntax-aware structured diff tool
#46I personally am much more excited by “sliders” than the structure-aware diffs. Marking additions between [], it is the difference between e.g. handle_case [some new case over multiple lines handle_case] some existing case [ check_invariant(); } function newFunc(){ ... ] check_invariant(); } And [handle_case some new case] handle_case old case [function newFunc(){ ... check_invariant(); }]
Syntactic differs already do better because they understand that parentheses/brackets are paired. Difftastic does OK with this example: https://imgur.com/a/pVlVBo5
Re: Difftastic: Syntax-aware structured diff tool
#47I worked on this problem for just over a decade before moving onto other things. It’s a tough problem to solve. The biggest problem I ran into is that the largest segment of user growth were too fickle. They wanted all kinds of magic in new optional features for their personal preferences that took incredible effort. I lacked the analytics to see who used which exotic features. Most of these people just wanted a beau…
I'm hoping that defining syntax in a separate TOML file will let end users extend difftastic for their own languages/config files. I want to keep difftastic small and manageable.
Re: Difftastic: Syntax-aware structured diff tool
#48I'd feel so much more motivation for checking out alternative diff tools if there was a better story for integrating them with the review tools in Github, GitLab, etc. I know there's nothing anyone can do about that— it's something the Git hosts themselves have to enable, or I have to see enough benefit in it to go to an dedicated review tool to make the bother of that worthwhile. I believe Gerrit has a pluggable dif…
I still look at diffs in the terminal pretty often, but all my code reviews are in rendered HTML.
That said, there needs to be a credible tool before review tools can adopt it! GitHub does a line-based diff with word-based highlighting, which is probably the best you can do without syntactic smarts.
Re: Difftastic: Syntax-aware structured diff tool
#49I think you'd need another parser/syntax interface for this to work. E.g. running a binary that you can submit source code to which responds with a JSON file containing the parsed tokens. That way you can reuse the compiler's parser.
Re: Difftastic: Syntax-aware structured diff tool
#50How can he have crashes if it's written in Rust?
Probably meaning 'panic' - e.g. unwrapping a Result without allowing for an error result.
I will tidy it up at some point, but I spend too much time throwing away ideas that don't work. Defensive code is silly if you delete it after!