News for hackers. Stuff that matters.
Re:Types are the basic tool of software design by slooonz on Friday January 03, 2025 @02:36PM (#42588756)
You want diff to know the syntax and semantics of every programming language out there ?
Re:Types are the basic tool of software design by knubie on Friday January 03, 2025 @02:53PM (#42588889)
This is possible already with tools like difftastic.

https://github.com/Wilfred/difftastic

Re:Types are the basic tool of software design by DarkPlayer on Friday January 03, 2025 @04:27PM (#42589655)
Difftastic would not solve the issue described by madeofpalk because it still highlights the added comma. You need a diff tool that can distinguish between optional and required syntax. So far I am not aware of any tool that supports this, except the one I am working on (SemanticDiff).
Re:Types are the basic tool of software design by benatkin on Friday January 03, 2025 @06:23PM (#42590585)
I'm pretty sure this counts. https://github.com/afnanenayet/diffsitter

Certainly the idea has been suggested many times. I think people end up formatting both before/after and doing a diff on formatted before against formatted after. I've done that.

Re:Types are the basic tool of software design by benatkin on Friday January 03, 2025 @02:48PM (#42588852)
It would be like a syntax highlighter. It’s doable.
Re:Types are the basic tool of software design by slooonz on Friday January 03, 2025 @03:50PM (#42589346)
But diff does not exists in a vacuum. It would need to be integrated to IDEs, editor, merge tools, PR tools. You now have to have `patch` understand and depend on the details of the syntax of your language. In a way that may break between different versions of diff and patch. Not even starting with variants of a language, different interpretations of how to handle the preprocessor/macros system, different editions of the same language.

All that, just to not have to add a trailing comma ?

Re:Types are the basic tool of software design by benatkin on Friday January 03, 2025 @04:30PM (#42589688)
Most things like patch would still use line diff. I think I would want this semantic diff in the merge request review and the logs. It could have definitions distributed with the syntax highlighters in language plugins in an editor/IDE, git CLI, and git forge.
Re:Types are the basic tool of software design by from-nibly on Friday January 03, 2025 @07:41PM (#42591069)
So GitHub, git lab, gutbucket, gittea (and its 50 forks), fossil, and all the other tools should change, not the formatting of the code?
Re:Types are the basic tool of software design by benatkin on Friday January 03, 2025 @08:20PM (#42591353)
No, having a concise separator is still preferable to saving a line in a diff.