Abstract
Automating API migration between programming languages is a significant challenge due to the scarcity of parallel "bilingual" codebases. DeepAM addresses this by using natural language comments as a semantic bridge. By mapping API sequences from different languages into a shared vector space, DeepAM discovers mappings at a scale and accuracy previously unattainable, significantly outperforming traditional lexical and information-retrieval-based methods.
Introduction
When developers port software between languages, such as from Java to C#, migrating APIs—specialized libraries for tasks like I/O or networking—is a major bottleneck. Traditional automated tools often rely on "bilingual projects" where the same software exists in both languages. However, such projects are exceedingly rare; a study of 11,000 GitHub projects found only 15 such pairs. Furthermore, tools relying on lexical similarity fail when APIs perform the same function but have different names (e.g., BufferedReader.read in Java vs. StreamReader.read in C#).
Methodology: Natural Language as a Pivot
DeepAM introduces the concept of "third-party translation." Instead of requiring direct code-to-code parallels, it leverages the fact that developers in both Java and C# use natural language comments to describe code intent.
The system operates in four primary stages:
- Extraction: It harvests API sequences and their corresponding natural language descriptions from large-scale code corpora.
- Joint Semantic Embedding: Using a multi-modal sequence-to-sequence (seq2seq) architecture with bidirectional GRUs, the model learns to represent API sequences as vectors. If sequences from different languages share similar descriptions (e.g., "save to a text file"), they are positioned closely in this shared semantic space.
- Sequence Alignment: Equivalent API pairs are identified by finding nearest neighbors in the vector space using cosine similarity.
- Rule Extraction: Phrase-Based Statistical Machine Translation (SMT) is applied to distill these alignments into reusable 1-to-1 mapping rules.
Experimental Setup and Datasets
The authors constructed a massive dataset by scraping over 442,000 Java and 182,000 C# projects from GitHub. This resulted in approximately 9.88 million pairs of API sequences and descriptions (5.2M Java, 4.6M C#). This scale is orders of magnitude larger than datasets used in previous bilingual-project-based approaches, allowing the model to capture a much wider variety of programming patterns.
Results and Discussion
DeepAM significantly outperforms existing tools like StaMiner and TMAP. It achieved an average F-score of 81.9% for class migration, compared to StaMiner's 66.2%. Notably, DeepAM's recall (82.6%) was much higher than the baseline (60.2%), indicating a superior ability to find a wider variety of mappings.
As shown in the table above, DeepAM discovered over 808,000 API mapping rules, a nearly eight-fold increase over StaMiner’s 100,000 rules. This demonstrates the power of using natural language as a bridge to tap into vast, non-parallel code repositories. Manual evaluation further confirmed that 72.4% of DeepAM's aligned pairs were truly equivalent, nearly doubling the precision of traditional Information Retrieval (IR) methods (40.8%).
Conclusion and Future Work
DeepAM demonstrates that natural language intent is a universal constant that can effectively align disparate programming languages. While highly effective, the system's performance is tied to the quality of code documentation. Future research may focus on handling more complex N-to-M mapping rules and extending the approach to languages with less formal documentation standards, such as Python or JavaScript.
Summary updated