· Blog  · 3 min read

How to write a programming language from scratch? - AQ

How to write a programming language from scratch? AQ is a fast, small, simple and safe interpreted programming language.

How to write a programming language from scratch? AQ is a fast, small, simple and safe interpreted programming language.

Introduction

How to design a programming language from scratch? What parts should a new programming language include?
This article will detail the process of developing a programming language through the design of AQ, starting from scratch to designing, developing the compiler, and related infrastructure, eventually completing the construction of a programming language.

Introduction to AQ

AQ is an interpreted programming language. It is fast, small, simple, and secure. Programs written in AQ can also be compiled. Additionally, the source code of AQ is available on GitHub, open source, and follows the AQ License.

GitHub address: https://github.com/aq-org/AQ, where you can obtain the source code of AQ.

Features

  • Fast (source code compilation and run speed)
  • Small (source code size)
  • Simple (easy to learn)
  • Secure (safe memory management and code checks)
  • Cross-platform (supports Windows, Linux, and MacOS, etc.)
  • C++-like syntax (quick to grasp)
  • Interpreted (optional compilation)
  • Free (follows AQ License)
  • Open source (based on AQ License)

Design

Original Plan

AQ initially began development in October 2023 and underwent restructuring on February 1, 2024, with multiple revisions forming the current framework.

The original plan was to implement the compiler in C++ and then develop the virtual machine. However, since the compiler needed to translate to the virtual machine’s bytecode and due to prolonged compiler development time, the original version was abandoned. The code has been entirely deleted but can be found in the commits.

New Plan

The new plan is to develop the AQ virtual machine first and then implement the compiler through other means. Since it’s developed in C, the AQ virtual machine reduces performance overhead and gains broader support. The AQ virtual machine is currently divided into interpreter, memory, runtime, and operating system library.

  1. The interpreter is the execution engine of the AQ virtual machine. Bytecode instruction execution functions are currently being developed.
  2. Memory is the storage of the AQ virtual machine. For efficiency reasons, the AQ virtual machine is based on a register architecture. A garbage collection mechanism will be added in the future.
  3. The runtime is the dependent environment of the AQ virtual machine, including error handling, standard output, and other necessary components, providing a basic runtime environment for AQ.
  4. The operating system library is the necessary component for the AQ virtual machine to interact with the operating system.

These four parts of the design essentially include most of the components of an interpreted language’s virtual machine. As the functionality of the programming language continues to expand in the future, upgrades can be implemented by adding components.

Reasons and Advantages

The AQ language is designed as an interpreted language for multi-platform compatibility. In the future, further compiler development work for different operating systems can make development more efficient. Based on the register architecture, it also reduces performance loss.

We are working hard on developing the AQ virtual machine. If you want to learn more or participate in the development work, please follow our official website: https://www.axa6.com and GitHub: https://github.com/aq-org/AQ.

This article is published under the AQ License: https://github.com/aq-org/AQ/blob/main/LICENSE. If needed, please adapt or reprint according to the AQ License.

Share:
Back to Blog

Related Posts

View All Posts »
Type Definition of AQ Virtual Machine - AQ

Type Definition of AQ Virtual Machine - AQ

Since different systems, hardware and other external conditions have different support and definitions for memory, it is necessary to design a unified type standard in order to make AQ virtual machine meet the requirements of cross-platform operation. This article defines and standardizes the type of AQ virtual machine to ensure that AQ virtual machines on different systems can run normally.

An excellent virtual machine memory architecture - AQ

An excellent virtual machine memory architecture - AQ

The memory architecture of a virtual machine directly affects the performance and occupancy of the virtual machine. Designing an excellent architecture can effectively improve performance and efficiency. This article will introduce the memory architecture used by the AQ virtual machine.

Announcement on multi-language support for the AQ official website - AQ

Announcement on multi-language support for the AQ official website - AQ

Due to the increasing development work of AQ, the lack of professional translators and unsatisfactory translation results, the multi-language version of the AQ official website will be temporarily suspended from real-time maintenance from today. Only English and Chinese will be supported.