The simplest plagiarism check is a Python script wrapped around difflib. Run it over a linked-list assignment in CS2 and it can flag nothing at all, even when several pairs in the cohort were clearly written together and only careful reading by hand will find them.
Run the same archive through a modern pipeline and those pairs surface in seconds. That gap is the whole story of code similarity detection in miniature, and it is worth understanding generation by generation, because many tooling arguments in department meetings are really arguments between 1995 and 2024.
So consider an experiment. Take a pool of past submissions, plant known copies with deliberate disguises, and run four generations of matching technology against the set. What follows is the method and an honest account of where each approach breaks.
The method, and why you should seed your own ground truth
Real plagiarism cases are inconvenient research subjects. You never know the true positive rate because you never learn about the copies you missed. So build ground truth by hand.
Say the archive covers two courses: CS2 in Java and a data structures course in Python. Take 40 clean submissions, produce one disguised duplicate of each, and remove the originals from the pool so every planted pair is the only instance of that solution in the set. Then label the 80 files as known-positive and everything else as presumed independent (unless every remaining pair is audited by hand, a "false positive" here means a presumed-independent file that got flagged, not confirmed innocence).
The disguises should mirror what students actually do when they are trying not to get caught, which is also what students do when they are legitimately collaborating and trying not to look suspicious. Five transformations, eight pairs each: identifier renaming, reformatting with comments stripped, a for loop rewritten as a while, a 30-line method split into three helpers, and a switch converted to an if/else if chain. These map roughly onto what the clone-detection literature calls Type-1 through Type-3 clones, covered below.
1974 to 1993, when a diff was the whole idea
Unix diff shipped in 1974 and it computes a longest common subsequence over lines. For source code it is close to the worst possible representation: rename one variable and every line containing it is "different," reformat and every line moves. The first purpose-built tools understood this. Dick Grune's SIM, circulating at VU Amsterdam from the late 1980s, tokenized programs before comparing them and used dynamic programming to align token sequences, which is a genuine conceptual leap: compare the structure, not the text.
SIM also introduced the thing that would define the next thirty years of argument, which is a similarity threshold you have to tune. Set it low and you drown in flags. Set it high and the interesting cases, the ones where a student changed just enough, slip through.
import difflib, itertools, pathlib
subs = {p.name: p.read_text() for p in pathlib.Path("subs").glob("*.java")}
for a, b in itertools.combinations(sorted(subs), 2):
r = difflib.SequenceMatcher(None, subs[a], subs[b]).ratio()
if r > 0.85:
print(f"{r:.2f} {a} {b}")
That is essentially a basic difflib script, and essentially SIM's ancestor with a worse algorithm. Against a seeded set like this at a 0.85 threshold, it catches the renamed-identifier pairs reasonably well, because renaming short variables rarely moves the character-level ratio much. It does worse on reformatted pairs, and it catches nothing that has been restructured.
The fingerprint era, MOSS, and the winnowing algorithm
Alex Aiken released MOSS at UC Berkeley in 1994 and it is still running. The algorithm underneath was published later, in the 2003 SIGMOD paper by Schleimer, Wilkerson, and Aiken on winnowing, and it is worth stating plainly because it explains both why MOSS works and where it fails.
You tokenize the source with a language-specific lexer, so whitespace and comments vanish and identifiers can be normalized. You take every contiguous k-token sequence (k is typically around 25 to 40 depending on language). You hash each one. Then you winnow: from each window of hashes, keep the minimum, which yields a sparse but guaranteed-dense fingerprint set. Two documents that share a long run of tokens will share fingerprints no matter how the surrounding code was rearranged, because the guarantee is that any match of length at least k will produce a shared fingerprint.
The winnowing guarantee is the reason MOSS survived three decades of refactoring tricks: any copied run of tokens longer than k cannot hide, no matter what the student does to the rest of the file.
Against a seeded set like this, MOSS at default settings is perfect on renaming and reformatting, as you would expect. It is weaker on structure change: loop rewrites, method extraction, and the switch conversion all slip through some of the time. When you split a method in three, no contiguous 30-token run survives intact across the boundary, and winnowing is fundamentally about contiguous runs.
Two operational notes. The result pages are ephemeral, gone within a couple of weeks, so export the HTML the same day or lose the evidence. And the submission mechanism was designed for a batch job in 1994 and still behaves like one, which is fine until you need to explain a flag to a student's advisor in a meeting that starts in ten minutes.
Token sequences, greedy string tiling, and why JPlag held on
JPlag arrived from the University of Karlsruhe in 1996, from Prechelt, Malpohl, and Philippsen, and it also works on token sequences, but with greedy string tiling rather than fingerprints. GST (Michael Wise, 1993) finds maximal common substrings and marks them, then repeats on the unmatched remainder, which means it can produce several disjoint matched regions between the same two files instead of one aggregate score. In practice this is a much better fit for the question a human actually asks, which is "show me the parts that match," not "give me a number."
Newer JPlag releases rebuilt the pipeline and added a proper HTML report format. In token mode it handles method extraction better than winnowing does. It remains a sensible choice for a department with no budget and one technically comfortable person to run it.
The flag that bites everyone is --min-token-length, which defaults to 9. Leave it alone and a two-line helper function that got extracted and renamed will never be reported, because it is under the floor. A 6-token threshold can reframe a case headed for a full honor code hearing as "these two students share a utility function and nothing else," which is a different conversation. Whatever value you pick, document the rationale and say so in the syllabus.
Syntax trees enter, and clone research crosses over
The idea that source should be compared as a tree rather than a string did not come from the plagiarism community. It came from clone detection, the industrial cousin of this work. Ira Baxter's work on Design Maintenance Systems in the mid-1990s used abstract syntax trees for diffing, and by 2007 the field had a serious benchmark: Bellon and colleagues compared six clone detectors and found, uncomfortably, that the tools barely agreed on what a clone was. Each detector's output overlapped the others' by a small fraction.
That finding shaped everything after it. Roy and Cordy's 2007 survey formalized the Type-1 through Type-4 taxonomy that the seeded transformations map onto, and it reframed the problem: you are not looking for identical text, you are looking for a distance metric over semantics, and any single metric is a proxy.
An AST matcher (think GumTree-style tree edit distance, or Dolos, from the Dodona team at Ghent University) normalizes the tree before comparing it. Renaming vanishes because leaves are compared by type. Reformatting vanishes because formatting is not in the tree. Method extraction is caught because you compare subtrees, and a subtree that got hoisted into a helper is still a subtree. On a seeded set like this, an AST matcher catches most of the method-extraction pairs too.
What it still misses is the control-flow rewrite. Converting a switch to an if chain changes the tree's shape at a level that tree edit distance charges heavily for. It is weakest when the student also reordered the cases.
What code similarity detection actually bought us, generation by generation
That is the real tradeoff nobody puts in the tool documentation. Better matching tends to produce fewer flags, but each flag is harder to adjudicate, because the matcher is now catching structural similarity that requires a human to distinguish from "two students both wrote the obvious merge sort." The most precise flags are also the most expensive to review, and reviewer time is the budget line that never appears in the comparison chart.

