Programming Language Identification (PLI) is a core step in many software engineering tasks, including code analysis, software maintenance, repository indexing, and vulnerability detection. Most existing PLI techniques infer the language from external indicators such as file extensions, or from grammar-based and statistical pattern matching applied to the source text. These approaches share three recurring weaknesses: they depend on indicators that are easily missing or misleading, they confuse languages that share large parts of their syntax (for example, C and C++, or Java and JavaScript), and they degrade on short snippets and on files that mix more than one language. As a result, real-world accuracy and adaptability remain limited. To address these problems, we propose an ensemble-based hybrid framework that we call PrOgram LANguage Detection (POLAND). The framework first applies Natural Language Processing (NLP) preprocessing, in which a custom regular-expression tokenizer and a Term Frequency–Inverse Document Frequency (TF-IDF) vectorizer convert raw code into numerical features that emphasize language-specific tokens over shared ones. These features are then classified in parallel by three complementary learners—a Multilayer Perceptron (MLP), a Random Forest (RF), and a Multinomial Naive Bayes (MNB) model—and the final language is decided by majority voting, while the minority predictions are retained as candidate languages to flag possible mixed-language code. We evaluate POLAND on a dataset of 36 programming languages, built from 18 languages collected from public GitHub repositories and 18 languages generated from generic code templates, with each language normalized to 200 samples. Under a held-out test split, the ensemble reaches an average accuracy of about 97%, with the per-classifier training time summing to roughly 60 s on a commodity workstation. We discuss the languages that remain difficult to separate, analyse the sources of confusion, and outline the current limitations of the approach.
No takes yet. Share an insight, caveat, or question.
Jayalaxmi et al. (2026) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: