I think I have heard of their product before, and reading the blog post intrigued me, so I wanted to try it, but... VS Code Integration? GitHub Integration? No standalone version which you could actually use as a diff tool for git locally? Ok, I guess only having a "cloud" version makes licensing easier, and you can call me old fashioned, but seeing an eminently "offline" task such as diff being turned into "online-o…
How far should a programming language aware diff go?
21–30 of 54 posts
Re: How far should a programming language aware diff go?
#22Anyway, it seems the "Level 3: semantic diff" actually could be divided into different levels. But "Level 4: Mostly identical" seems quite problematic.
Re: How far should a programming language aware diff go?
#23Hopefully this tool gives a dev ready control of what kinds of differences to hide/show.
I'm actually not convinced of the concept of semantic diff (not talking just about this tool specifically)... when we talk about code that is different but equivalent, I think we're talking about elements of style.
It seems to me that it would pretty much always be better to normalize the elements of style considered insignificant, rather than hide them just in the diff tool. That covers diffing as well as viewing/reading the code.
If you don't care about a particular element of style then either it shouldn't be coming up much or I think you'd be better off using some kind of enforcing/fixing linter.
Re: How far should a programming language aware diff go?
#24Re: How far should a programming language aware diff go?
#25The problem is that even a lot of the changes that normally constitute clutter can become relevant in certain situations or even introduce bugs.
One example would be ordering of Python imports: Changing the order of imports should have no effect on program behaviour if all your packages are well-behaved - and in 99.99% of cases it indeed hasn't. But the fact remains that imports are statements that are executed and can have side-effects. If a package does something nontrivial during load, changing the import order can have effects. Hiding such a change could mask introduction of a bug.
Hiding changes can also lead to confusion if you are trying to understand a series of changes that are based on each other, or if all changes of a commit are hidden. I've had the latter situation with IntelliJ, where the working tree was shown as "unclean" but the diff was completely empty. Solution: The diff wasn't actually empty, IntelliJ was just set to hide the changes.
I think a more interesting solution would be to build a sort of "tree of changes": At the bottom, you'd have the individual changes in the file; one level up, the changes would be grouped into higher-level operations, such as "change formatting", "rename identifier", "remove field", "move function", etc. If possible, those could be grouped into even higher-level changes, such as "implement new class" or "extract expression into function", etc.
Re: How far should a programming language aware diff go?
#26How does semanticdiff compare to that? Anyone got experience?
Re: How far should a programming language aware diff go?
#27Re: How far should a programming language aware diff go?
#28After switching to difftastic for semantic diff, I have never looked back. ( https://github.com/Wilfred/difftastic ) How does semanticdiff compare to that? Anyone got experience?
As author of SemanticDiff, I am obviously a bit biased. But Wilfred, the author of difftastic, found the analysis to be "pretty even-handed" [1], so I think it should be somewhat fair.
Re: How far should a programming language aware diff go?
#29Re: How far should a programming language aware diff go?
#30Earlier quoted context omitted.
My guess would be that quite a large portion of changes we'd expect at a glance to be identical aren't, especially for inputs that would not be expected. I'd also guess this is much more likely in languages in which valid code commonly produces undefined behavior. If the tool could show you, for example, "this change is functionally identical except for when the sum of the two inputs overflows a UInt64", that'd be pr…
That would neat, although I suspect most compilers/linters should already be able to warn you about potential overflows. If you want to boil down what devs are looking for in a diff tool to one thing, it would be "which change(s) between these two versions of code result in a different binary (or AST/opcodes/bytecode, depending on the language)?" All other changes, while certainly sometimes useful to know about, are…