AST differencing, or for short tree differencing, consists of computing the list of differences between two ASTs.<ref>{{Cite journal |last1=Fluri |first1=Beat |last2=Wursch |first2=Michael |last3=PInzger |first3=Martin |last4=Gall |first4=Harald |date=2007 |title=Change Distilling:Tree Differencing for Fine-Grained Source Code Change Extraction |url=http://dx.doi.org/10.1109/tse.2007.70731 |journal=IEEE Transactions on Software Engineering |volume=33 |issue=11 |pages=725–743 |doi=10.1109/tse.2007.70731 |s2cid=13659557 |issn=0098-5589}}</ref> This list of differences is typically called an edit script. The edit script directly refers to the AST of the code. For instance, an edit action may result in the addition of a new AST node representing a function. The problem of computing good AST edit scripts is hard, with two main challenges: handling move actions, and scaling to fine-grained ASTs with thousands of nodes.<ref>{{Cite journal|last1=Falleri|first1=Jean-Rémy|last2=Morandat|first2=Floréal|last3=Blanc|first3=Xavier|last4=Martinez|first4=Matias|last5=Monperrus|first5=Martin|date=2014-09-15|title=Fine-grained and accurate source code differencing|url=https://dl.acm.org/doi/10.1145/2642937.2642982|journal=Proceedings of the 29th ACM/IEEE International Conference on Automated Software Engineering|language=en|___location=Vasteras Sweden|publisher=ACM|pages=313–324|doi=10.1145/2642937.2642982|isbn=978-1-4503-3013-8|s2cid=218737160 }}</ref>
=== Structured merge ===
With proper AST differencing, ASTs can be used for merging versions and branches, this is known as [[Merge (version control)|structured merge]]. The advantage is to avoid spurious conflicts due to lines and formatting.<ref>{{Cite journal|last1=Larsen|first1=Simon|last2=Falleri|first2=Jean-Remy|last3=Baudry|first3=Benoit|last4=Monperrus|first4=Martin|date=2022|title=Spork: Structured Merge for Java with Formatting Preservation|url=https://ieeexplore.ieee.org/document/9684709|journal=IEEE Transactions on Software Engineering|pages=1|doi=10.1109/TSE.2022.3143766|arxiv=2202.05329 |s2cid=246823829 |issn=0098-5589}}</ref>