In the dynamic field of software development, knowledge of multiple programming languages is increasingly valued. To address the demand for cross-language systems, our research investigates code translation and proposes a new approach using transformer models to map cross-language codes. We draw inspiration from the success of transformer-based neural networks in natural language processing and apply these models to the complex world of programming languages. A central hypothesis is that transformers can effectively translate code between languages, acting as a bridge between programming paradigms. We develop a custom transformer encoder-decoder model for program-to-program translation that is initialized with a dataset containing C++ programs and corresponding codes in Haxe, Kotlin, Python, and Java. The cooperation between the encoder and the decoder allows a smooth translation of the code, which shows considerable adaptability. Through fine-tuning with data from other programming languages like Kotlin and Python, our model extends its translation capabilities. Enabling Haxe as an intermediate language further facilitates translation to target languages like Java. This adaptability, based on a transformer-based architecture, effectively meets the challenges of an ever-evolving programming environment. It should be noted that our approach differs from large language models in terms of programming complexity and capturing OOP design patterns. In addition to translation, our research paves a way for code visualization using tools such as Java interactive visualization environment. “Cross-Language Code Mapping with Transformer Models” marks a significant advance towards automatic code translation in object-oriented programming, enriching developer tool kits and promoting collaboration across language boundaries in software engineering.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Cross-Language Code Mapping with Transformer Encoder-Decoder Model

  • M. V. Deepak Naik,
  • Swaminathan Jayaraman

摘要

In the dynamic field of software development, knowledge of multiple programming languages is increasingly valued. To address the demand for cross-language systems, our research investigates code translation and proposes a new approach using transformer models to map cross-language codes. We draw inspiration from the success of transformer-based neural networks in natural language processing and apply these models to the complex world of programming languages. A central hypothesis is that transformers can effectively translate code between languages, acting as a bridge between programming paradigms. We develop a custom transformer encoder-decoder model for program-to-program translation that is initialized with a dataset containing C++ programs and corresponding codes in Haxe, Kotlin, Python, and Java. The cooperation between the encoder and the decoder allows a smooth translation of the code, which shows considerable adaptability. Through fine-tuning with data from other programming languages like Kotlin and Python, our model extends its translation capabilities. Enabling Haxe as an intermediate language further facilitates translation to target languages like Java. This adaptability, based on a transformer-based architecture, effectively meets the challenges of an ever-evolving programming environment. It should be noted that our approach differs from large language models in terms of programming complexity and capturing OOP design patterns. In addition to translation, our research paves a way for code visualization using tools such as Java interactive visualization environment. “Cross-Language Code Mapping with Transformer Models” marks a significant advance towards automatic code translation in object-oriented programming, enriching developer tool kits and promoting collaboration across language boundaries in software engineering.