Introduction to the Alia Language
Overview of Alia
Alia is a "primordial programming language" whose syntax is truly definable. Its design principle is to make syntax the core of the programming language: language features can be extended and customized through syntax definitions, along with a variety of developer-experience optimizations.
Design Principles
- Syntax first: Syntax is the core of Alia; new syntax structures can be defined via the
aliaskeyword - Extensibility: Language features are extended through
aliasdefinitions - Multiple backends: Compilation backends include JavaScript, Node.js, and Rust
- Human friendly: Follows natural language habits, with a comfortable code style and rigorous logic
- AI native: Fully supports artificial intelligence development, forming a brand-new programming paradigm for the AI era
Core Concepts
1. Syntax Definition
At the heart of Alia is the alias keyword, which defines new syntax structures:
alias repeat <Number times> times <Stack stack> -> {
for { let i = 0 } i < times { i ++ } { call stack.run }
}
repeat 3 times { print 'Hello Alia!' }
2. Type System
Alia's types fall into two categories: Code and Value. Code represents code, while Value represents content. Value includes String, Number, Boolean, Null, and Object. The object system includes Array, Object, Stack, Alias, Error, and Channel. Built-in extension types include Sheet, Date, RegExp, Color, and ColoredString.
3. Execution Mechanism
Alia uses stacks (Stack) to carry code execution. Stack provides run to execute content and join to wait for parallel results. break inside a stack body exits the execution.
Getting Started Flow
The getting started flow consists of installing the development environment, creating an .alia file, writing code, and verifying execution. Interpretive execution corresponds to alia start, compiled execution corresponds to alia run, and the project entry file is main.alia.
Example Code
print 'Hello World!'
for { let i = 0 } i < 10 { i ++ } { print i }