Programming Language Ecosystem Migration
Background
Huawei's self-developed programming language Cangjie is a next-generation domestic programming language. But as a new language, it faces a classic cold-start problem:
Small community → Weak ecosystem → Developers won't come → Even smaller community
The core of an ecosystem is libraries. When developers choose a language, they first ask: Are the libraries I need available? Can I use them directly? If everything needs to be written from scratch, it's better to stick with mature languages.
Cangjie needs to migrate mature libraries from other languages (Java, Python, Go, etc.) and reimplement them in Cangjie. But the problems are:
- Manual migration is too slow. A medium-sized library takes weeks to migrate manually.
- The language is too new for AI. Cangjie has very little training data; large models have barely seen this language.
- Documentation is scattered. Cangjie's syntax, standard library, and compiler features are in different places.
Our task: Build a tool that lets AI automatically migrate libraries from other languages to Cangjie.
Challenge
The core challenge: AI can't write Cangjie code.
Large models have almost no Cangjie code in their training data. Direct translation would likely fail to compile.
We needed to solve three problems:
- Knowledge injection: How to teach AI Cangjie's syntax and features?
- Code understanding: How to make AI understand the source library's logic?
- Quality assurance: How to ensure generated code compiles and works correctly?
Approach
Our solution: RAG + Agent + Multi-round Self-Check.
Step 1: Knowledge Injection (RAG)
We indexed all Cangjie documentation (language spec, standard library docs, compiler docs, example code) into a vector database.
When AI needs to write a function, it first retrieves relevant documentation for the latest syntax and API information.
Step 2: Code Understanding & Migration (Agent)
This step references multiple academic papers:
- Codex (OpenAI, 2021): Decomposing tasks into subtasks, generating step by step
- AlphaCode (DeepMind, 2022): Large-scale sampling strategy
- CodeRL (Salesforce, 2022): Using compilation results as reward signals
- Self-Debug (Meta, 2023): Self-correction based on error messages
Step 3: Multi-round Self-Check (Self-Refine)
Single-pass compilation success rate is only ~40%. After multi-round self-check, it rises to 85%+.
Results
| Metric | Data | |--------|------| | Migration automation rate | 80%+ | | Compilation success rate (after self-check) | 85%+ | | Single library migration time | From weeks to hours | | Successfully migrated projects | Dozens | | Community recognition | Multiple community contribution awards |
Why This Project Was Hard
- Language too new. Not enough training data; AI can't write Cangjie directly.
- Quality requirements high. Libraries are infrastructure; code must be reliable.
- Deep understanding required. Not just syntax translation—need to understand design intent.
**This is what we're good at: non-standard scenarios, complex data, uncertain technical paths.