AssemblyScript is a programming language designed to be a subset of TypeScript, a popular programming language that is a strict syntactical superset of JavaScript. AssemblyScript is designed to be compiled to WebAssembly, a low-level binary format that can be run in web browsers and other environments.

AssemblyScript is often used to write high-performance code that needs to run in a web browser or other environment that supports WebAssembly. It is particularly useful for writing code that needs to interact with Web APIs or perform complex calculations.

One of the main features of AssemblyScript is its type system, which is based on TypeScript's type system. This allows developers to use types to ensure that their code is correct and easy to understand. AssemblyScript also includes features such as classes, interfaces, and modules, which can be used to organize and structure code in a logical way.


Here is an example of AssemblyScript code that defines a function that adds two numbers and returns the result:

export function add(x: i32, y: i32): i32 {
  return x + y;

This code defines a function called **add** that takes two arguments, **x** and **y**, both of which are 32-bit integers (denoted by **i32**). The function returns the sum of **x** and **y**, which is also a 32-bit integer.

Here is another example that defines a class and a method:

export class Point {
  x: f64;
  y: f64;

  constructor(x: f64, y: f64) {
    this.x = x;
    this.y = y;

  distanceToOrigin(): f64 {
    return Math.sqrt(this.x * this.x + this.y * this.y);

This code defines a class called **Point** with two properties, **x** and **y**, both of which are 64-bit floating point numbers (denoted by **f64**). The class has a constructor that initializes the **x** and **y** properties, and a method called **distanceToOrigin** that calculates the distance from the point to the origin (0, 0).