Part of that review time is the side-by-side diff. The rest is the part that tooling never solved until recently: figuring out whether the submission timestamps make the copying direction plausible, checking whether the two students were ever in the same lab section, and opening last week's assignment to see whether they were already converging. That is a database problem disguised as a similarity problem. A good review spreadsheet ends up with many columns that are not about the code at all.
2022 to now, when the source of the code changed
Everything above is about copied code and the assumption underneath it is that a copy has a human author who started somewhere. GitHub Copilot went generally available in June 2022. ChatGPT shipped on November 30 of that year. Stack Overflow's 2024 developer survey put AI tool use at 62 percent of respondents, up from 44 percent the year before. For a grading pipeline, the relevant number is not 62. It is that recent submissions contain a class of file with no peer. There is no second submission to match against.
Similarity detection is structurally blind to this. Winnowing, GST, and tree edit distance all answer "is this like something else in my set?" When the answer is "no, it is like something in a training corpus," every one of those algorithms returns zero and the assignment comes back clean.
A very low similarity score and a very high AI score can describe the same file. A tool that reports only the first number is not lying to you, it is answering a different question than the one you asked.
The signals are different in kind, too. Detection on the generation side looks at token-level predictability (perplexity, which for code means how surprised a language model is by each token given the ones before it), at variance across a document rather than within a document, and at stylistic tells: uniform comment density, defensive checks that no student would write, documentation strings on private methods, consistent Optional usage in a course that has not taught Optional. None of that is similarity. You cannot get there by comparing files to each other.

