Complete Masterclass Guide
A complete, line-by-line breakdown of every feature in Cruise v0.3.0. From zero syntax knowledge to building deep learning models and GUIs!
01
Variables, Types & Console Output
Learn how to declare variables with let or single-assignments, work with strings/numbers, and output values using write().
# Lesson 01: Declaring Variables and Printing Output
let name = "Cruise Language"
let version = 0.3
let is_active = 1
write("Welcome to " + name)
write("Current Version:")
write(version)
Line 1: Comments start with # and are safely ignored by the Lexer scanner.
Line 2: let name = "Cruise Language" creates a StringNode in the AST and registers name in memory.
Line 3: let version = 0.3 stores float representation 0.3 in variable version.
Line 4: let is_active = 1 defines an integer token stored into memory scope.
Line 6: write("Welcome to " + name) concatenates the string and variable, then outputs to stdout.
Line 7-8: Prints the literal string label followed by the numeric value of version.
02
Conditionals & Comparison Logic
Perform decision making using if, else, and closing end keywords.
let score = 85
if score >= 50:
write("Status: Passed! π")
else:
write("Status: Needs Improvement β")
end
Line 1: Initializes score with integer value 85.
Line 3: if score >= 50: evaluates comparison operator. Note the mandatory trailing colon (:).
Line 4: Evaluates because 85 is greater than or equal to 50, outputting success message.
Line 5-6: The else: block is skipped by the Evaluator during runtime execution.
Line 7: end explicitly closes the AST IfNode conditional construct.
03
Loops & Iterative Execution
Iterate dynamically over code using while condition loops and block terminators.
let counter = 1
while counter <= 3:
write("Loop Iteration Step:")
write(counter)
let counter = counter + 1
end
Line 1: Sets variable counter starting point to integer 1.
Line 3: while counter <= 3: continuously checks state until counter exceeds 3.
Line 4-5: Prints loop progress text and the current value stored in counter.
Line 6: Increments variable counter by 1 in every iteration step to prevent infinite loops.
Line 7: end closes the AST WhileNode statement block.
04
Functions & Local Environment Scope
Create modular routines with fn, pass parameters, and pass data back using return.
fn compute_area(width, height):
let area = width * height
return area
end
let total = compute_area(5, 10)
write("Total Calculated Area:")
write(total)
Line 1: fn compute_area(width, height): registers a FuncNode in global symbol environment.
Line 2: Calculates product inside a isolated local memory scope instance.
Line 3: return area raises a ReturnException to cleanly pass value back to parent environment.
Line 4: end terminates the function definition statement.
Line 6: Calls function with positional parameters 5 and 10, storing returned 50 into total.
Line 7-8: Outputs the resulting computation directly to terminal stdout.
05
Modules & Local File Imports
Break projects into clean files and load shared logic dynamically with import.
# Inside helper.cru
fn calculate_tax(amount):
return amount * 0.15
end
# Inside main.cru
import helper
let tax = calculate_tax(100)
write("Tax Amount:")
write(tax)
Line 1-4: File helper.cru defines reusable calculation utility function calculate_tax.
Line 7: import helper looks up helper.cru, tokenizes, parses, and evaluates its AST in current environment.
Line 9: Invokes function imported directly from the secondary module file seamlessly.
Line 10-11: Prints calculated tax value (15.0) to stdout console.
06
CPM Package Manager
Install, manage, and execute external community libraries from terminal using Cruise Package Manager.
# Step 1: Install remote package via Terminal
$ cruise install math_extra
# Step 2: Use in your script file (app.cru)
import math_extra
math_extra_hello()
Line 2: Terminal command cruise install math_extra triggers CPM registry lookup and downloads package.
Line 5: import math_extra reads newly downloaded math_extra.cru module file into local folder.
Line 7: Executes package function math_extra_hello() directly inside project space.
07
PyTorch Tensor Calculus & Autograd
Perform multi-dimensional matrix operations and automatic backpropagation using native tensor engine integrations.
let x = tensor([1.0, 2.0, 3.0, 4.0], true)
let y = x * 2.0
write("Tensor Matrix Result:")
write(y)
Line 1: tensor([...], true) creates a PyTorch FloatTensor object with autograd enabled (requires_grad=True).
Line 2: Multiplies whole tensor matrix array element-wise by scalar value 2.0.
Line 4-5: Prints calculated output tensor result matrix [2.0, 4.0, 6.0, 8.0].
08
Machine Learning Optimizers (Adam / SGD)
Train machine learning model parameter weights directly within Cruise scripts using built-in optimizers.
let weights = tensor([0.5, 1.5], true)
let optimizer = opt_adam([weights], 0.01)
write("Optimizer Initialized:")
write(weights)
Line 1: Initializes model weight parameter tensor array with autograd enabled.
Line 2: opt_adam([weights], 0.01) creates an Adam gradient descent optimizer instance bound to parameters.
Line 4-5: Outputs configured parameter state to console stdout.
09
Built-in Math & Trigonometry Library
Access math functions like sin, cos, sqrt, and mathematical constant pi directly.
let angle = pi / 2
let sine_val = sin(angle)
let root_val = sqrt(64)
write("Sine of Pi/2:")
write(sine_val)
write("Square Root of 64:")
write(root_val)
Line 1: Uses built-in constant pi (3.14159...) and divides by 2.
Line 2: sin(angle) computes trigonometric sine calculation (1.0).
Line 3: sqrt(64) calculates mathematical square root value (8.0).
Line 5-8: Prints evaluated math results directly to terminal console stdout.
10
Desktop GUI App Framework
Mount interactive Tkinter desktop GUI application windows and event handlers in single function calls.
fn on_button_click():
write("Button Click Event Triggered! π")
end
gui_window("Cruise App", "Click Me!", on_button_click)
Line 1-3: Defines custom callback event handler routine on_button_click.
Line 5: gui_window(...) initializes desktop window titled "Cruise App" with interactive button and callback handler.
Master all keyword functions, operators, and standard capabilities built into Cruise v0.3.0.
| Feature Category |
Cruise v0.3.0 Command Syntax |
Description & Behavior |
| Functions |
fn greet(user): ... end |
Defines modular AST function blocks with parameters and return statements. |
| Variable Assignment |
let x = 100 |
Assigns numbers, strings, lists, or tensors into scoped environments. |
| Conditionals |
if x == y: ... else: ... end |
Full multiline conditional branching with support for both '=' and '=='. |
| Loops |
while x < 10: ... end |
Executes AST code blocks while evaluation condition remains true. |
| Package Manager |
cruise install math_extra |
Terminal command to fetch and install external Cruise packages. |
| Modules |
import math_extra |
Loads local or CPM-installed `.cru` module code into execution scope. |
| Tensors |
t = tensor([1.0, 2.0], true) |
Creates PyTorch tensors with autograd automatic differentiation enabled. |
| Desktop GUI |
gui_window("App", "Click", fn) |
Mounts an interactive window interface with button event handlers. |
Discover tools, package managers, and standard extensions for Cruise.
PyPI Package (`cruise-lang`)
The core v0.3.0 engine with AST parser and REPL shell is published on PyPI. Install it on any machine running Python 3.8+.
pip install --upgrade cruise-lang
CPM Package Manager
Fetch, manage, and load community modules straight from your terminal into your workspace automatically.
cruise install <package_name>
Future features and milestone releases for Cruise Language.
v0.1.1 β Initial Release
Core Interpreter & REPL Shell
Published REPL shell, initial variables, loops, and basic stdout functions.
Completed
v0.2.1 β Milestone Release
Functions & HTTP Engine
Added custom user functions, `.cru` / `.crui` dual extension support, and HTTP request library.
Completed
v0.3.0 β Current Live Release π
AST Parser, Lexer, CPM & Modules Engine
Complete AST Lexer Tokenizer engine, CPM package manager, module imports, PyTorch tensor calculus & optimizers, math library, and GUI framework.
Completed
Core Maintainer & Creator
Meet the creator behind Cruise Language and open-source developer tooling.
Creator of Cruise Language (`cruise-lang`) & Open Source Developer
Passionate about programming language design, PyTorch deep learning frameworks, interpreter architecture, and developer tools. Manjas created Cruise Language to bridge the gap between human-readable domain scripting and native matrix tensor calculus.
Main Focus
AI & Interpreters
Package Manager
PyPI Author
Language
Cruise (`.cru`)