Huawei’s Cangjie Programming Language Showcases Its First Full-Scale Development Example

At the HDC 2024 Huawei Developer Conference keynote, Gong Ti, President of Huawei’s Consumer BG Software Department, officially announced Huawei’s self-developed Cangjie programming language. After five years of research and development, the language is now available for developer previews.

During the subsequent HDC 2024 session titled “Cangjie Language Boosts Efficient Development of HarmonyOS Native Applications,” Huawei’s Chief Technical Expert in Programming Languages, representatives from the Industrial and Commercial Bank of China, and LeetCode shared more information about Cangjie.

Introduction to the Cangjie Programming Language

Huawei’s Chief Technical Expert in Programming Languages and Chief Architect of Cangjie, Professor Feng Xinyu, took the stage first to give a brief introduction to the Cangjie programming language.

Cangjie is a modern programming language designed for the development of intelligent applications across all scenarios, featuring native intelligence, inherent full-scenario capabilities, high performance, and strong security. It integrates modern language features, offers comprehensive compilation and runtime optimizations, a simple and easy-to-use declarative programming framework for intelligent agents, and out-of-the-box support from an IDE toolchain.

According to Professor Feng, Cangjie employs a modular layered design, requiring only 2.08MB of memory when idle, compared to 4.91MB for mainstream mobile language S (presumed to be Swift) and 58.97MB for mainstream mobile language J (presumed to be Java).

Additionally, Cangjie supports full concurrent GC (Garbage Collection), reducing STW (Stop The World) pauses compared to traditional GC, enhancing the smoothness of application threads. Cangjie also supports various syntactic sugars, concurrency optimizations, and interoperability with C language.

Industrial and Commercial Bank of China’s Cangjie Development Pilot

Following Professor Feng’s introduction, researcher Li Ke from the Industrial and Commercial Bank of China discussed the institution’s development practices with the Cangjie language.

The Industrial and Commercial Bank of China has completed the development of its first HarmonyOS Next App, using both Cangjie and ArkTS languages, which is now available on Huawei’s AppGallery.

The pilot of Cangjie at the Industrial and Commercial Bank of China focused on the “Income and Expense Calendar” feature of the ICBC Personal Mobile Banking, as shown in the figure below. The loading and display of income and expense details involve complex data parsing and view rendering tasks.

Cangjie supports declarative UI for page writing, with relatively simple syntax; it can also be mixed with ArkTS language for development, following a basic pattern of declarations and calls, which is also straightforward. Li also mentioned that the Industrial and Commercial Bank of China plans to gradually expand the scope of Cangjie language pilots to more apps.

LeetCode’s Full-Scale Cangjie Development

Finally, Ye Haijian, Technical Team Leader of LeetCode Mobile, took the stage to speak. LeetCode is a platform for programmers to enhance their IT technical professionalism, with 18 million registered users worldwide, many of whom practice algorithm problems on the platform. It was introduced that the LeetCode HarmonyOS native application was developed using the Cangjie language in full scale, and the team also developed some third-party libraries for Cangjie.

LeetCode developers also mentioned declarative UI development, and Cangjie provides very simple Web components (as shown in the bottom right of the figure below), which can be directly invoked.

Cangjie has type inference capabilities, such as automatically inferring generic types, automatically inferring the type of let variables, and automatically inferring the return type of functions, which can reduce the burden of type annotations for developers.

Cangjie has also been optimized for security, avoiding issues like null pointers and null references at compile time, requiring variables to be initialized before use, and not providing a null value.

Moreover, Cangjie natively supports high concurrency, with thread-switching code being more concise than that of Java and Swift, and it also supports constructor functions for enumerations.

Cangjie has also introduced an AI-assisted programming tool (BitFun FireCoder), which LeetCode integrated in May, claiming that “20% of the code can be generated automatically by AI.”

The LeetCode HarmonyOS native application, developed by a team of two, took four months to complete the core functionality, with a total code volume of over 20,000 lines.

In terms of performance, the LeetCode HarmonyOS native application (developed with Cangjie) has improved cold start speeds and multi-image article browsing experiences compared to the Java & Kotlin version. The specific effects can be seen in the figure below:

The LeetCode HarmonyOS native application started development on February 1, 2024, with plans to launch the first Beta version on July 31, the commercial version 1.0 on September 30, and the commercial version 1.1 on November 30.