Complete Developer Masterclass
Master every keyword, function, file operation, and deep learning tensor operator in Cruise v0.4.2 with line-by-line breakdowns! 🚀
01
Variables, Types & Console Printing
Cruise supports let =, let be, or direct assignment, and prints using write().
# Lesson 01: Variables and Outputs
let name = "Cruise"
let version be 0.42
total_users = 1000
write("Welcome to " + name)
write("Version:")
write(version)
write(total_users)
Line 1: Comments start with # and are safely ignored by the Lexer.
Line 2: let name = "Cruise" stores string "Cruise" into the Environment memory frame.
Line 3: let version be 0.42 uses Cruise's natural English assignment keyword be to assign float 0.42.
Line 4: total_users = 1000 demonstrates direct assignment without keywords.
Line 6: write(...) concatenates strings and outputs "Welcome to Cruise" to terminal stdout.
Line 7-9: Evaluates and prints stored numerical values.
02
Functions & Return Values (`fn` / `define`)
Declare reusable logic blocks using fn or define, accept parameters, and return calculated output with return and end.
fn calculate_rectangle(width, height):
let area = width * height
return area
end
let result = calculate_rectangle(8, 5)
write("Calculated Area:")
write(result)
Line 1: fn calculate_rectangle(width, height): defines a FuncNode taking parameters width and height.
Line 2: Calculates multiplication product inside an isolated local execution scope.
Line 3: return area raises a ReturnException to pass the value back to the caller.
Line 4: end marks the termination of the function definition block.
Line 6: Invokes function and stores returned integer 40 into result.
Line 7-8: Outputs the resulting computation directly to stdout.
03
Conditionals & Branching (`if ... else ... end`)
Perform decision logic using if, else, and closing end keywords.
let accuracy = 94
if accuracy >= 90:
write("Model Status: High Performance! 🚀")
else:
write("Model Status: Retraining Required ⚠️")
end
Line 1: Sets numerical variable accuracy to 94.
Line 3: if accuracy >= 90: evaluates comparison operator condition.
Line 4: Executes primary branch since 94 is greater than or equal to 90.
Line 5-6: The else: fallback path is cleanly bypassed.
Line 7: end closes the AST IfNode conditional construct.
04
Loops: Single-line `times` & Dynamic `while`
Cruise supports fast repetition with N times <stmt> and while loops with while <cond>: ... end.
# Single-line Quick Automation Loop
3 times write("Cruising at High Speed! ⚡")
# Dynamic While Loop with State Accumulation
let step = 1
while step <= 3:
write("Processing Step:")
write(step)
let step = step + 1
end
Line 2: 3 times write(...) repeats the given statement exactly 3 times without loop boilerplate.
Line 5: Initializes step counter tracking variable step.
Line 6: while step <= 3: checks state before executing loop body.
Line 9: Increments step by 1 in each cycle.
Line 10: end closes the AST WhileNode statement block.
05
Arrays & Index Access (`arr[i]`)
Create lists of items using bracket syntax [elem1, elem2] and retrieve elements by 0-based index.
let scores = [98, 85, 92, 77]
write("First Score:")
write(scores[0])
write("Third Score:")
write(scores[2])
Line 1: let scores = [...] constructs a ListNode holding 4 integer items.
Line 4: scores[0] accesses first element (98) via AST IndexNode.
Line 6: scores[2] accesses third element (92).
06
PyTorch Tensor Calculus & Autograd
Construct multidimensional PyTorch FloatTensors, perform matrix arithmetic, and execute autograd backpropagation.
let w = tensor([2.0, 4.0], true)
let x = tensor([1.0, 3.0], true)
let y = (w * x) + 1.0
write("Calculated Tensor:")
write(y)
Line 1-2: tensor([...], true) creates PyTorch FloatTensors with autograd tracking enabled (requires_grad=True).
Line 3: Multiplies tensors element-wise and adds scalar 1.0.
Line 5-6: Prints tensor result matrix [3.0, 13.0].
07
Deep Learning Optimizers (`opt_adam` / `opt_sgd`)
Train machine learning model parameter weights directly using built-in Adam and SGD optimizer bindings.
let weights = tensor([0.5, 1.5], true)
let optimizer = opt_adam([weights], 0.01)
write("Optimizer Initialized:")
write(weights)
Line 1: Initializes parameter weights tensor with gradient calculation enabled.
Line 2: opt_adam([weights], 0.01) binds an Adam optimizer instance with learning rate 0.01.
Line 4-5: Prints initialized optimizer parameter state directly to stdout.
08
Math Library (`sin`, `cos`, `sqrt`, `pi`)
Execute mathematical and scientific operations directly using native standard library functions.
let angle = pi / 2
let s = sin(angle)
let root_val = sqrt(64)
write("Sine of Pi/2:")
write(s)
write("Square Root of 64:")
write(root_val)
Line 1: Accesses mathematical constant pi (3.14159...) and divides by 2.
Line 2: sin(angle) computes trigonometric sine (1.0).
Line 3: sqrt(64) computes square root (8.0).
Line 5-8: Outputs evaluated numerical values to console.
09
HTTP API Requests (`fetch` & `post`)
Communicate with external REST APIs and parse JSON responses automatically using fetch() and post().
# Send HTTP GET Request
let github_info = fetch("https://api.github.com")
write("GitHub API Status:")
write(github_info)
Line 2: fetch(...) performs GET request with standard headers and automatically decodes JSON response payloads.
Line 4-5: Outputs parsed dictionary response directly to stdout.
10
Desktop GUI Framework (`gui_window`)
Mount interactive Tkinter desktop GUI windows and bind button click handlers in a single call.
fn on_button_click():
write("Button Clicked Successfully! 🚀")
end
gui_window("Cruise Desktop App", "Launch Model", on_button_click)
Line 1-3: Defines custom callback event handler routine on_button_click.
Line 5: gui_window(...) initializes Tkinter window titled "Cruise Desktop App" with interactive button and headless fallback.
11
CPM Package Manager & Module Imports
Install community libraries from terminal via CPM and load modules using import module_name.
# Step 1: Install Package from Terminal
$ cruise install math_extra
# Step 2: Use in your script (app.cru)
import math_extra
math_extra_info()
Line 2: Terminal command cruise install math_extra fetches library from registry and saves math_extra.cru locally.
Line 5: import math_extra tokenizes, parses, and evaluates module AST into current Environment.
Line 7: Executes imported package routine math_extra_info() seamlessly.
12
Native File System (`fs`) Operations 📁✨
Perform real disk input/output directly in Cruise without external modules using built-in write_file(), read_file(), and file_exists().
# Write data to a text file
write_file("cruise_log.txt", "Cruise v0.4.2 is running fast! ⚡")
# Check if file exists on disk
if file_exists("cruise_log.txt"):
let content = read_file("cruise_log.txt")
write("Read from disk:")
write(content)
end
Line 2: write_file(path, data) saves the text string directly to the local disk file using UTF-8 encoding.
Line 5: file_exists(path) returns boolean true or false checking disk presence.
Line 6: read_file(path) reads the full disk file contents into memory variable content.
Line 7-8: Outputs the file content straight to standard terminal output.
Quick reference cheat-sheet for all keywords, expressions, tensor operators, and built-ins in Cruise v0.4.2. ⚡
| Feature Category |
Cruise v0.4.2 Syntax |
Description & Behavior |
| Functions |
fn name(a, b): ... return x end |
Defines scoped AST function blocks (supports both fn and define). |
| Variables |
let x = 10 / let x be 10 / x = 10 |
Assigns numbers, strings, lists, or tensors into current environment frame. |
| Conditionals |
if x >= y: ... else: ... end |
Multiline conditional branching blocks with comparison operators. |
| Automation Loops |
3 times write("Cruising!") |
Single-line repeated execution loop construct. |
| While Loops |
while x < 10: ... end |
Executes body statements while condition expression evaluates to true. |
| Array Indexing |
arr = [1, 2, 3]; val = arr[0] |
Creates lists and accesses elements by 0-based bracket index. |
| PyTorch Tensors |
t = tensor([1.0, 2.0], true) |
Creates PyTorch FloatTensors with autograd differentiation enabled. |
| Optimizers |
opt = opt_adam([t], 0.01) |
Binds native Adam or SGD gradient descent optimizers to parameters. |
| File System (fs) |
read_file(f) / write_file(f, txt) |
Native disk file I/O operations and existence validation via file_exists(). |
| HTTP Suite |
data = fetch(url) / post(url, obj) |
Sends HTTP GET & POST requests with automatic JSON parsing. |
| Desktop GUI |
gui_window("App", "Click", fn) |
Mounts desktop application window with button event callback handler. |
| Package Manager |
cruise install pkg_name |
Terminal command to fetch and install reusable Cruise libraries via CPM. |
Explore the runtime package tools and standard extensions built for Cruise.
PyPI Package (`cruise-lang`)
The core engine with AST parser, REPL shell, PyTorch calculus, native File System (fs), and package manager is distributed via PyPI. Install it across Linux, macOS, Windows, or iPadOS terminal environments.
pip install cruise-lang
CPM Package Manager
Fetch, download, and configure modular community packages straight from your terminal into your workspace with zero configuration.
cruise install <package_name>
Release history and milestones for Cruise Programming Language.
v0.1.0 — Foundation
Core Interpreter & REPL Shell
Published REPL shell, initial variable allocations, and basic stdout functions.
Completed
v0.2.0 — Functions & HTTP
Custom Functions & HTTP Engine
Added custom user functions, `.cru` / `.crui` dual extension execution, and HTTP requests.
Completed
v0.3.0 — AST Engine & CPM
Complete AST Lexer & Package Manager
Integrated full AST parser, token lexer, CPM package manager, and scoped memory frames.
Completed
v0.4.0 — Deep Learning & Tooling
Tensor Calculus, Optimizers, Indexing & GUI
Native PyTorch autograd derivatives, Adam/SGD optimizers, single-line `times` automation loops, bracket indexing, Tkinter desktop GUIs, and full HTTP suite.
Completed
v0.4.1 — Parser Stability
AST Method Binding & Entry Points
Resolved Parser method arguments across expression nodes, strengthened natural English assignment parsing, and configured global CLI entry points.
Completed
v0.4.2 — Final Release (Archived) 📦
Disk I/O (`read_file`, `write_file`, `file_exists`) & Built-ins
Final active release. All future maintenance and feature updates are closed.
Archived 🛑
Core Maintainer & Creator
Meet the creator behind Cruise Programming Language and open-source 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 Status
Archived
Language
Cruise (`.cru`)