Skip to content

Getting Started

Quant is a statically-typed programming language with C-like syntax. It features a powerful type system, module imports, and modern programming constructs.

Let’s start with a simple “Hello, World!” program:

from std import print
fn main() -> int {
print("Hello, World!\n");
return 0;
}
  • from std import print: Imports the print function from the standard library
  • fn main() -> int: Declares the main function that returns an integer
  • print("Hello, World!\n");: Prints a message
  • return 0;: Returns 0 to indicate successful execution

Every Quant program consists of:

  1. Imports (optional): Import functions or modules you need
  2. Function Definitions: Define functions with the fn keyword
  3. Main Function: The entry point of your program (unless it’s a library)
import math
from std import print
fn main() -> int {
// Your code here
return 0;
}

Quant supports two import styles:

import math
fn main() -> int {
x: int = int(math.sqrt(16));
return 0;
}
from std import print
fn main() -> int {
print("Direct function call\n");
return 0;
}

Quant supports two types of comments:

// Single-line comment
/*
Multi-line comment
can span multiple lines
*/
# Alternative single-line comment (Python-style)

All statements in Quant must end with a semicolon (;):

fn main() -> int {
x: int = 10; // Variable declaration
print("%d\n", x); // Function call
return 0; // Return statement
}

Now that you understand the basics, explore: