Oh no, you're thinking, yet another cookie pop-up. Well, sorry, it's the law. We measure how many people read us, and ensure you see relevant ads, by storing cookies on your device. If you're cool with that, hit “Accept all Cookies”. For more info and to customize your settings, hit “Customize Settings”.

Review and manage your consent

Here's an overview of our use of cookies, similar technologies and how to manage them. You can also change your choices at any time, by hitting the “Your Consent Options” link on the site's footer.

Manage Cookie Preferences
  • These cookies are strictly necessary so that you can navigate the site as normal and use all features. Without these cookies we cannot provide you with the service that you expect.

  • These cookies are used to make advertising messages more relevant to you. They perform functions like preventing the same ad from continuously reappearing, ensuring that ads are properly displayed for advertisers, and in some cases selecting advertisements that are based on your interests.

  • These cookies collect information in aggregate form to help us understand how our websites are being used. They allow us to count visits and traffic sources so that we can measure and improve the performance of our sites. If people say no to these cookies, we do not know how many people have visited and we cannot monitor performance.

See also our Cookie policy and Privacy policy.

More than half of GitHub is duplicate code, researchers find

Boffins beware: random samples are therefore useless for research

Given that code sharing is a big part of the GitHub mission, it should come at no surprise that the platform stores a lot of duplicated code: 70 per cent, a study has found.

An international team of eight researchers didn't set out to measure GitHub duplication. Their original aim was to try and define the “granularity” of copying – that is, how much files changed between different clones – but along the way, they turned up a “staggering rate of file-level duplication” that made them change direction.

Presented at this year's OOPSLA (part of the late-October Association of Computing Machinery) SPLASH conference in Vancouver, the University of California at Irvine-led research found that out of 428 million files on GitHub, only 85 million are unique.

Before readers say “so what?”, the reason for this study was to improve other researchers' work. Anybody studying software using GitHub probably seeks random samples, and the authors of this study argued duplication needs to be taken into account.

As open source watcher Adrian Colyer blogged, “simple random selection is likely to lead to samples including high duplication, which may bias the results of research”, so the paper's resulting public index of code duplication, which they've dubbed “DéjàVu”, helps “understand the similarity relations in samples of projects, or to curate sample to reduce duplicates”.

For example, the study said, if a researcher is studying how many C and C++ programs use assertions, duplication clearly skews their output; similarly, a software quality study needs to take duplication into account.

Software duplication heat map

X = files, Y = commits, Color = dupes. Source: DéjàVu: A Map of Code Duplicates on GitHub, Lopes et al at ACM

DéjàVu maps file clones in Java, C++, JavaScript and Python.

The researchers assessed code duplication using a variety of hash techniques. Identical code was easy, since they produced identical hashes, but it was also necessary to take into account software with small changes (spaces or tabs), or even larger changes.

To draw these other duplicates into their sample, the researchers applied a “token hash” that captured minor changes in spaces, comments, and ordering; and a package called

SourcererCC

to capture clones with edits too large for the token hash.

JavaScript was the most cloned environment of all: a mere six per cent of files spawned the other 94 per cent of JavaScript files on GitHub. Of the C++ ecosystem, 73 per cent of files were duplicates; 71 per cent of Python programs were dupes.

Java developers are the most individualistic of the four environments researched, “but even for Java, 40% of the files are duplicates”.

The other thing that probably won't surprise readers is that duplication is primarily dependency-driven. JavaScript provided a good example: people creating a project would commit NPM libraries into their new repositories as if they were part of the application code.

As Colyer wryly noted: “If ever you have felt like you are downloading the universe when running npm install, here’s the data to prove it: including nested dependencies (nesting up to 47 levels deep was discovered, with median five) the number of unique included projects has median 63, and maximum 1261.”

Similarly, nearly all JavaScript programmers suck JQuery into their projects.

There's also programmers' habits as Git users: “there is a lot more duplication of code that happens in GitHub that does not go through the fork mechanism, and instead, goes in via copy and paste of files and even entire libraries”, the study noted. ®

 

Similar topics

Similar topics

Similar topics

TIP US OFF

Send us news


Other stories you might like