Content deleted Content added
m clean up, typo(s) fixed: in June 21, 2024 → on June 21, 2024, June 21, 2024 → June 21, 2024, (3), long term → long-term, a extension → an extension, it's → its (5), ’s → 's |
|||
(29 intermediate revisions by 11 users not shown) | |||
Line 1:
{{AFC submission|d|nn|u=158.181.216.135|ns=118|decliner=Stuartyeates|declinets=20250102225902|ts=20241128073832}} <!-- Do not remove this line! -->
{{AFC comment|1=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. [[User:Stuartyeates|Stuartyeates]] ([[User talk:Stuartyeates|talk]]) 22:59, 2 January 2025 (UTC)}}
----
{{Short description|Programming language}}
{{Draft topics|internet-culture|software|computing|technology}}
{{AfC topic|stem}}
{{Connected contributor|Poppodoms}}
{{COI|date=July 2024}}
{{Use mdy dates|date=July 2024}}
{{Infobox programming language
Line 17 ⟶ 28:
| typing = [[Duck typing|Duck]], [[Gradual typing|gradual]], [[Structural type system|structural]], [[type system|Static, strong, safe]], [[nominal type system|nominative]], [[manifest typing|manifest]], [[Strong and weak typing|strong]], [[Type inference|inferred]]
| memory management =
| operating system = [[HarmonyOS]], [[Linux]], [[Windows]], [[macOS]]
| license = [[Proprietary software|Proprietary]] (HarmonyOS)
| website = {{plainlist|
Line 24 ⟶ 35:
}}
| file ext = .cj
| influenced_by = [[ArkTS]], [[TypeScript]], [[JavaScript]], [[Swift (programming language)|Swift]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]], [[Java (programming language)|Java]], [[C++]], [[Go (programming language)|Go]], [[Python (programming language)|Python]]
| influenced =
}}
'''Cangjie''' is a [[High-level programming language|high-level]], [[static typing|statically typed]], [[general-purpose programming language|general-purpose]], [[multi-paradigm programming language|multi-paradigm]], [[compiled language|compiled]] [[Imperative programming|imperative]] and [[Declarative programming|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.<ref name="vid" /> It is also referred to as '''CangjieLang''' or '''CJ''' but its proper name is Cangjie.<ref>{{Cite web |last=Matsui |first=Emiko |date=2024-06-21 |title=Huawei programming language to make official debut at HDC 2024 |url=https://www.huaweicentral.com/huawei-programming-language-to-make-official-debut-at-hdc-2024/ |access-date=2024-07-06 |website=Huawei Central |language=en-US}}</ref>
== History ==
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
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.<ref>{{Cite web |last=Amit |date=2021-09-25 |title=Huawei to launch a self-developed programming language Cangjie next year |url=https://www.huaweiupdate.com/huawei-to-launch-a-self-developed-programming-language-cangjie-next-year/ |access-date=2024-07-06 |website=HU |language=en-US}}</ref>
Line 38 ⟶ 49:
During HDC 2021, in October 2021, HarmonyOS 3 Developer Preview was officially released as the OS was moving towards [[Declarative programming|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.<ref>{{Cite web |last=Benjie |first=Joshua |date=2022-03-17 |title=Huawei testing own programming language registration |url=https://www.rprna.com/news/huawei-testing-own-programming-language-registration/ |access-date=2024-07-06 |website=RPRNA |language=en-US}}</ref>
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.<ref name="vid" /><ref>{{Cite web |last=Li |first=Deng |date=2022-06-16 |title=
On May 17, 2024, Cangjie programming language was internally added into OpenHarmony source code through its [[Foreign function interface|foreign function interface (FFI)]]
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.<ref>{{Cite web |last=Nick |date=2024-06-17 |title=Huawei Renames Programming Language Lab to 'Cangjie Programming Language' and Announces Insights at HDC 2024 |url=https://harmonyoshub.com/huawei-renames-programming-language-lab-to-cangjie-programming-language-and-announces-insights-at-hdc-2024/ |access-date=2024-07-06 |website=HarmonyOSHub |language=en-GB}}</ref>
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 Mate 60|Huawei Mate60 Pro]] devices first with expansions of more devices going into 2025 rollout of HarmonyOS
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.<ref>{{Cite web |title=ACM 中国图灵大会 2024 将于 7 月 5 日举行,设华为仓颉编程语言论坛 - IT之家 |url=https://www.ithome.com/0/778/167.htm |access-date=2024-07-06 |website=www.ithome.com}}</ref><ref>{{Cite web |last=Nick |date=2024-07-07 |title=The Cangjie Programming Language Unveiled at ACM China Turing Conference |url=https://harmonyoshub.com/the-cangjie-programming-language-unveiled-at-acm-china-turing-conference/ |access-date=2024-07-07 |website=HarmonyOSHub |language=en-GB}}</ref>
In September, [[LeetCode]] China supports Cangjie for all problems.<ref>{{Cite web |title= |script-title=zh:编程刷题平台 LeetCode 力扣所有题目均已支持华为仓颉语言 |trans-title=All problems on the programming practice platform LeetCode are now supported in Huawei's Cangjie language |url=https://www.sohu.com/a/809062659_114760 |access-date=2024-12-03 |website=[[Sohu]]}}</ref>
=== Version history ===
Line 67 ⟶ 80:
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 (programming language)|C]], [[C++]] alongside ArkTS code to run within one program.<ref>{{Cite web |title= |script-title=zh: 华为仓颉编程语言首批合作企业亮相:中国工商银行、中国移动、科蓝软件等在列 |trans-title=Huawei's
== Features ==
Unlink [[ArkTS]], Cangjie is a general purpose programming language
Cangjie features an embedded AgentDSL programming framework, natural language & programming language organic integration.
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
===
Cangjie's [["Hello, World!" program]] is:
<syntaxhighlight lang="swift" line="1" start="1">
main() {
println("Hello, World!")
</syntaxhighlight>
Immutable variables are declared with the {{code|let|swift}} keyword and mutable ones with the {{code|var
|swift}} 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.<ref>{{cite book |last1=劉玥 |title=Cangjie Programming Quick Start |date=2024-07-01 |isbn=9787115624710 |script-title=zh:仓颉编程快速上手}}</ref>
=== Pattern matching ===
▲ }
[[Pattern matching]] in Cangjie is provided by the <code>match</code> expression, which has two forms: one with a value to match and the other without a value to match. A <code>match</code> expression with a value checks each <code>case</code> in sequence, executing the corresponding code when the pattern matches successfully. To ensure exhaustiveness, the last <code>case</code> often uses a [[Wildcard character|wildcard]] pattern <code>_</code> to cover all possible values. A <code>match</code> expression without a value evaluates does not need a pair of brackets for the condition.<ref name="vid" />
=== Lambda expression ===
Lambda expression can have no parameters:<ref name="vid">{{Cite book |last=张磊 |title= |publisher=[[Tsinghua University Press]] |year=2024 |isbn=9787302616597 |script-title=zh:仓颉语言实战(微课视频版) |trans-title=Hands on Cangjie Language (Video Course Version)}}</ref><syntaxhighlight lang="swift" line="1" start="1">
let f = {a: Int64, b: Int64 => a + b}
let print = { => println("Hello Cangjie")}
</syntaxhighlight>
=== Foreign function interface ===
Cangjie has built-in [[Foreign function interface|FFI]] support for [[C (programming language)|C]] and [[Python (programming language)|Python]]. External functions are declared using the <code>foreign</code> keyword and called using the <code>unsafe</code> keyword. For C interoperability, Cangjie supports automatic conversion between basic data types. The <code>CPointer<T></code> type corresponds to C pointer types, for example, and <code>CPointer<Int32></code> corresponds to <code>int32_t *</code>. 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.<ref name=":0">{{Cite book |last=徐礼文 |title= |publisher=[[Tsinghua University Press]] |isbn=9787302625889 |script-title=zh:仓颉语言核心编程——入门、进阶与实战 |trans-title=Cangjie Language Core Programming: Introduction, Advanced Topics and Practical Applications}}</ref> Below is an example:
{|
!C code
!Cangjie code
|-
|<syntaxhighlight lang="c" line="1">
#include <stdio.h>
#include <stdlib.h>
int getRandom() {
int i = rand();
return i;
}
</syntaxhighlight>
|<syntaxhighlight lang="swift" line="1">
from std import ffi.c.*
foreign func getRandom(): Int32
main(): Unit {
let r = unsafe getRandom()
println("random number $(r)")
}
</syntaxhighlight>
|}
=== 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 {{code|macro|}} keyword, placed in {{code|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.<ref name=":0" />
== STD module runtime ==
{{See also|Ark Compiler}}
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
== Development tools ==
=== Compiler ===
With [[Ark Compiler]], it supports a variety of dynamic and static programming languages such as [[JavaScript|JS]], [[TypeScript|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.<ref>{{cite web |title=ArkCompiler Runtime |url=https://gitee.com/openharmony/docs/blob/master/en/readme/ARK-Runtime-Subsystem.md |website
=== 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. <samp>new</samp> 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.<ref name=":0" />
=== IDE and editor support ===
Line 125 ⟶ 175:
{{Huawei|phones=yes|tablets=yes|laptops=yes|wearables=yes|cpu=yes|os=yes|services=yes|people=yes|other=yes|below=yes}}
{{Draft categories|
[[:Category:
[[:Category:
[[:Category:
[[:Category:Scripting languages]]
[[:Category:Source-to-source compilers]]
[[:Category:Statically typed programming languages]]
[[:Category:Huawei products]]
}}
{{Drafts moved from mainspace |date=July 2024}}
|