ydiff

a language-aware tool for comparing programs

ydiff is a language-aware tool for comparing programs. It supports multiple languages and has an extensible design. It is not yet ready for general release, although it is already an indispensible tool to me.

ydiff is an open source project. You can follow its development on github: yinwang0/ydiff or get its source code from there. If you want to know more about it, welcome to read on and play with the interactive demos provided at the end of this page.

Why ydiff?

We very often want to know how our code is modified. This is normally done by using the diff program. While effective for finding differences between close revisions, the result from diff can be very hard to read for revisions over a long time span. The worst case is when the code is massively rearranged or refactored, where diff considers every line to have been changed.

ydiff can help in this kind of situation. Different from line-based or character-based diff, ydiff is "language-based". It parses the programs and then performs structural comparison on the parse trees. In addition to the usual functionalities of diff, it has the following properties:

These properties make ydiff helpful for understanding changes. It may also be possibly used for detecting plagiarism in programming classes or copyright infringement of code.

Why "ydiff"?

I wanted to use the name "λdiff", but having noticed how troublesome it is to type it from the command line, I decided to flip its first letter upside down.

Supported Languages

Currently ydiff supports the following languages:

I will be adding more languages.

License

GPL v3

Authors

Yin Wang (yinwang0@gmail.com)

Demos

You are welcome to have a look at the demos. They are fun to play with. The demos are interactive HTML files. All program structures are in framed nodes, whose colors mean:

The left and right windows are always locked in their relative position. A mouse click on changed, moved or unchanged nodes will highlight the matched nodes and scroll the other window to match. After that, the windows will be locked into their new relative position for browsing.

Okay, here are the demos: