Studying the Difference Between Natural and Programming Language Corpora
Preprint
Abstract
Code corpora, as observed in large software systems, are now known to be far more repetitive and predictable than natural language corpora. But why? Does the difference simply arise from the syntactic limitations of programming languages? Or does it arise from the differences in authoring decisions made by the writers of these natural and programming language texts? We conjecture that the differences are not entirely due to syntax, but also from the fact that reading and writing code is un-natural for humans, and requires substantial mental effort; so, people prefer to write code in ways that are familiar to both reader and writer. To support this argument, we present results from two sets of studies: 1) a first set aimed at attenuating the effects of syntax, and 2) a second, aimed at measuring repetitiveness of text written in other settings (e.g. second language, technical/specialized jargon), which are also effortful to write. We find find that this repetition in source code is not entirely the result of grammar constraints, and thus some repetition must result from human choice. While the evidence we find of similar repetitive behavior in technical and learner corpora does not conclusively show that such language is used by humans to mitigate difficulty, it is consistent with that theory.Keywords
All Related Versions
This publication has 26 references indexed in Scilit:
- How programmers read regular code: a controlled experiment using eye trackingEmpirical Software Engineering, 2016
- Stochastic Model for the Vocabulary Growth in Natural LanguagesPhysical Review X, 2013
- Languages cool as they expand: Allometric scaling and the decreasing need for new wordsScientific Reports, 2012
- The communicative function of ambiguity in languageCognition, 2012
- Formulaic Sequences: Are They Processed More Quickly than Nonformulaic Language by Native and Nonnative Speakers?Applied Linguistics, 2008
- A Brief History of Generative Models for Power Law and Lognormal DistributionsInternet Mathematics, 2004
- The Information Conveyed by Words in SentencesJournal of Psycholinguistic Research, 2003
- Two Regimes in the Frequency of Words and the Origins of Complex Lexicons: Zipf’s Law Revisited∗Journal of Quantitative Linguistics, 2001
- An empirical study of smoothing techniques for language modelingComputer Speech & Language, 1999
- Prediction and Entropy of Printed EnglishBell System Technical Journal, 1951