Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Diff
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Implementations and related programs{{anchor|Others}} == Changes since 1975 include improvements to the core algorithm, the addition of useful features to the command, and the design of new output formats. The basic algorithm is described in the papers ''An O(ND) Difference Algorithm and its Variations'' by [[Eugene Myers|Eugene W. Myers]]<ref>{{cite journal|author=E. Myers|title=An O(ND) Difference Algorithm and Its Variations|journal=Algorithmica|volume=1|issue=2|year=1986|pages=251β266|doi=10.1007/BF01840446|citeseerx=10.1.1.4.6927|s2cid=6996809}}</ref> and in ''A File Comparison Program'' by Webb Miller and Myers.<ref>{{cite journal|author1=Webb Miller |author2=Eugene W. Myers |title=A File Comparison Program|journal=Software: Practice and Experience|volume=15|issue=11|year=1985|pages=1025β1040|doi=10.1002/spe.4380151102|citeseerx=10.1.1.189.70 |s2cid=15489614 }}</ref> The algorithm was independently discovered and described in ''Algorithms for Approximate String Matching'', by [[Esko Ukkonen]].<ref>{{cite journal|author=Esko Ukkonen|title=Algorithms for Approximate String Matching|volume=64|journal=Information and Control|issue=1β3|year=1985|pages=100β118 | doi = 10.1016/S0019-9958(85)80046-2|doi-access=free}}</ref> The first editions of the diff program were designed for line comparisons of text files expecting the [[newline]] character to delimit lines. By the 1980s, support for binary files resulted in a shift in the application's design and implementation. GNU diff and diff3 are included in the '''diffutils''' package with other diff and [[Patch (Unix)|patch]] related utilities.<ref>[https://www.gnu.org/software/diffutils/ GNU Diff utilities] {{Webarchive|url=https://web.archive.org/web/20150316032418/http://www.gnu.org/software/diffutils/ |date=2015-03-16 }}. Made available by the [[Free Software Foundation]]. Free Documentation. Free source code.</ref> === Formatters and front-ends === Postprocessors '''sdiff''' and '''diffmk''' render side-by-side diff listings and applied change marks to printed documents, respectively. Both were developed elsewhere in Bell Labs in or before 1981.{{citation needed|date=February 2015}}{{discuss|topicality of front-ends}} [[Diff3]] compares one file against two other files by reconciling two diffs. It was originally conceived by Paul Jensen to reconcile changes made by two people editing a common source. It is also used by revision control systems, e.g. [[Revision Control System|RCS]], for [[merge (revision control)|merging]].<ref>{{cite web|url=https://www.gnu.org/software/rcs/manual/html_node/merge.html|title=merge (GNU RCS 5.10.0)|website=gnu.org|access-date=22 January 2021|archive-date=18 September 2019|archive-url=https://web.archive.org/web/20190918125803/http://www.gnu.org/software/rcs/manual/html_node/merge.html|url-status=live}}</ref> [[Emacs]] has [[Ediff]] for showing the changes a patch would provide in a user interface that combines interactive editing and merging capabilities for patch files. [[Vim (text editor)|Vim]] provides '''vimdiff''' to compare from two to eight files, with differences highlighted in color.<ref>{{Cite web|author-link=Bram Moolenaar|first=Bram|last=Moolenaar|url=https://vimhelp.org/diff.txt.html#vimdiff|title=Vim documentation: diff|website=vimdoc.sourceforge.net|access-date=1 May 2020|quote=The easiest way to start editing in diff mode is with the "vimdiff" command. This starts Vim as usual, and additionally sets up for viewing the differences between the arguments. <code>vimdiff file1 file2 [file3] [file4] [...file8]</code> This is equivalent to: <code>vim -d file1 file2 [file3] [file4] [...file8]</code>|archive-date=16 February 2020|archive-url=https://web.archive.org/web/20200216203940/https://vimhelp.org/diff.txt.html#vimdiff|url-status=live}}</ref> While historically invoking the diff program, modern vim uses [[git]]'s fork of xdiff library (LibXDiff) code, providing improved speed and functionality.<ref name="brabandt2018">{{Cite web|title=The power of diff|url=https://vimways.org/2018/the-power-of-diff/|date=1 December 2018|website=Vimways|access-date=1 May 2020|first=Christian |last=Brabandt|url-status=live|archive-url=https://web.archive.org/web/20181202020105/https://vimways.org/2018/the-power-of-diff/|archive-date=2 December 2018}}</ref> GNU [[Wdiff]]<ref>{{Cite web|url=https://www.gnu.org/software/wdiff/wdiff.html|title=gnu.org|website=www.gnu.org|access-date=2020-09-12|archive-date=2020-08-11|archive-url=https://web.archive.org/web/20200811124535/https://www.gnu.org/software/wdiff/wdiff.html|url-status=live}}</ref> is a front end to diff that shows the words or phrases that changed in a text document of written language even in the presence of word-wrapping or different column widths. colordiff is a Perl wrapper for 'diff' and produces the same output but with colorization for added and deleted bits.<ref>{{Cite web|url=https://www.colordiff.org/|title=colordiff|website=www.colordiff.org|access-date=2018-06-14|archive-date=2018-06-14|archive-url=https://web.archive.org/web/20180614121429/https://www.colordiff.org/|url-status=live}}</ref> diff-so-fancy and diff-highlight are newer analogues.<ref>{{cite web |title=diff-so-fancy |url=https://github.com/so-fancy/diff-so-fancy |publisher=So Fancy |date=6 May 2023}}</ref> "delta" is a Rust rewrite that highlights changes and the underlying code at the same time.<ref>{{cite web |last1=Davison |first1=Dan |title=dandavison/delta |website=[[GitHub]] |url=https://github.com/dandavison/delta |date=8 May 2023}}</ref> '''Patchutils''' contains tools that combine, rearrange, compare and fix context diffs and unified diffs.<ref>{{cite web |last1=Waugh |first1=Tim |title=twaugh/patchutils |website=[[GitHub]] |url=https://github.com/twaugh/patchutils |date=12 June 2020 |access-date=28 June 2020 |archive-date=1 October 2020 |archive-url=https://web.archive.org/web/20201001234609/https://github.com/twaugh/patchutils |url-status=live }}</ref> === Algorithmic derivatives === Utilities that compare source files by their syntactic structure have been built mostly as research tools for some programming languages;<ref>{{cite journal|last1=Horwitz|first1=Susan|title=Identifying the semantic and textual differences between two versions of a program|journal=ACM SIGPLAN Notices|date=June 1990|volume=25|issue=6|pages=234β245|doi=10.1145/93548.93574|url=http://www.cs.wisc.edu/wpis/papers/sigplan90.ps|citeseerx=10.1.1.49.3377|access-date=2017-11-01|archive-date=2010-06-12|archive-url=https://web.archive.org/web/20100612103752/http://www.cs.wisc.edu/wpis/papers/sigplan90.ps|url-status=live}}</ref><ref>{{cite journal|last1=Yang|first1=Wuu|title=Identifying syntactic differences between two programs|journal=Software: Practice and Experience|date=July 1991|volume=21|issue=7|pages=739β755|doi=10.1002/spe.4380210706|citeseerx=10.1.1.13.9377|s2cid=10853673}}</ref><ref>Grass. Cdiff: A syntax directed Diff for C++ programs. Proceedings USENIX C++ Conf., pp. 181-193, 1992</ref> some are available as commercial tools.<ref>Compare++, http://www.coodesoft.com/ {{Webarchive|url=https://web.archive.org/web/20111129033738/http://www.coodesoft.com/ |date=2011-11-29 }}</ref><ref>SmartDifferencer, http://www.semanticdesigns.com/Products/SmartDifferencer {{Webarchive|url=https://web.archive.org/web/20091014160445/http://www.semanticdesigns.com/Products/SmartDifferencer/ |date=2009-10-14 }}</ref> In addition, free tools that perform syntax-aware diff include: * C++: zograscope, AST-based.<ref>{{cite web |title=xaizek/zograscope |url=https://github.com/xaizek/zograscope |website=GitHub |date=26 May 2020 |access-date=27 June 2020 |archive-date=21 December 2020 |archive-url=https://web.archive.org/web/20201221105419/https://github.com/xaizek/zograscope |url-status=live }}</ref> * HTML: Daisydiff,<ref>''DaisyDiff'', https://code.google.com/p/daisydiff/ {{Webarchive|url=https://web.archive.org/web/20150319014218/http://code.google.com/p/daisydiff/ |date=2015-03-19 }}</ref> html-differ. * XML: ''xmldiffpatch'' by Microsoft and ''xmldiffmerge'' for IBM.<ref>''xmldiffpatch'', http://msdn.microsoft.com/en-us/library/aa302294.aspx {{Webarchive|url=https://web.archive.org/web/20091027123710/http://msdn.microsoft.com/en-us/library/aa302294.aspx |date=2009-10-27 }}</ref><ref>''xmldiffmerge'', http://www.alphaworks.ibm.com/tech/xmldiffmerge {{Webarchive|url=https://web.archive.org/web/20090924034538/http://www.alphaworks.ibm.com/tech/xmldiffmerge |date=2009-09-24 }}</ref> * [[JavaScript]]: astii (AST-based). * Multi-language: [[Pretty Diff]] (format code and then diff)<ref>Cheney, Austin. ''Pretty Diff - Documentation''. http://prettydiff.com/documentation.php {{Webarchive|url=https://web.archive.org/web/20120731233435/http://prettydiff.com/documentation.php |date=2012-07-31 }}</ref> '''spiff''' is a variant of ''diff'' that ignores differences in floating point calculations with roundoff errors and [[Space (punctuation)|whitespace]], both of which are generally irrelevant to source code comparison. [[Telcordia Technologies|Bellcore]] wrote the original version.<ref name="dontcallme"/><ref name="hpux"/> An [[HPUX]] port is the most current public release. spiff does not support binary files. spiff outputs to the [[standard output]] in standard diff format and accepts inputs in the [[C (programming language)|C]], [[Bourne shell]], [[Fortran]], [[Modula-2]] and [[Lisp (programming language)|Lisp]] [[programming language]]s.<ref>{{cite web|url=http://www.math.utah.edu/cgi-bin/man2html.cgi?/usr/local/man/man1/spiff.1|title=SPIFF 1|date=1988-02-02|access-date=2013-06-16|archive-date=2016-10-02|archive-url=https://web.archive.org/web/20161002135508/http://www.math.utah.edu/cgi-bin/man2html.cgi?%2Fusr%2Flocal%2Fman%2Fman1%2Fspiff.1|url-status=live}}</ref><ref>{{cite web|url=http://hpux.connect.org.uk/hppd/hpux/Text/spiff-1.0/man.html|title=Man page|location=UK|first=Daniel W|last=Nachbar|date=1988-02-02|access-date=2013-06-16|archive-date=2012-09-10|archive-url=https://web.archive.org/web/20120910004102/http://hpux.connect.org.uk/hppd/hpux/Text/spiff-1.0/man.html|url-status=live}}</ref><ref name="dontcallme">{{cite web|url=https://github.com/dontcallmedom/spiff|title=spiff|author=dontcallmedotcom|website=[[GitHub]]|access-date=2013-06-16|archive-date=2015-03-26|archive-url=https://web.archive.org/web/20150326181245/https://github.com/dontcallmedom/spiff|url-status=live}}</ref><ref>{{cite web|url=https://stackoverflow.com/a/1489107/2291035|date=2009-09-28|author=Davide|title=stackoverflow|access-date=2013-06-16|archive-date=2022-02-19|archive-url=https://web.archive.org/web/20220219233604/https://stackoverflow.com/questions/1428177/diff-tool-that-ignores-floating-point-formats-but-not-values-in-text/1489107|url-status=live}}</ref><ref name="hpux">{{cite web|url=http://hpux.connect.org.uk/hppd/hpux/Text/spiff-1.0/|title=HP-UX Porting and Archiving|location=UK|first=Daniel W|last=Nachbar|date=1999-12-01|access-date=2013-06-13|archive-date=2012-09-05|archive-url=https://web.archive.org/web/20120905154135/http://hpux.connect.org.uk/hppd/hpux/Text/spiff-1.0/|url-status=live}}</ref> LibXDiff is an LGPL [[Library (computing)|library]] that provides an interface to many algorithms from 1998. An improved Myers algorithm with [[Rabin fingerprint]] was originally implemented (as of the final release of 2008),<ref>{{cite web |last1=Libenzi |first1=Davide |title=LibXDiff |url=http://freshmeat.sourceforge.net/projects/xdiff-lib |website=SourceForge FreshMeat |language=en |access-date=2020-06-28 |archive-date=2020-07-01 |archive-url=https://web.archive.org/web/20200701070301/http://freshmeat.sourceforge.net/projects/xdiff-lib |url-status=live }}</ref> but [[git]] and [[libgit2]]'s fork has since expanded the repository with many of its own. One algorithm called "histogram" is generally regarded as much better than the original Myers algorithm, both in speed and quality.<ref>{{cite journal |last1=Nugroho |first1=Yusuf Sulistyo |last2=Hata |first2=Hideaki |last3=Matsumoto |first3=Kenichi |title=How different are different diff algorithms in Git?: Use --histogram for code changes |website=Empirical Software Engineering |pages=790β823 |language=en |doi=10.1007/s10664-019-09772-z |date=January 2020|s2cid=59608676 |doi-access=free |arxiv=1902.02467 }}</ref><ref>{{cite web |title=algorithm - What's the difference between 'git diff --patience' and 'git diff --histogram'? |url=https://stackoverflow.com/a/32367597/ |website=Stack Overflow |quote=This does indeed show that histogram diff slightly beats Myers, while patience is much slower than the others. |access-date=2020-06-28 |archive-date=2022-02-19 |archive-url=https://web.archive.org/web/20220219233605/https://stackoverflow.com/questions/32365271/whats-the-difference-between-git-diff-patience-and-git-diff-histogram/32367597 |url-status=live }}</ref> This is the modern version of ''LibXDiff'' used by Vim.<ref name="brabandt2018"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)