DEV Community

HarmonyOS
HarmonyOS

Posted on

Introducing ArkTS, Huawei’s Next-Generation Development Language

Read the original article:Introducing ArkTS, Huawei’s Next-Generation Development Language

Hello, in this article, I will introduce Huawei’s next-generation development language, ArkTS, and we will discuss the innovations it offers and how it enhances the developer experience.

Introduction

Huawei continues to revolutionize not only hardware but also the software ecosystem. With its own operating system HarmonyOS Next, Huawei offers a powerful alternative in the mobile technology world, and with the new programming language ArkTS, it elevates the process of software development, making it more efficient, secure, and modern.

Built on the foundations of TypeScript, ArkTS provides developers with a familiar syntax while introducing additional features and optimizations tailored to the needs of HarmonyOS. In this article, we will explore the core differences of ArkTS and Huawei’s vision for app development with examples.

Why Did Huawei Develop ArkTS?

Huawei is not just pushing the boundaries in hardware but also ensuring seamless integration of software with its HarmonyOS, enhancing the interconnectedness between devices. To achieve this vision, achieving the highest standards in performance, security, and sustainability is essential. This is where ArkTS shines as a high-performance, optimized language for building applications on HarmonyOS.

ArkTS is not just a programming language; it is a representation of Huawei’s new approach to software engineering.

ArkTS vs. TypeScript: Key Differences

While ArkTS offers a syntax similar to TypeScript, it stands out with its mobile app optimizations and a more performance-focused structure:

Mandatory Static Types

In TypeScript, type annotations are optional, but in ArkTS, they are mandatory. This ensures more stable and secure applications by catching errors during compile time.

// TypeScript 
let name = "Huawei";  // TypeScript infers 'name' as type string
name = 123;           //Error in strict mode: "Type 'number' is not assignable to type 'string'"

// ArkTS
let name: string = "Huawei";  // Type must be explicitly declared
name = 123;                  // Compilation error: "Type 'number' is not assignable to type 'string'"
Enter fullscreen mode Exit fullscreen mode

Unlike TypeScript, which allows structural typing (accepting different types as long as they have the same properties), ArkTS does not support this feature. This strengthens type safety and ensures clearer, more predictable behavior.

Object Memory Layout is Immutable

ArkTS does not allow changes to the object memory layout at runtime. This decision ensures better performance and more predictable behavior, particularly in memory-intensive operations.

Operator Semantics Are Restricted

For example, the “+” operator in ArkTS can only be used with numbers, requiring specific methods for string concatenation. This makes the language more explicit and predictable in its behavior.

ArkTS and ArkUI: Strong UI Integration

Huawei doesn’t position ArkTS merely as a backend language; instead, it integrates deeply with ArkUI, the declarative UI framework of HarmonyOS. This integration enables developers to create interactive, component-based UIs with ease.

Declarative UI Development

@Component
struct HelloWorld {
  @State message: string = "Hello ArkTS!"

  build() {
    Column() {
      Text(this.message)
        .fontSize(20)
        .onClick(() => {
          this.message = "Clicked!";
        })
    }
    .width('100%')
    .height('100%')
  }
}
Enter fullscreen mode Exit fullscreen mode

State Management: @State, @prop, @link

@Component
struct ParentComponent {
  @State parentMessage: string = "Parent Component Message"

  build() {
    Column() {
      ChildComponent({ childMessage: this.parentMessage })
      Button("Change Message")
        .onClick(() => {
          this.parentMessage = "New Message!";
        })
    }
  }
}

@Component
struct ChildComponent {
  @Prop childMessage: string

  build() {
    Text(this.childMessage)
  }
}
Enter fullscreen mode Exit fullscreen mode

Dynamic UI: Conditional Rendering and Lists

@Component
struct UserList {
  @State users: string[] = ["Ali", "Ayşe", "Mehmet"]

  build() {
    List() {
      ForEach(this.users, (user: string) => {
        ListItem() {
          Text(user)
        }
      })
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Compatibility with JavaScript and TypeScript

Thanks to Huawei's developer-friendly approach, you can easily integrate existing JavaScript/TypeScript modules within ArkTS.

// utils.js
export function add(a, b) {
  return a + b;
}

// Usage in ArkTS
import { add } from './utils';

let result = add(5, 3); // 8
Enter fullscreen mode Exit fullscreen mode

A New Era of Development with Huawei

Huawei is transforming the world of software development with HarmonyOS, and ArkTS stands at the heart of this transformation. It offers a powerful, high-performance tool tailored to modern development needs while maintaining the core advantages of TypeScript.

If you’re already familiar with TypeScript, transitioning to ArkTS will be a seamless process. However, ArkTS’s strict type controls, performance optimizations, strong UI integration, and security advantages provide a whole new level of development experience.

Joining the growing HarmonyOS ecosystem with Huawei is not just about staying ahead; it’s about investing in the future of technology.

📚 For more information, visit the Huawei Developer portal.

Result

With ArkTS, Huawei is not just introducing a new programming language — it is empowering developers to build more robust, high-performance, and secure applications. Built on top of TypeScript, ArkTS enhances the development process with strict type rules, restricted and predictable behaviors, and a focus on performance and reliability.

Its deep integration with ArkUI enables developers to build user interfaces more easily and effectively, making it a powerful tool especially for those working within the HarmonyOS ecosystem.

Prioritizing developer experience, ArkTS represents a modern approach to software engineering. If you are already familiar with TypeScript, transitioning to ArkTS will be smooth — but with the innovations ArkTS offers, your development process will reach a whole new level of quality. Joining Huawei’s HarmonyOS vision means not just keeping up with today’s technology, but investing in the future.

References

Getting Started with ArkTS

Learning ArkTS

ArkTS Coding Style Guide

https://forums.developer.huawei.com/forumPortal/en/topic/0203190033426165054?fid=0102647487706140266

Written by Baris Tuzemen

Top comments (1)

Collapse
 
rentingting602 profile image
RenTingting602

Appreciate you writing this.