# TCCCD: Triplet-Based Cross-Language Code Clone Detection
###### Abstract  
Code cloning is a common practice in software development, where developers reuse existing code to accelerate programming speed and enhance work efficiency. Existing clone-detection methods mainly focus on code clones within a single programming language. To address the challenge of code clone instances in cross-platform development, we propose a novel method called TCCCD, which stands for Triplet-Based Cross-Language Code Clone Detection. Our approach is based on machine learning and can accurately detect code clone instances between different programming languages. We used the pre-trained model UniXcoder to map programs written in different languages into the same vector space and learn their code representations. Then, we fine-tuned TCCCD using triplet learning to improve its effectiveness in cross-language clone detection. To assess the effectiveness of our proposed approach, we conducted thorough comparative experiments using the dataset provided by the paper titled CLCDSA (Cross Language Code Clone Detection using Syntactical Features and API Documentation). The experimental results demonstrated a significant improvement of our approach over the state-of-the-art baselines, with precision, recall, and F1-measure scores of 0.96, 0.91, and 0.93, respectively. In summary, we propose a novel cross-language code-clone-detection method called TCCCD. TCCCD leverages the pre-trained model UniXcode for source code representation and fine-tunes the model using triplet learning. In the experimental results, TCCCD outperformed the state-of-the-art baselines in terms of the precision, recall, and F1-measure. code clone detection; cross-language; pre-trained model; triplet learning +
Footnote †: journal: Medical  
Code-clone-detection technology has made significant progress in the detection of Type-I, Type-II, and Type-III clones, with methods such as CCFinder [6], Deckard [7], NiCad [8], and SourcererCC [9] being proposed. However, for Type-IV clone detection, which is semantic clone detection, there are still challenges to be faced. These challenges include the difficulty of fully capturing and comprehending the intricate semantics of code, as well as the insufficient performance and efficiency in handling large-scale code repositories. To address these challenges, many researchers have combined static detection methods with deep learning and applied them to Type-IV clone detection, achieving promising results, such as CCLearner [10], CCGraph [11], ASTNN [12], and DeepSim [13]. Prior research in the field of code clone detection primarily concentrated on identifying clones within the single programming language, with limited attention given to cross-language clone detection. Recent studies on cross-language code clone detection encompass LLCCA [14], CLCDSA [15], and C4 [16]. LLCCA is a tool based on the SSQSA [17] architecture for cross-language code clone detection. However, it exhibits certain limitations, such as requiring equal source code lengths and identical code steps and functional flow for code blocks, restricting its applicability in real-world scenarios. CLCDSA utilizes Abstract Syntax Trees (ASTs) to extract features for detecting cross-language code clones. Nonetheless, its precision and recall rates are relatively low, impeding its effectiveness in real-world scenarios. C4 leverages the pre-trained model CodeBERT [18] to convert code from diverse languages into high-dimensional vector representations, facilitating the detection of cross-language code clones. However, C4's use of CodeBERT's pre-trained models for languages beyond the six it was trained on may lead to less-accurate code representation. Additionally, C4's pre-trained approach solely focuses on modeling natural language, neglecting the valuable structural information present in the code. This limitation restricts C4's ability to fully exploit the code's structural and data flow features.