news.volyx.in

Difftastic: A diff that understands syntax (github.com)

983 points by tempodox · 1630 days ago · 219 comments on HN

Article summary

Difftastic is a structural diff tool that compares files based on their syntax, understanding which pieces of syntax have changed and highlighting them in context. It supports over 30 programming languages and is compatible with git and other version control systems. The tool has some limitations, such as performance issues with large files and a lack of support for data formats like YAML and TOML. Difftastic is open source under the MIT license and has a community-driven development process.

Main themes

  • syntax-aware diffing
  • Abstract Syntax Trees
  • parser maintenance
  • data format support
  • performance and display limitations
  • integration with existing tools
  • customization options
  • malformed file handling

What commenters say

  • Some users find existing diff tools insufficient for understanding changes in code and appreciate the syntax-aware approach of Difftastic.
  • Support for data formats like JSON, YAML, and TOML is desirable, but may require additional parsing and canonicalization steps.
  • The use of Abstract Syntax Trees (ASTs) for diffing is seen as a promising approach, but also poses challenges like handling malformed files and maintaining robust parsers.
  • There are differing opinions on the feasibility of building and maintaining parsers for hundreds of languages, with some arguing it's a significant undertaking and others pointing to the benefits of outsourcing this task to existing parser projects like tree-sitter.
  • Some commenters suggest that test suites could provide a heuristic for correcting malformed code, but others argue that this is not a straightforward solution.
  • The development of Difftastic is seen as a step in the right direction, but some users would like to see additional features, such as support for XML and Markdown, or integration with existing tools like git diff.
  • There are concerns about the performance and display limitations of Difftastic, particularly with large files or complex changes.
  • The tool's ability to ignore non-semantic changes like whitespace and formatting is seen as a major advantage, but some users would like to see more customization options for this behavior.