ArkTS: Difference between revisions

Content deleted Content added
m →‎History: grammar
spam
 
(17 intermediate revisions by 10 users not shown)
Line 1:
{{Notability|date=July 2024}}
{{COI|date=July 2024}}
{{Short description|General-purpose compiled programming language}}
{{Use mdy dates|date=December 2021}}
Line 4 ⟶ 6:
| name = ArkTS
| title = ArkTS
| logo =
| logo caption =
| logo size = 80px
| paradigm = [[Multi-paradigm programming language|Multi-paradigm]]: [[functional programming|functional]], [[generic programming|generic]], [[imperativeDeclarative programming|imperativedeclarative]], [[object-oriented programming|object-oriented]]
| released = {{start date and age|2021|09|30}}
| designer =
| developer = [[Huawei]] and, [[OpenAtom Foundation]], [[Eclipse Foundation]] open-source contributors
| latest_release_version = 4.1.7.3
| latest_release_date = {{Start date and age|2024|03|30}}
| latest preview version =
Line 17 ⟶ 19:
| typing = [[Duck typing|Duck]], [[Gradual typing|gradual]], [[Structural type system|structural]]
| memory management =
| operating system = [[HarmonyOS]], [[OpenHarmony]], Oniro OS, [[macOS]], [[Windows]], [[Android (operating system)|Android]], [[iOS]]
| license = [[Apache License]]<br />[[Proprietary software|Proprietary]] (up to HarmonyOS 3.1)
| website = {{plainlist|
*{{URL|https://developer.harmonyos.com/}}
*{{URL|https://www.harmonyos.com/arkts/}}
}}
| file ext = .ets, .ts
| influenced_by = [[TypeScript]], [[Swift (programming language)|Swift]], [[Objective-C]], [[JavaScript]], [[C Sharp (programming language)|C#]], [[F Sharp (programming language)|F#]], [[Java (programming language)|Java]], [[ActionScript]], [[AtScript]], [[AssemblyScript]]
Line 28 ⟶ 27:
}}
 
'''ArkTS''' is a [[High-level programming language|high-level]] [[general-purpose programming language|general-purpose]], [[multi-paradigm programming language|multi-paradigm]], [[compiled language|compiled]], [[Declarative programming|declarative]] [[programming language]] developed by [[Huawei]] which is a superset of [[open-source]] [[TypeScript]], in turn a superset of [[JavaScript]] formerly used in July 2022 HarmonyOS 3.0 version, alongside its evolved percussorprecursor, extended TypeScript (eTS) built for [[HarmonyOS]] development as a shift towards [[Declarative programming]].<ref>{{Cite web |last=Paul |first=Wong |date=2024-04-28 |title=Lesson 3: Introduction of the ArkTS Language |url=https://www.paulwong-codecraft.com/post/introduction-of-the-arkts-language |access-date=2024-07-06 |website=Paulwong Codecraft |language=zh}}</ref> ArkTS compiles to machine code via it'sits [[Aheadahead-of-time compilation]] [[Ark Compiler]]. ArkTS was first released in September 30, 2021 on [[OpenHarmony]], and the ArkTS toolchain has shipped in [[DevEco Studio]] since version 3.1, released in 2022.<ref>{{cite web |last1=Amit |title=Breaking: Huawei HarmonyOS 3.1 timeline announced [Developer Preview Released] |url=https://www.huaweiupdate.com/breaking-huawei-harmonyos-3-1-timeline-announced-developer-preview-released/ |website=Huawei Update |publisherdate=HuaweiNovember Update14, 2022 |access-date=12 February 2024}}</ref> Since, [[OpenHarmony]] 4.0 release on October 26, 2023, ArkTS APIs has been added to the open source community to contribute.<ref>{{cite web |title=Getting Started with ArkTS |url=https://docs.openharmony.cn/pages/v4.0/en/application-dev/quick-start/arkts-get-started.md/ |website=OpenAtom OpenHarmony |publisher=OpenAtom OpenHarmony |access-date=12 February 2024}}</ref>
 
Huawei intended ArkTS to support many core concepts associated with extended TypeScript (eTS) based on [[TypeScript]] and in turn [[JavaScript]] from previous versions of HarmonyOS 3.0 with [[ArkUI]] declarative UI app development and 2.0 imperative app development alongside [[Java (programming language)|Java]]. ArkTS was introduced at Huawei's Developer Conference (HDC) 2022 in November 2022 on HarmonyOS 3.1 release.<ref>{{cite web |last1=Balogun |first1=Yusuf |title=Huawei Enters Declarative Development with HarmonyOS 3.1 Version Announcement |url=https://www.techgenyz.com/huawei-enters-declarative-development-harmonyos-3-1-version/ |website=techgenyz |publisher=techgenyz |access-date=12 February 2024}}</ref><ref>{{cite web |last1=Amit |title=Breaking: Huawei HarmonyOS 3.1 timeline announced [Developer Preview Released] |url=https://www.huaweiupdate.com/breaking-huawei-harmonyos-3-1-timeline-announced-developer-preview-released/#google_vignette |website=Huawei Update |publisherdate=HuaweiNovember Update14, 2022 |access-date=12 February 2024}}</ref>
 
It underwent an upgrade in HDC 2023 with HarmonyOS 4.0 API 10 and a major upgrade at January 18, 2024 HarmonyOS Ecology Developer Conference alongside, new Cangjie programming language announced by Huawei where both programming languages become the primary languages for the iterative [[HarmonyOS NEXT]] system version of HarmonyOS operating system.<ref>{{cite web |last1=NYAME |first1=FREDERICK |title=GET READY FOR HARMONYOS 4.0: OFFICIAL ANNOUNCEMENT COMING ON AUGUST 4 |url=https://www.gizchina.com/2023/07/26/get-ready-for-harmonyos-4-0-official-announcement-coming-on-august-4/ |website=GIZMOCHINA |publisherdate=GIZMOCHINAJuly 26, 2023 |access-date=12 February 2024}}</ref><ref>{{cite web |last1=Paul |first1=Peter |title=HarmonyOS NEXT unveiled: A standalone OS without reliance on Android APKs! |url=https://www.gizguide.com/2023/08/harmony-os-next-introduced.html |website=GIZGUIDE |publisher=GIZGUIDE |access-date=12 February 2024}}</ref>
 
The current version of ArkTS, was released on October 26, 2023, for open source OpenHarmony 4.0 API 10 with new ArkTS APIs via [[DevEco Studio]] 4.0 Canary build after HarmonyOS 4.0 release on August 4, 2023.<ref>{{cite web |last1=Li |first1=Deng |title=OpenHarmony 4.0 release version launched with API 10 |url=https://www.huaweicentral.com/openharmony-4-0-release-version-launched-with-api-10/ |website=HC Newsroom |publisherdate=HCOctober Newsroom28, 2023 |access-date=12 February 2024}}</ref> Following current stable release, a preview released in January 2024, with OpenHarmony 4.1 Beta 1 API 11. Alongside, internal [[HarmonyOS NEXT]] Developer Preview 1 and 2 with latest API 11-12 preview based on latest version of [[OpenHarmony]] that features advanced syntax that is matured on the 5.0 version of the [[DevEco Studio]] IDE that is syntactically rigorous and provides more complete and rich capabilities compared to previous versions.<ref>{{cite web |last1=Li |first1=Deng |title=Open source HarmonyOS 4.1 release beta 1 with API 11 interfaces |url=https://www.huaweicentral.com/open-source-harmonyos-4-1-release-beta-1-with-api-11-interfaces/ |website=HC Newsroom |publisherdate=HCJanuary Newsroom2024 |access-date=12 February 2024}}</ref><ref>{{Cite web |title=HarmonyOS Next 开发小记(项目源码分享) - 掘金 |url=https://juejin.cn/post/7356114363881717799?searchId=20240411231707C1D672F50C405B4F4366 |access-date=2024-04-11 |website=juejin.cn}}</ref>
 
== History ==
 
Development of ArkTS started in 2015 by HarmonyOS founder Wang Chenglu, with the eventual collaboration of many other programmers at [[Huawei]] at that time began development of HarmonyOS after being incubated in the R&D labs for a few years as earlier as 2012 within the company. ArkTS was motivated by the need for a replacement for Huawei's earlier programming language [[Java (programming language)|Java]] that not only carried legal baggage but also performance issues, underdeveloped applications in a weaker SDK both HarmonyOS 1.0 Vision TV, IoT and HarmonyOS 2.0 expanded version shipped with and improvements that still lacked in HarmonyOS 3.0 eTS/JS development for HarmonyOS app development that lacked modern features for the modern operating system. ArkTS took language ideas from the likes of [[TypeScript]], [[Swift (programming language)|Swift]], [[Rust (programming language)|Rust]], [[JavaScript]]. On November 2022, Huawei revealed the programming language evolved from eTS on HarmonyOS 3.0 to ArkTS on HarmonyOS 3.1 update. A [[Software release life cycle#Beta|beta version]] of the [[programming language]] was released to registered Huawei developers at the conference and it was not open-sourced at that time until OpenHarmony 3.0 API 7 era under [[OpenAtom Foundation]] when Huawei contributed the ArkTS codes and APIs of HarmonyOS 3.0 which was previously called eTS in September 2021.<ref>{{cite web |last1=Zhang |first1=Phate Zhang |title=Behind the birth of Huawei's HarmonyOS |url=https://cntechpost.com/2020/09/25/behind-the-birth-of-huaweis-harmonyos/#:~:text=During%20his%20time%20at%20Central%20Software%20Institute%2C%20he,sure%20to%20make%20Huawei%27s%20own%20system%20and%20ecology. |website=CNTechPost |publisherdate=CNTechPostSeptember 25, 2020 |access-date=12 February 2024}}</ref>
 
During HDC 2021, in October 2021, Huawei announced [[ArkUI]] with DevEco Studio 3.0 for HarmonyOS 3.0 era, which provides a framework for [[declarative programming|declarative]] UI structure design across all Huawei devices for eTS development which evolved into ArkTS development by HDC 2022 for HarmonyOS 3.1. ArkTS first appeared on OpenAtom's OpenHarmony 3.1 Beta on December 31, 2021 alongside its documentation. <ref>{{cite web |title=OpenHarmony 3.1 Beta |url=https://docs.openharmony.cn/pages/v3.2/en/release-notes/OpenHarmony-v3.1-beta.md/ |website=OpenAtom OpenHarmony |publisher=OpenAtom OpenHarmony |access-date=15 February 2024}}</ref> Since December 2023, [[ArkUI]] is evolved into [[OpenHarmony]] 4.0, also [[Eclipse Foundation]] global OpenHarmony-based Oniro OS with ArkTS programming language support and APIs. Also, Huawei announced it would evolve [[ArkUI]] into a cross-platform declarative UI called [[ArkUI#ArkUI-X|ArkUI-X]] to reduce app development time and costs by bringing it to multiple platforms on [[Android (operating system)|Android]], [[iOS]], [[Microsoft Windows]] and [[macOS]] etc. Including [[EulerOS]] in containers that shares [[HarmonyOS]] application software stack technologies making it easier for interoperability.<ref>{{cite web |title=DevEco Studio 3.0 for HarmonyOS 3.0 and OpenHarmony 3.1 beta releases are here |url=https://developerknow.com/deveco-studio-3-0-for-harmonyos-3-0-and-openharmony-3-1-beta-releases-are-here/ |website=Develop Know |publisher=Develop Know |access-date=12 February 2024}}</ref><ref>{{cite web |last1=Li |first1=Deng |title=Huawei DevEco Studio 3.1 Canary rolling out |url=https://www.huaweicentral.com/huawei-deveco-studio-3-1-canary-rolling-out/ |website=HC Newsroom |publisherdate=HCNovember Newsroom17, 2022 |access-date=12 February 2024}}</ref>
 
=== Version history ===
Line 69 ⟶ 68:
| October 26, 2023
| {{yes}}
| {{noyes}}
|-
|ArkTS 4.1.7.3
|March 30, 2024
| {{yes}}
| {{noyes}}
|}
 
Line 83 ⟶ 82:
The platforms ArkTS supports are [[HarmonyOS]], [[Linux]], [[Windows]], [[macOS]], [[iOS]] and [[Android (operating system)|Android]].
 
A key aspect of ArkTS design is its ability to interoperate with the huge body of existing eTS and JavaScript code developed for Huawei products over the previous versions of HarmonyOS, such as HarmonyOS Design language system, graphical user interface system. On Huawei devices running HarmonyOS, it links with the eTS [[runtime library]], which allows Native APIs in DevEco Studio templates, [[C (programming language)|C]], [[C++]] and ArkTS code to run within one program.<ref>{{cite web |title=HarmonyOS 3.0.0 Developer Preview |url=https://developer.harmonyos.com/en/develop/harmonyos-sdk |website=HarmonyOS |publisher=HarmonyOS |access-date=12 February 2024}}</ref>
 
== Features ==
Line 89 ⟶ 88:
ArkTS is a general purpose programming language that employs modern programming-language theory concepts and strives to present a simple, yet powerful syntax. ArkTS incorporates innovations and conventions from various programming languages, with notable inspiration from [[TypeScript]], which it replaced as the primary development language on [[HarmonyOS]].
 
ArkTS was designed to be safe and friendly to new programmers while not sacrificing speed. By default ArkTS manages all memory automatically and ensures variables are always initialized before use. Array accesses are checked for out-of-bounds errors and integer operations are checked for overflow. Parameter names allow for the creation of clear APIs. Protocols define interfaces that types may adopt, while extensions allow developers to add functionality to existing types. ArkTS enables [[Object-oriented programming|Object-Oriented Programming]] with the support for [[Class (computer programming)|classes]], [[subtyping]], and [[method overriding]]. Optionals allow [[Null pointer|nil]] values to be handled explicitly and safely. Concurrent programs can be written using [[async/await]] syntax and [[Actor model|actors]] isolate shared mutable state in order to eliminate data races.<ref>{{cite web |title=ArkTS Tutorial |url=https://gitee.com/openharmony-sig/arkcompiler_runtime_core/releases/download/sts-spec-release-2023-06-16/ArkTS%20Tutorial-0.7.0.pdf |website=OpenAtom Gitee |publisher=OpenAtom Gitee |access-date=12 February 2024}}</ref>
 
== Examples ==
The following is an example of a simple [["Hello, World!" program|Hello World]] program. It is standard practice in ArkUI with ArkTS programming language to separate the application struct and views into different structs, with the main view named <code>Index</code>.<ref>{{cite web |title=Getting Started with ArkTS in Stage Model - Implementing Page Redirection |url=https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/start-with-ets-stage-0000001477980905-V3 |website=HarmonyOS |publisher=HarmonyOS |access-date=12 February 2024}}</ref>
<syntaxhighlight lang="TypeScript">
import ArkTS
Line 137 ⟶ 136:
== ArkUI-X ==
{{See also|ArkUI}}
ArkUI-X is an [[open-source software|open-source]] [[User interface|UI]] [[software development kit]] which is extension of ArkUI for ArkTS development created by Huawei. It is used to develop [[Cross-platform software|cross platform applications]] from a single [[codebase]] for any platform such as [[Android (operating system)|Android]], [[iOS]], [[OpenHarmony]], Oniro OS and [[HarmonyOS]] which was released on December 8, 2023, after Canary 1 build on August 4, 2023.<ref>{{cite web |title=ArkUI-X Release Notes |url=https://github.com/arkui-x/docs/blob/master/zh-cn/release-notes/README.md |website=ArkUI-X GitHub |publisher=ArkUI-X GitHub |access-date=12 February 2024}}</ref> ArkUI replaces the older [[Interface Builder]] paradigm with a new declarative development paradigm.
 
== Ark TypeScript Runtime ==
{{See also|Ark Compiler}}
ARK TypeScript Runtime is a runtime used in ArkTS applications derived from former HarmonyOS 3.0/OpenHarmony 3.1 API 8 eTS (extendedTypeScript) on OpenHarmony as well as [[HarmonyOS]] apps taking advantage of custom OpenHarmony-based [[HarmonyOS NEXT]] core operating system. It contains an allocator and garbage collector (GC) for ArkTS/JS objects, a standard library that conforms to the ECMAScript specification, an interpreter for running the ARK Bytecode (abc) generated by ARK front-end components, an inline cache for acceleration, a statically typed compiler, a C++/C function interface for Native API (NAPI) application development at runtime, and other modules in [[Ahead-of-time compilation]] via [[DevEco Studio]] since version 3.1.1 on both HarmonyOS 3.1 SDK and OpenHarmony 3.2 SDK API 9.<ref>{{cite web |title=ArkCompiler JS Runtime - ets Runtime |url=https://gitee.com/openharmony/arkcompiler_ets_runtime |website=OpenAtom Gitee |publisher=OpenAtom Gitee |access-date=12 February 2024}}</ref>
 
=== ets_frontend ===
The ets_frontend is a front-end tool in the ARK Runtime Subsystem which combines the ace-ets2bundle component that supports converting ETS programming language files into ARK bytecode files. They correspond with ArkTS app development in OpenHarmony and HarmonyOS development under HarmonyOS NEXT system.<ref>{{cite web |title=ets_frontend |url=https://gitee.com/openharmony/arkcompiler_ets_frontend |website=OpenAtom Gitee |publisher=OpenAtom Gitee |access-date=12 February 2024}}</ref>
 
=== ArkCompiler Toolchain for Debugging ===
The ArkCompiler Toolchain provides developers with debugging tools for ArkTS application development, such as the Debugger, CPUProfiler, and HeapProfiler. The debugging and tuning capabilities provided by the Ark Toolchain is used through [[DevEco Studio]] IDE that relies on the ArkCompiler Runtime to provide runtime-related information to developers.<ref>{{cite web |title=Ark toolchain components |url=https://gitee.com/openharmony/arkcompiler_toolchain |website=OpenAtom Gitee |publisher=OpenAtom Gitee |access-date=12 February 2024}}</ref>
 
== Development tools ==
=== Compiler ===
With [[Ark Compiler]], it supports a variety of dynamic and static programming languages such as [[JavaScript|JS]], [[TypeScript|TS]], and ArkTS. It is the compilation and runtime base that enables OpenHarmony alongside HarmonyOS NEXT 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=OpenAtom Gitee |publisher=OpenAtom Gitee |access-date=12 February 2024}}</ref>
 
=== IDE and editor support ===
[[DevEco Studio]] for HarmonyOS development using default declarative [[ArkUI]], also other third-party UI frameworks on OpenHarmony SDK, [[ArkUI|ArkUI-X]] cross-platform development with [[Android (operating system)|Android]] and [[iOS]] support.<ref>{{cite web |title=ArkUI-X SDK |url=https://github.com/arkui-x/docs/blob/master/en/application-dev/tools/how-to-use-arkui-x-sdk.md |website=ArkUI-X GitHub |publisher=ArkUI-X GitHub |access-date=12 February 2024}}</ref>
 
== See also ==
{{Portal|Computer programming}}
{{Portal|Free and open-source software}}
* [[ArkUI]]
* [[TypeScript]]
Line 163:
* [[Swift (programming language)]]
* [[Kotlin (programming language)]]
* [[Comparison of programming languages]]
 
== References ==