Towards Semantic Version Control
The new release we’re announcing today, BL677, includes a feature that pretty much explains what our vision for the future is: semantic version control.
It may sound like big words but it is a pretty simple concept: the version control “understands” the code. So when you diff C#, Java code, C, VB.net (and hopefully all languages in the near future), it knows how to handle it:
Built-in semantic diff for .NET and Java
Take a deeper look at the previous screenshot to see what is going on. The method “HashToHex” was just below the constructor and now (right side) it was moved below “GetFile” inside a new class named “Hasher”. Plastic knows that: you see how the method has been marked as “changed and moved” (“C” and “M”), and how the new class is marked as “added” too (“A”).
And here is how a regular “text based diff” shows the same thing:
The advantage is clear: Plastic is saving you time helping you focus on what really happened. If detects the refactor, so you don’t have to find it yourself.
How is this important? Well, reviewing code is part of the job of any developer these days, and what we’re looking for is to make it simpler. The semantically decorated diff is another step towards that goal.
Ignore format changes
Look at the following diff: you see how the “FileCache constructor” was slightly modified, while “GetFile” was just reformatted, splitting lines.
And now let’s see what happens when you show the semantic differences:
It simply ignores the change in “GetFile” because it knows it is just a formatting change, helping you focus on important stuff first. Of course this will be configurable in upcoming releases.
The road to semantic
The ones of you who read our blog regularly already know that we’ve been on this for a while.
- First we created Xdiff/Xmerge back in 2008, it feels eons ago now. It was code agnostic, didn’t use a parser, but it helped finding (and merging!) moved blocks of code. It is still a key part inside our diff and merge tools.
- Later we created “method history” based on Xdiff and then on Semantic.
- We then worked on SemanticMerge, our “other” product.
- After releasing Semantic we realized the approach to diff and merge was radically different from the traditional layout in diff and merge tools. That’s why we decided to replace our textbox as the basis to create this new approach to semantic diffing and merging, with annotations on the text instead of the schematic rendering that Semantic uses. By the way, the goal is to release SemanticMerge 2.0 based on what you see here today.
Next goal: simplifying diffs by highlighting changes that matter
We find ourselves diffing big changes from time to time, like a big refactor that had to touch 100-200 files or so. When that happens, there’s a process going on in our minds:
- Hum... 200 files... ouch! I’ll go and grab a coffee. Focus and first 5-10 minutes lost.
- You get back and start going through the files... changes here and there, taking notes... Hum... this is hard, let’s check the email.
So you’re basically put off by the number of files to review. Chances are that many of these 100-200 files just contain really simple changes, like methods being renamed, “usings” modified (we do C#), and stuff like that.
Wouldn't it be helpful if you were presented something as follows?
It would greatly help seeing, at first sight, that most of the files to review only contain trivial changes. You wouldn't be put off, you wouldn't lose focus and you’ll be more productive. That’s basically what our vision is, and we are already working on this improvements as I write this lines :-)
At this point we’re working at full speed on a new release which will introduce new semantic features, so stay tuned because we’ll be blogging about it real soon :-)
You can download BL677 from our labs section.