This is the point where running two separate tools stops making sense. Codequiry does the peer and web comparison with token, AST, and fingerprinting passes that survive renaming and reformatting, and it runs an AI-generation pass over the same upload so the report has both numbers next to each other. The workflow change is smaller than it sounds and bigger than it looks: one CSV, four score columns, sorted by max rather than by peer alone. When the peer score is low and the AI score is high, you know which conversation you are having before you open the file.

Why one detector stopped being enough
The honest summary of the tool comparison landscape in 2025 looks like this.
| Tool | Origin | Core method | AI-generation scoring | Web and GitHub corpus |
|---|---|---|---|---|
| SIM | VU Amsterdam, late 1980s | Token-level dynamic programming | No | No |
| MOSS | UC Berkeley, 1994 | k-gram fingerprints plus winnowing | No | No |
| JPlag | Karlsruhe, 1996; 4.x in 2023 | Greedy string tiling, tree mode added | No | No |
| Dolos | Ghent University | Tree and token fingerprinting | No | No |
| Turnitin | 1997; AI writing flag 2023 | Text corpus matching | Text only, not source code | Yes, for prose |
| Codequiry | Commercial, API and dashboard | Token, AST, and fingerprinting combined | Yes, per file and per submission | Yes, GitHub and open web |
Nothing here is a criticism of MOSS or JPlag. They are free, they are maintained by people who care, and MOSS in particular is a small miracle of longevity. But the problem they were built to solve was scoped in 1994 to a closed set of student files, and three of the four things instructors now need to check (AI generation, code lifted from GitHub, code lifted from a tutorial site) fall outside that scope. If you want to see how the two approaches differ on the same submission set, there is a side-by-side comparison of Codequiry and MOSS that walks through it.
What has not changed in thirty years
The threshold argument. Every tool since SIM has asked the instructor to pick a number, and every instructor picks it in a hurry and then defends it in a hearing. Writing the number into the syllabus with a one-paragraph explanation of what it means heads off most of the "my score was 41 percent, is that plagiarism" emails.
The review bottleneck. A detector has never once decided a case. It ranks, and a human adjudicates, and the human's time per flag has gone up, not down, as the matchers got better.
And the false accusation risk, which is the one that matters most. Even the best matcher will flag some presumably independent pairs. Those are the files where two students both wrote the same obvious solution to a well-specified problem, which is not misconduct, it is a badly designed assignment. If your assignment has one correct shape, your detector is measuring your assignment.
What to tell a new TA running their first check this semester: run the peer pass and the AI pass on the same upload, export everything to a spreadsheet the same day, sort by maximum score across all columns rather than peer score alone, and budget more time per flag than you expect. Start with an established code plagiarism checker that gives you peer, web, and AI numbers in one report, because stitching three tools together is how you end up reading every file by hand and hoping you are thorough. If you are setting up a course from scratch, the instructor workflow walkthrough covers the submission portal and the first-check setup in about the time it takes to drink a coffee.
The last thirty years of this field have been a long argument about representation, from lines to tokens to trees, and the argument was worth having because each move caught something real. The next argument is not about representation at all. It is about provenance, and it started in November 2022. Run the AI detection pass alongside the peer check and you will see the difference in your own archive.