转自:菜鸟教程
华为在 2024 年 6 月 21 日的华为开发者大会上,华为终端 BG 软件部总裁龚体正式官宣了华为自研仓颉编程语言,并发布了 HarmonyOS NEXT 仓颉语言开发者预览版。
仓颉编程语言文件后缀名为.cj
, 以下是第一个入门代码输出:你好,仓颉。
![be4cdb80e5bb41adfb06c85bc419dea6.png](https://img-blog.csdnimg.cn/img_convert/be4cdb80e5bb41adfb06c85bc419dea6.png)
仓颉编程语言的名字来自 “仓颉造字”。
仓颉(约公元前2650年)是中国古代传说中的人物,据说是黄帝的史官,他被认为是汉字的创造者。
仓颉造字是中国古代传说中的一个重要故事,讲述的是仓颉创造汉字的过程。
《荀子・解蔽》称:“好书者众矣,而仓颉独传者壹也”,该名字也是代表了团队成员对于仓颉编程语言的寄托,希望该语言能够被广大开发者喜爱,并且广为流传。
这是华为首次公开发布仓颉编程语言。
![905b4533542c99dd511e5a4028c3b6d9.png](https://img-blog.csdnimg.cn/img_convert/905b4533542c99dd511e5a4028c3b6d9.png)
龚体表示:“2019 年,仓颉编程语言项目在华为诞生,历经 5 年研发沉淀,大量研发投入,今日终于和全球开发者见面。仓颉编程语言通过现代语言特性的集成、全方位的编译优化和运行时实现、以及开箱即用的 IDE 工具链支持,为开发者打造友好开发体验和卓越程序性能。”
仓颉编程语言的发布,标志着其正式融入鸿蒙生态,为开发者提供了一个全新的编程平台。在这里,开发者可以享受到更加友好的开发体验和卓越的程序性能,共同推动鸿蒙生态的繁荣发展。
仓颉编程语言入门
1、你好,仓颉
![8d4c6324933f57eee414abbe77f69a0c.png](https://img-blog.csdnimg.cn/img_convert/8d4c6324933f57eee414abbe77f69a0c.png)
2、标识符
![e12476e39375583843d19b9355b1a5da.png](https://img-blog.csdnimg.cn/img_convert/e12476e39375583843d19b9355b1a5da.png)
3、变量
![1f422b53b8330de574ef7c1fe725ae7b.png](https://img-blog.csdnimg.cn/img_convert/1f422b53b8330de574ef7c1fe725ae7b.png)
4、类型
![d0951c2a1ac8f737f8f591ff8c1bfdf4.png](https://img-blog.csdnimg.cn/img_convert/d0951c2a1ac8f737f8f591ff8c1bfdf4.png)
![4322b0b07fc42e0285f65bb02fe6ddd3.png](https://img-blog.csdnimg.cn/img_convert/4322b0b07fc42e0285f65bb02fe6ddd3.png)
5、表达式
![14d6d360eacdac1662a4aaee4ce42cc9.png](https://img-blog.csdnimg.cn/img_convert/14d6d360eacdac1662a4aaee4ce42cc9.png)
![7754788f5f015d16c7ef27adbbfc54d0.png](https://img-blog.csdnimg.cn/img_convert/7754788f5f015d16c7ef27adbbfc54d0.png)
![74fefe3906733ab4def42051258ec836.png](https://img-blog.csdnimg.cn/img_convert/74fefe3906733ab4def42051258ec836.png)
![07c4414e0f62da1da86377930eb0fd23.png](https://img-blog.csdnimg.cn/img_convert/07c4414e0f62da1da86377930eb0fd23.png)
![9be44b17d197a74260913c826be8c232.png](https://img-blog.csdnimg.cn/img_convert/9be44b17d197a74260913c826be8c232.png)
6、程序结构
![1fa54c036031989d2a30c0056b1b145b.png](https://img-blog.csdnimg.cn/img_convert/1fa54c036031989d2a30c0056b1b145b.png)
7、函数定义
![dc872af07ea58e9615bdf746ea4669b0.png](https://img-blog.csdnimg.cn/img_convert/dc872af07ea58e9615bdf746ea4669b0.png)
![8f54e99f0ffc65c5a84144d336fb3307.png](https://img-blog.csdnimg.cn/img_convert/8f54e99f0ffc65c5a84144d336fb3307.png)
![ef129ce5ae69e85b27fe4924860bb0e4.png](https://img-blog.csdnimg.cn/img_convert/ef129ce5ae69e85b27fe4924860bb0e4.png)
![455aa4fb6dcace5fbd63450e94237b3b.png](https://img-blog.csdnimg.cn/img_convert/455aa4fb6dcace5fbd63450e94237b3b.png)
8、枚举
![eb1cd0d57a1ee9807071712b86397a4e.png](https://img-blog.csdnimg.cn/img_convert/eb1cd0d57a1ee9807071712b86397a4e.png)
![1eac3c2e24123c9fb210aba72e4f1722.png](https://img-blog.csdnimg.cn/img_convert/1eac3c2e24123c9fb210aba72e4f1722.png)
![cfaa12a1690da4af2f1b0eda370b357b.png](https://img-blog.csdnimg.cn/img_convert/cfaa12a1690da4af2f1b0eda370b357b.png)
![b33f7b2e92caaf98e655362f428601da.png](https://img-blog.csdnimg.cn/img_convert/b33f7b2e92caaf98e655362f428601da.png)
![8e61eb28ff935251dd8d2fbc531d8ce9.png](https://img-blog.csdnimg.cn/img_convert/8e61eb28ff935251dd8d2fbc531d8ce9.png)
9、结构体
![d76036a23c77849187b9967681572980.png](https://img-blog.csdnimg.cn/img_convert/d76036a23c77849187b9967681572980.png)
![eda2e5d3744c2c2115a64d50d33fe739.png](https://img-blog.csdnimg.cn/img_convert/eda2e5d3744c2c2115a64d50d33fe739.png)
![a1c110c58b3226923b115b02368f4949.png](https://img-blog.csdnimg.cn/img_convert/a1c110c58b3226923b115b02368f4949.png)
10、类
![abcb6967298780b0267bf5e8bcc23407.png](https://img-blog.csdnimg.cn/img_convert/abcb6967298780b0267bf5e8bcc23407.png)
![80122d136a080b48705e2a236716c51c.png](https://img-blog.csdnimg.cn/img_convert/80122d136a080b48705e2a236716c51c.png)
![6e3265e31f0dcdb8d5065c8389932b07.png](https://img-blog.csdnimg.cn/img_convert/6e3265e31f0dcdb8d5065c8389932b07.png)
![622a346ec517a81509bc4176e6188cdd.png](https://img-blog.csdnimg.cn/img_convert/622a346ec517a81509bc4176e6188cdd.png)
![1366e854e78807b4a7d5b93e40a006f9.png](https://img-blog.csdnimg.cn/img_convert/1366e854e78807b4a7d5b93e40a006f9.png)
11、接口与扩展
![1ab895e0d4cd2caad8469941c65b79ed.png](https://img-blog.csdnimg.cn/img_convert/1ab895e0d4cd2caad8469941c65b79ed.png)
![a3da2c00cf18835b546b4e85e6522349.png](https://img-blog.csdnimg.cn/img_convert/a3da2c00cf18835b546b4e85e6522349.png)
![134c46403ac365bbfd14a63c9de5b7c4.png](https://img-blog.csdnimg.cn/img_convert/134c46403ac365bbfd14a63c9de5b7c4.png)
![7229754ae480228e0fc1fe50b4ccb468.png](https://img-blog.csdnimg.cn/img_convert/7229754ae480228e0fc1fe50b4ccb468.png)
12、异常处理
![b1aeb8ac0ba20f30bc43813cc5e45d61.png](https://img-blog.csdnimg.cn/img_convert/b1aeb8ac0ba20f30bc43813cc5e45d61.png)
![c792d955b281dd217412854885aac117.png](https://img-blog.csdnimg.cn/img_convert/c792d955b281dd217412854885aac117.png)
微信搜索公众号:架构师指南,回复:架构师 领取资料 。
![a59355655440dd8a3aab67f7a579129f.png](https://img-blog.csdnimg.cn/img_convert/a59355655440dd8a3aab67f7a579129f.png)
![375d4656d3ce7711001dc8bf2bfb5ad3.png](https://img-blog.csdnimg.cn/img_convert/375d4656d3ce7711001dc8bf2bfb5ad3.png)
13、并发编程
![27ff3a0c88210bd396c0c6bc871236bd.png](https://img-blog.csdnimg.cn/img_convert/27ff3a0c88210bd396c0c6bc871236bd.png)
![ffc21cf2e4dad901453d140fba4c7596.png](https://img-blog.csdnimg.cn/img_convert/ffc21cf2e4dad901453d140fba4c7596.png)
![f18ae9b0cee572926e07c2605fe80559.png](https://img-blog.csdnimg.cn/img_convert/f18ae9b0cee572926e07c2605fe80559.png)
14、跨语言互操作
![13cb73edb5b3ed7d59b38360cf4272a3.png](https://img-blog.csdnimg.cn/img_convert/13cb73edb5b3ed7d59b38360cf4272a3.png)
![b0dfe136fadf5e0b4e7f8b36fc1e2c59.png](https://img-blog.csdnimg.cn/img_convert/b0dfe136fadf5e0b4e7f8b36fc1e2c59.png)
![c02f4cc2bb1684c5f31b618349dbf91d.png](https://img-blog.csdnimg.cn/img_convert/c02f4cc2bb1684c5f31b618349dbf91d.png)
![0aa460cd113c78e00cc84bbba763487d.png](https://img-blog.csdnimg.cn/img_convert/0aa460cd113c78e00cc84bbba763487d.png)
![ee864a556d3f32fbfa7eaf54275476da.png](https://img-blog.csdnimg.cn/img_convert/ee864a556d3f32fbfa7eaf54275476da.png)
15、宏
![353101e47314bf0300e8c7baab70d004.png](https://img-blog.csdnimg.cn/img_convert/353101e47314bf0300e8c7baab70d004.png)
![32b590d7ae9080ed6774daf17f11193d.png](https://img-blog.csdnimg.cn/img_convert/32b590d7ae9080ed6774daf17f11193d.png)
![0ab8759e4e13b25b26e047c92517ca97.png](https://img-blog.csdnimg.cn/img_convert/0ab8759e4e13b25b26e047c92517ca97.png)
参考资料:
仓颉编程:https://developer.huawei.com/consumer/cn/cangjie/
入门教程:https://developer.huawei.com/consumer/cn/training/course/slightMooc/C101718903607800132
白皮书:https://developer.huawei.com/consumer/cn/doc/openharmony-cangjie/cj-wp-abstract
感谢您的认真阅读,如果喜欢本篇文章,就点个“在看”或转发到朋友圈,让更多的人看到吧
程序员小猿 ID:DeveloperIT
长 按 二 维 码 , 一 键 关 注
MORE | 更多精彩文章