Supports 10+ programming languages and data exchange formats:
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.
SemanticDiff is a programming language aware diff that distinguishes between relevant and irrelevant changes. Irrelevant changes such as added/removed whitespace, optional commas or unnecessary parentheses are hidden to help you focus on the actual changes. Relevant changes are further analyzed to highlight moved code, renames or other refactorings. This helps you understand code changes faster, especially when working with reformatted or refactored code.
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?
See it live in action.
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.
Get updates on our SemanticDiff VS Code Extension and GitHub App, and be the first to know about new devlogs, tutorials, and blog posts.
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. If you want to review a public GitHub pull request you can simply open our GitHub App and enter the URL of the PR.
The second option is to use our Visual Studio Code extension to review merge requests. 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.
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.