Why Huawei’s New Cangjie Language Could Redefine HarmonyOS App Development

Huawei unveiled the fully self‑developed Cangjie programming language at the 2024 Developer Conference, detailing its native intelligence, full‑scene support, high performance, strong security, multi‑paradigm features, and simple syntax designed specifically for HarmonyOS applications.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Why Huawei’s New Cangjie Language Could Redefine HarmonyOS App Development

At the Huawei Developer Conference on June 21, 2024, Huawei announced HarmonyOS NEXT and introduced a brand‑new, completely self‑developed programming language called Cangjie, aimed at building applications within the HarmonyOS ecosystem.

Language Overview

The official definition describes Cangjie as a next‑generation language for "all‑scene intelligence," emphasizing native intelligence, full‑scene capability, high performance, and strong security. It is tightly integrated with HarmonyOS, meaning it is primarily intended for developing HarmonyOS apps.

Key Features

Native intelligence – higher development efficiency and flexibility.

Full‑scene support – lightweight runtime suitable for small devices such as smart watches.

High performance – optimized execution speed.

Strong security – built‑in safety mechanisms.

The language’s white‑paper highlights additional characteristics:

Multi‑paradigm programming – supports functional, imperative, and object‑oriented styles, reminiscent of Scala and Rust.

Static strong typing with runtime checks – similar to Java.

Efficient concurrency via user‑level lightweight threads (native coroutines), akin to Go.

Interoperability with C and other mainstream languages.

Declarative UI development support, comparable to Kotlin.

Getting Started

Cangjie source files use the .cj extension. A typical program defines global variables, functions, and custom types (struct, class, enum, interface). The entry point is a main function that can accept an Array<String> argument and return an integer or Unit.

Example "Hello World" program:

// helloworld.cj
main() {
    let text: String
    text = "Hello World!"
    println(text)
}

Other language constructs include:

Identifiers and program structure.

Control flow – if…else, for, while, do‑while, for‑in.

Functions – defined with func.

Structs and classes – similar to Go and Java/C++.

Enums with parameterized constructors.

Generics – e.g., Array<T>, Set<T>.

Collections – built‑in Array, ArrayList, HashSet, HashMap.

Exception handling – try…catch…finally and an Option type for safe value handling.

Concurrency – the spawn keyword creates a lightweight thread executing a lambda expression.

Concurrency example (simplified):

spawn { println("New thread") }
println("Main thread")

Conclusion

Cangjie blends familiar syntax from languages such as Swift, Go, and TypeScript, making it approachable for developers experienced with those ecosystems. While the language is still new and its ecosystem is growing, its design aims to lower the learning curve for HarmonyOS app development and provide strong performance and security guarantees.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Mobile DevelopmentconcurrencyHarmonyOSProgramming LanguagesyntaxCangjie
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.