What do you think of Huawei’s Hongmeng ArkTS language?

ArkTS is the application development language of Hongmeng Ecosystem. On the basis of maintaining the basic syntax style of TypeScript (TS for short), it imposes stricter constraints on the dynamic type characteristics of TS and introduces static types. At the same time, it provides declarative UI, state management and other corresponding capabilities, allowing developers to develop high-performance applications in a simpler and more natural way.

Natural and concise syntax

ArkTS provides simple and natural declarative syntax, componentization mechanism, data-UI automatic association and other capabilities, realizing a programming method that is close to natural language and more efficient in writing, and brings developers easy-to-learn, easy-to-understand, and minimalist development. Premium experience.

v2-1b895d2492bc89a426877759ce551f67_720w.gif

Lightweight concurrency mechanism

The ArkCompiler runtime provides Worker API on HarmonyOS to support concurrent programming. Based on the memory isolation of runtime instances, ArkCompiler optimizes the startup performance and memory overhead of concurrently running instances by sharing immutable or non-volatile objects, built-in code blocks, method bytecodes and other technical means in running instances.

v2-67e0f58e9dc35b145ffde367aca7ad56_720w.gif

Basic syntax overview

After a preliminary understanding of the ArkTS language, we use a specific example to illustrate the basic composition of ArkTS. As shown in the figure below, when the developer clicks the button, the text content changes from "Hello World" to "Hello ArkUI". Figure 1 Example renderings

v2-a6464697baf1b51c0598e050bd4ca553_720w.gif

In this example, the basic composition of ArkTS is as follows. Figure 2 Basic composition of ArkTS

image.png

  • Decorators: Used to decorate classes, structures, methods and variables and give them special meanings. For example, in the above example, @Entry, @Component and @State are all decorators. @Component represents a custom component, @Entry represents the custom component as an entry component, and @State represents the state variable in the component. Changes in the state variable will trigger the UI. refresh.
  • UI description: Describe the structure of the UI in a declarative manner, such as the code block in the build() method.
  • Custom component: A reusable UI unit that can be combined with other components, such as the above struct Hello decorated with @Component.
  • System components: The default built-in basic and container components in the ArkUI framework can be directly called by developers, such as Column, Text, Divider, and Button in the example.
  • Property methods: Components can configure multiple properties through chain calls, such as fontSize(), width(), height(), backgroundColor(), etc.
  • Event method: Components can set the response logic of multiple events through chain calls, such as onClick() following Button.

In addition, ArkTS extends a variety of syntax paradigms to make development more convenient:

  • @Builder/@BuilderParam: Special method of encapsulating UI description, fine-grained encapsulation and reuse UI descriptions.
  • @Extend/@Style: Extend built-in components and encapsulated attribute styles for more flexible combinations Built-in components.
  • stateStyles: Polymorphic styles, which can set different styles according to the internal state of the component.

ArkTS language learning content

A set of learning roadmap is attached here. You can refer to the high-definition full version"Pureblood Hongmeng Development 4.0 Advanced Documentation"Click to view to save it.

at last

ArkTS is the application development language of Hongmeng Ecosystem. Now that Hongmeng is starting to break away from android, learning the ArkTS language developed by Hongmeng is the foundation that must be learned; if you want to enter the Hongmeng development industry, you must learn it quickly. Now it seems that the popularity of Hongmeng is rising. Hongmeng is a trend on the Internet, and programmers must seize the market dividends.

Finally, there is no correct Hongmeng Learning route and documentation. You can refer to the notes above to learn more.

Guess you like

Origin blog.csdn.net/m0_70748845/article/details/134864784