SemanticDiff is a Visual Studio Code extension to help you understand code changes faster by removing noise and adding useful annotations.
You can try a subset of SemanticDiff’s features directly in your browser.
Go ahead and select one of the examples or enter your own code.
Want to try the VS Code extension?
SemanticDiff is a programming language aware diff for Visual Studio Code that hides style changes and adds useful annotations. Understand code changes faster and make sure no critical details are missed. No matter if you are checking your own code before committing or when reviewing a pull request.
Why spend time on reviewing the output of your code formatter? Let the CI validate the code style, while you concentrate on the logic changes.
When moving a lot of code, it is easy to overlook that print statement you added while debugging. It is buried in a huge hunk of red and green lines. Wouldn’t it be great if your diff tool would highlight such modifications?
Refactorings are often simple but can affect many lines of code. Checking all the individual changes is often too tedious so that other unintended changes get overlooked. SemanticDiff assists you by automatically separating refactorings from other code changes.
Interested in new features and releases?
Enter your email to stay up to date.
Learn more about SemanticDiff.
git diff
and the GNU diffutils
being the most popular ones.
Common diffs treat source code as text files, and generate a visualization based on a simple line-by-line comparison. This is far from perfect: There are many types of code changes, such as inserting line breaks between function arguments, that don’t have any effect on the software but are displayed as changes. This adds a lot of visual noise and makes it difficult for developers to spot the relevant changes.
In contrary, a semantic diff (or also called structural diff) understands the meaning of the change. It can, for example, distinguish between relevant and irrelevant changes, and recognizes when changes correspond to a typical refactoring pattern, like moving code or renaming a function. Instead of showing lot of changed lines, a semantic diff will show an abstract description of the change, e.g., that a function has been renamed.
SemanticDiff works similar to a compiler or interpreter. Given two source codes to compare, they are first converted to Abstract Syntax Trees (ASTs). This step adds additional information that enables us to filter out various style changes, like adding optional semicolons or commas in an array initialization.
In a second step, we match both trees to find out what has changed. Additional rules are applied to filter out more complex invariances. Afterwards the detected changes are translated back into a text diff representation.
The SemanticDiff beta supports most programming languages relevant for web development. We plan to add more languages based on the user feedback we receive. The currently supported programming languages and data exchange formats are:
Yes, of course! Simply open the corresponding code diff, either by using the VS Code extension provided by your Git hoster or by checking out the code locally and manually opening the diff in VS Code. Then switch to SemanticDiff by clicking on our logo in the top right corner. Please note that not all features, such as adding comments, may be available in the SemanticDiff view.
If you are looking for a better out-of-the-box experience, check out MergeBoard. Our code review software not only allows your team to use the SemanticDiff technology collaboratively, but also offers other benefits like better communication tools.
SemanticDiff is able to detect moved or copied blocks of code, as well as renaming of variables, functions, and classes. Additional types of refactorings will be added over time. If you have suggestions on what should be recognized, feel free to open a feature request in our bug tracker.
Please note that not all of these features may be available in the beta version yet.
There are very few other tools that can generate structural/semantic diffs. The ones we know of focus on supporting a wide variety of programming languages at the expense of accuracy and not supporting advanced features.
In contrast, our goal is to develop software that delivers correct results that developers can rely on. This is also an important requirement for advanced features, like detecting refactorings. We therefore support only a small number of programming languages at the moment, for which we want to improve support together with our beta testers.
Do not hesitate to contact us if you have any questions or feedback.
We look forward to hearing from you.