Draft:Cangjie (programming language)
Programming language From Wikipedia, the free encyclopedia
Cangjie is a high-level, statically typed, general-purpose, multi-paradigm, compiled imperative and declarative programming language developed by Huawei which was first released on June 21, 2024, as a beta recruitment of the developer preview version of the HarmonyOS NEXT app development for HarmonyOS operating system.[1] It is also referred to as CangjieLang or CJ but its proper name is Cangjie.[2]
Submission declined on 2 January 2025 by Stuartyeates (talk).
Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
| ![]() |
Comment: The article needs independent coverage, that is secondary source with in depth coverage not written or published by people associated with the language. Pretty much all of the sources below are good for sourcing details of the language but not for proving notability. Stuartyeates (talk) 22:59, 2 January 2025 (UTC)
![]() | The following Wikipedia contributor may be personally or professionally connected to the subject of this page. Relevant policies and guidelines may include conflict of interest, autobiography, and neutral point of view. |
![]() | A major contributor to this article appears to have a close connection with its subject. (July 2024) |
Paradigm | Multi-paradigm: functional, generic, imperative, declarative, object-oriented |
---|---|
Developer | Huawei |
First appeared | June 21, 2024 |
Preview release | 1.0 (Beta)
/ June 21, 2024 |
Typing discipline | Duck, gradual, structural, Static, strong, safe, nominative, manifest, strong, inferred |
OS | HarmonyOS, Linux, Windows, macOS |
License | Proprietary (HarmonyOS) |
Filename extensions | .cj |
Website | |
Influenced by | |
ArkTS, TypeScript, JavaScript, Swift, C#, F#, Java, C++, Go, Python |
History
Summarize
Perspective
Development of Cangjie started in 2019 by chief architect of Huawei's in-house programming language by Xinyu Feng, professor at the Department of Computer Science and Technology of Nanjing University alongside Tianjin University and Beihang University in its five-year development,[3] with the eventual collaboration of many other software programmers and engineers at Huawei at that time during the development initial release of HarmonyOS that same year, after being incubated in the R&D labs.[4]
In 2020, Huawei registered “Cangjie Language” trademark, which was classified as a “scientific instrument” and “web service” intellectual property in China. At that time, there were also rumors that Huawei was developing a new independent programming language Cangjie.[5]
During HDC 2021, in October 2021, HarmonyOS 3 Developer Preview was officially released as the OS was moving towards declarative programming software development. Huawei also announced that at that time that it would introduce the self-developed programming language for HarmonyOS in the future.[6]
It has also been reported between 2021 and 2022 that Huawei's programming language originally supposed to launch in 2022 or sometime around second half of 2022 which was pushed back due to ongoing development of HarmonyOS operating system internally.[1][7][8]
On May 17, 2024, Cangjie programming language was internally added into OpenHarmony source code through its foreign function interface (FFI) mechanism.[9]
On June 17, 2024, four days before HDC 2024, Huawei renamed it's programming language lab to Cangjie programming language and announces the developer sessions of the new programming language for the event.[10]
On June 21, 2024, at HDC 2024, Cangjie developer recruitment that is running throughout June 21, 2024 until October 21, 2024, first landed for Huawei Mate60 Pro devices first with expansions of more devices going into 2025 rollout of HarmonyOS NEXT.[11] Silicon Valley-based LeetCode, ICBC bank, China Mobile, Kelan Software, became one of the first local app developer companies recruited by Huawei using the new programming language to test and showcase to other developers and industry with the release of commercial apps in the initial Chinese market launch of the new HarmonyOS Next version platform.[12]
On July 5 to July 7, 2024, ACM China Turing Conference 2024 held with the Huawei Cangjie Programming Language Forum showcasing the new in-house domestic programming language across universities in China for Cangjie development integrated into academia.[13][14]
In September, LeetCode China supports Cangjie for all problems.[15]
Version history
Version history of Cangjie releases with HarmonyOS with OpenHarmony core API Level 12 SDK via DevEco Studio IDE.
Platforms
The platforms Cangjie supports are HarmonyOS, Linux, Windows and macOS for app development.
A key aspect of Cangjie design is its ability to attach with or without ArkTS code developed for HarmonyOS development. On Huawei devices running HarmonyOS, it allows Native APIs in DevEco Studio templates alternative to traditional Native APIs of C, C++ alongside ArkTS code to run within one program.[17]
Features
Summarize
Perspective
Unlink ArkTS, Cangjie is a general purpose programming language that is not based on any existing programming languages. The programming language employs modern programming-language theory concepts of other existing programming languages of its category that influences it such as Java with simple and advanced syntax features like Typescript-centric ArkTS language, in declarative programming development by complementing it with efficiency.[18]
Cangjie features an embedded AgentDSL programming framework, natural language & programming language organic integration. Its lightweight threads provide better concurrency and lower overhead compared to Kotlin and Java on Android, as shown in benchmark tests.[19][20]
It is reported that applications that have already been developed on existing ArkTS do not need to be redeveloped into the Cangjie version on HarmonyOS Next version. HarmonyOS supports high-performance interoperability between the Cangjie language and the ArkTS language. In the future, developers can choose between Cangjie programming language or ArkTS for incremental development for developer needs.[21][22]
Huawei also claims that the language integrates security features into its design, aiming to allow developers to focus on application functionality while reducing potential security vulnerabilities. The language provides a static type system and automatic memory management to enhance application stability, alongside runtime error detection and cross-language security measures.[23] Cangjie also supports various toolchains for app development, including language services such as highlighting and association, debugging with cross-language debugging and thread-level visual debugging, static checking, performance analysis, package management, document generation, Mock tools, testing frameworks, coverage tools, Fuzz tools, and intelligent assisted programming tools.[24]
Basic syntax
Cangjie's "Hello, World!" program is:
main() {
println("Hello, World!")
}
Immutable variables are declared with the let
keyword and mutable ones with the var
keyword. Values must be initialized before they are read. Values may infer their type based on the type of the provided initial value. If the initial value is set after the value's declaration, a type must be declared explicitly.[25]
Pattern matching
Pattern matching in Cangjie is provided by the match
expression, which has two forms: one with a value to match and the other without a value to match. A match
expression with a value checks each case
in sequence, executing the corresponding code when the pattern matches successfully. To ensure exhaustiveness, the last case
often uses a wildcard pattern _
to cover all possible values. A match
expression without a value evaluates does not need a pair of brackets for the condition.[1]
Lambda expression
Lambda expression can have no parameters:[1]
let f = {a: Int64, b: Int64 => a + b}
let print = { => println("Hello Cangjie")}
Foreign function interface
Cangjie has built-in FFI support for C and Python. External functions are declared using the foreign
keyword and called using the unsafe
keyword. For C interoperability, Cangjie supports automatic conversion between basic data types. The CPointer<T>
type corresponds to C pointer types, for example, and CPointer<Int32>
corresponds to int32_t *
. For Python, Cangjie supports interaction through the ffi.python library in std. It requires Python version 3.0 or above and currently only works on Linux.[26] Below is an example:
C code | Cangjie code |
---|---|
#include <stdio.h>
#include <stdlib.h>
int getRandom() {
int i = rand();
return i;
}
|
from std import ffi.c.*
foreign func getRandom(): Int32
main(): Unit {
let r = unsafe getRandom()
println("random number $(r)")
}
|
Metaprogramming
Cangjie supports two main types of macros: non-attribute macros, which take a single input parameter for the code being decorated, and attribute macros, which accept an additional attribute parameter allowing developers to pass extra information to the macro.
Compared to functions, macros in Cangjie require the macro
keyword, placed in macro package
, and being invoked using the @ symbol. While macro nesting is supported in calls, macro definitions cannot be nested themselves. The expansion of nested macros follows an inside-out order, and macros can share information through global variables. Macros can appear in both parenthesized and non-parenthesized calls. Developers can use quote expressions to create Token objects.[26]
STD module runtime
STD module runtime, known as Std.runtime is a module runtime package for Cangjie Standard Library via Cangjie Programming Language Library API that interacts with the program's runtime environment, with varaibles of controlling, managing and monitoring the program's execution.[1]
Development tools
Summarize
Perspective
Compiler
With Ark Compiler, it supports a variety of dynamic and static programming languages such as JS, TS, and ArkTS as well as Cangjie. It is the compilation and runtime base that enables OpenHarmony alongside HarmonyOS based on the same platform to run on multiple device forms such as smart devices, mobile phones, PCs, tablets, TVs, automobiles, and wearables. ArkCompiler consists of two parts, compiler toolchain and runtime.[27]
Package manager
Cangjie Package Manager (CPM) is the built-in package management tool for the Cangjie programming language that comes installed with the cjc toolchain. In Cangjie, a package is the smallest compilation unit, with each package capable of containing multiple source files (.cj files) and having its own namespace; a module is a collection of packages, representing a complete functional unit and serving as the minimum unit for third-party developer releases. new command creates a new module, generating a module.json file and src folder. Each module's program entry point must be in its root directory, and the top level can have at most one main function as the program entry point.[26]
IDE and editor support
Cangjie uses DevEco Studio plug-in for HarmonyOS native development as Cangjie SDK using default declarative ArkUI, also other third-party UI frameworks on HarmonyOS NEXT version and OpenHarmony SDK with future cross-platform ArkUI-X support.[28]
See also
References
External links
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
- in-depth (not just passing mentions about the subject)
- reliable
- secondary
- independent of the subject
Make sure you add references that meet these criteria before resubmitting. Learn about mistakes to avoid when addressing this issue. If no additional references exist, the subject is not suitable for Wikipedia.