The output of the `diff` command is the defacto standard for displaying and distributing file differences (AKA patches) on UNIX systems. Comparing versions of source code is the usual application, but "diffs" are generally useful for comparing entities by formatting them as lines of text so that they can be compared.

However I find it very difficult to read the output from the diff command. At the terminal, the VIM editor will syntax highlight opened diff files which helps, or even a simple script can be used for this. However I find side by side comparison of files much easier to interpret, and given the current trend towards wider screens, this is quite practical. Note that to ease side by side comparison of files, it's another good reason to restrict the line lengths in your files, preferably to less than 80 characters.


mergely provides both javascript source to integrate a side by side viewer/editor into your website/browser, and an online instance for use. One can upload local files, or even link to arbitrary URLs so that one gets a dynamic diff viewer. Below for example we show all the changes made to my l script through github, and one can click on the picture to get an up to date view in your browser (Notice the use of lhs and rhs URL parameters in the link).

Mozilla Thunderbird - Colored Diffs addon

The "Colored Diffs" addon is available for the email client I use, Thunderbird. I get a lot of email containing patches either directly from SCM systems, or from mailing lists of open source projects, so this addon helps me parse these quickly. There are useful options like highlighting whitespace so one can see whitespace damage that email clients are prone to do. By hovering over the screenshot below one can see the standard Thunderbird display without the addon.


Tkdiff is actually part of the TkCVS project, and was the graphical diff tool I used mostly for the last 7 years. It has separate utilities for merging (tkmerge) and managing repositories (tkcvs), and is very functional, with interline diffs etc. However it has some problems mainly due to the poorly maintained tools it's built on, i.e. Tcl/Tk. The main problem I noticed was the very slow cold cache startup because the disk went into a seek storm. I analysed this a bit using strace, and it's because Tcl essentially does find /usr/lib/ /usr/share/ -maxdepth 2 -type f -name pkgIndex.tcl looking for packages to load, on each startup. Coincidentally I notice that Tcl/Tk 8.5 has just been released after 5 years of development. There is mention of fixing this performance issue with new support for modules as opposed to the traditional packages, but tkcvs would have to be modified to take advantage of this. Also even in Tcl/Tk 8.5 there still have been no hooks created for GTK or QT, so applications still look clunky and out of place on linux as you can see below. Note the windows and Mac ports of Tk are well integrated into the GUI in this new version of Tcl/Tk, which is surprising. [Update Aug 2008: There have now been hooks created for GTK+ and QT].


Due to the problems mentioned with Tkdiff above, I've recently switched to using Meld. It provides all the functions that TkCVS does, but in separate tabs instead of separate utilities. It uses the well maintained and elegant PyGtk toolkit, which I've used myself for applications, and so integrates well into the linux desktop at least. If you hover over the screenshot below you can switch between its repository and file comparison views, and with my version (1.1.5), there are plugins provided for the svn, cvs, bzr, mercurial, monotone and tla SCM systems. One very handy thing I noticed that Meld supports is in-place editing of the files being compared, and also very easy merging by clicking on the icons in the center bar. The most common way I use Meld is to review my local changes before committing them to the perforce and subversion SCM systems I use, and to support this I have a handy script. Note if one prefers the KDE environment rather than Gnome/GTK+ then the analogous KDiff3 utility may be more suited.

Google Code - changeset viewer

Recently Jenan Wise from google added a changeset viewer to their project hosting web interface. Coincidentally the "Colored Diffs" project mentioned above is hosted on Google Code, so you can view its latest changes as an example. The screenshot below shows the representation of a particular change, where a summary of the diff is shown, and one can drill down further to get a full side by side file comparison of the change.

Github - changeset viewer

Github has a useful interface for (re)viewing changes to a file or more generally change sets to a project, including a visual diff viewer. For details see leveraging github for presentation of changes.


For completeness I'll mention "ExamDiff" which I first used at least 10 years ago (1998), when I was still using the windows platform. It was the first side by side comparison program I used, and I've been a convert since then. Now I haven't used windows for 7 years now, so I'm not sure that this is still the best tool for the job? Considering like most windows applications, it's closed source and somewhat crippled until you pay for it, I'm not providing it any link juice. Note that the KDiff3 utility menitoned above also provides a windows installer, and wikipedia has a list of file comparison tools which lists other free and open source windows and Mac OS X options.

© Feb 13 2008