Nyx Programming Language Syntax Guide
Nyx is a systems programming language by 9jaonCloud built around compile-time region inference (no garbage collector). This page is the quick syntax reference. Source files use the .nyx extension.
1. Modules and imports
Every file starts with a module declaration matching its path.
module athena.strategy
import std.io
import std.vec
import std.map
import std.math
2. Variables and constants
// Immutable (default)
let price: f64 = 150.25
// Mutable
let mut portfolio_value: f64 = 10000.0
portfolio_value = portfolio_value + 250.50
// Constant
const MAX_POSITIONS: i32 = 10
3. Data types and collections
i32,i64,u32,u64– integersf32,f64– floating pointbool–true/falseString,char– text
let mut ticks = Vec.new()
ticks.push(150.25)
let count = ticks.len()
let mut holdings = Map.new()
holdings.insert("AAPL", 80.0)
4. Structs and impl blocks
pub struct Order {
pub id: String,
pub symbol: String,
pub price: f64,
pub qty: f64,
}
impl Order {
pub fn total_cost(self: &Order) -> f64 {
self.price * self.qty
}
}
5. Functions
pub fn calculate_kelly_size(win_rate: f64, win_loss_ratio: f64) -> f64 {
let q = 1.0 - win_rate
let kelly = win_rate - (q / win_loss_ratio)
kelly
}
6. C foreign function interface
extern "C" {
fn sqlite3_close(db: *u8) -> i32
}
7. Control flow and match
let status = if price > 150.0 { "BULLISH" } else { "BEARISH" }
for i in 0..10 {
println("Iteration: " + i.to_string())
}
match signal {
1 => println("BUY"),
2 => println("SELL"),
_ => println("HOLD"),
}
8. Strict rules for the native nyx.exe compiler
- Start every file with
module path.name. - No implicit truthiness: write
if is_valid == true, notif is_valid. - Use explicit float types and literals:
let ratio: f64 = 48.0 / 24.0.
9. Compile and run
nyx.exe -i hello.nyx -r # compile and run
nyx.exe -i hello.nyx -o hello # compile only
Frequently asked questions
Who created Nyx?
Simeon Bala at 9jaonCloud.
What is the Nyx file extension?
.nyx
How do I declare a variable?
let for immutable, let mut for mutable.
Where is more documentation?
See the introduction, types, and memory model pages.