Getting Started
Introduction
Section titled “Introduction”Quant is a statically-typed programming language with C-like syntax. It features a powerful type system, module imports, and modern programming constructs.
Your First Program
Section titled “Your First Program”Let’s start with a simple “Hello, World!” program:
from std import print
fn main() -> int { print("Hello, World!\n"); return 0;}Breaking It Down
Section titled “Breaking It Down”from std import print: Imports theprintfunction from the standard libraryfn main() -> int: Declares the main function that returns an integerprint("Hello, World!\n");: Prints a messagereturn 0;: Returns 0 to indicate successful execution
Basic Program Structure
Section titled “Basic Program Structure”Every Quant program consists of:
- Imports (optional): Import functions or modules you need
- Function Definitions: Define functions with the
fnkeyword - 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;}Import Styles
Section titled “Import Styles”Quant supports two import styles:
Module Import
Section titled “Module Import”import math
fn main() -> int { x: int = int(math.sqrt(16)); return 0;}Selective Import
Section titled “Selective Import”from std import print
fn main() -> int { print("Direct function call\n"); return 0;}Comments
Section titled “Comments”Quant supports two types of comments:
// Single-line comment
/* Multi-line comment can span multiple lines*/
# Alternative single-line comment (Python-style)Statements and Semicolons
Section titled “Statements and Semicolons”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}Next Steps
Section titled “Next Steps”Now that you understand the basics, explore:
- Language Basics - Variables, types, and expressions
- Types Reference - Comprehensive type system documentation
- Control Flow - Conditionals and loops