FORGE Language v0.4.0
π§ The AI-Native Systems Language β The only compiled language where ai_ask() is a builtin.
FORGE v0.4.0 introduces the world's first AI standard library in a compiled systems language β alongside string stdlib, math stdlib, env vars, project scaffolding, and 5 platform targets. Write sequential code β the compiler automatically parallelizes it with @parallel, offloads to GPU with @gpu, and compiles to native binaries with zero garbage collection overhead.
ai_ask, ai_classify, ai_generate, ai_sentiment, ai_translate, ai_summarize), string stdlib (6 functions), math stdlib (8 functions), env vars, forge new scaffolding, 5 platforms, 26 gallery examples, VS Code extension with 31 snippets. See benchmarks βInstallation
# Download FORGE compiler (Linux x86_64)
curl -fsSL https://forgelang.dev/install.sh | sh
# Verify installation
forge version
# FORGE v0.4.0
FORGE requires no runtime dependencies. The binary includes the compiler, linker integration, AI runtime, and standard library.
Hello, FORGE
// hello.forge
fn main() -> void {
print("Hello, FORGE!")
}
forge run hello.forge
# Hello, FORGE!
Scaffolding: forge new
Create a new FORGE project with a single command:
forge new my_project
# Created: my_project/
# my_project/main.forge
# my_project/forge.toml
cd my_project && forge run main.forge
Build & Run
| Command | Description |
|---|---|
| forge run <file> | Build and execute in one step |
| forge build <file> | Compile to native binary |
| forge check <file> | Type-check without emitting code |
AI Stdlib v0.4.0 β New!
FORGE v0.4.0 is the world's first compiled language with AI builtins in the standard library. No SDKs, no bindings, no wrappers β just call ai_ask() directly from your compiled code.
ai_ask
Send a prompt to an AI model and get a text response. Powered by DeepSeek API.
fn main() -> void {
// Set your API key (one-time)
ai_set_key("sk-your-api-key")
// Ask the AI a question
let answer = ai_ask("What is FORGE?", "")
print(answer)
}
| Signature | Description |
|---|---|
| ai_set_key(str) | Set API key for AI calls |
| ai_ask(prompt, system) | Send prompt + optional system prompt, return response |
ai_classify
Classify text into predefined categories. Returns the category label.
let label = ai_classify(
"I love this product!",
"positive, negative, neutral"
)
// label == "positive"
print(label)
| Signature | Description |
|---|---|
| ai_classify(text, categories) | Classify text into one of the comma-separated categories |
ai_generate
Generate structured output (JSON, code, text) from a description.
let schema = "{\"name\": string, \"age\": int}"
let json = ai_generate("Generate a person named Alice who is 30", schema)
// json == '{"name": "Alice", "age": 30}'
print(json)
ai_sentiment
Analyze the sentiment of text. Returns a score from -1.0 (negative) to 1.0 (positive).
let score = ai_sentiment("This is absolutely amazing!")
// score β 0.95
print(score)
ai_translate
Translate text between languages.
let translated = ai_translate(
"Hello, how are you?",
"Spanish"
)
// translated == "Hola, ΒΏcΓ³mo estΓ‘s?"
print(translated)
ai_summarize
Summarize a long text into a concise version.
let summary = ai_summarize(long_article, "3 sentences")
print(summary)
| Signature | Description |
|---|---|
| ai_summarize(text, length) | Summarize text to specified length |
String Stdlib v0.4.0
Six string utility functions built into the standard library.
str_upper / str_lower
let upper = str_upper("hello") // "HELLO"
let lower = str_lower("WORLD") // "world"
str_trim
let trimmed = str_trim(" hello ") // "hello"
str_replace
let result = str_replace("hello world", "world", "FORGE")
// "hello FORGE"
str_split
let parts = str_split("a,b,c", ",")
// parts = ["a", "b", "c"]
Also available: str_starts_with(s, prefix) and str_ends_with(s, suffix) for prefix/suffix checking.
| Function | Description |
|---|---|
| str_upper(s) | Convert string to uppercase |
| str_lower(s) | Convert string to lowercase |
| str_trim(s) | Remove leading and trailing whitespace |
| str_replace(s, from, to) | Replace all occurrences of substring |
| str_split(s, delimiter) | Split string into array by delimiter |
| str_starts_with(s, prefix) | Check if string starts with prefix |
| str_ends_with(s, suffix) | Check if string ends with suffix |
Math Stdlib v0.4.0
Eight math functions built into the standard library.
math_pow
let result = math_pow(2.0, 10.0) // 1024.0
math_floor / math_ceil
let f = math_floor(3.7) // 3.0
let c = math_ceil(3.2) // 4.0
math_sin / math_cos
let s = math_sin(pi / 2.0) // 1.0
let c = math_cos(pi) // -1.0
math_random
let r = math_random() // Random float in [0.0, 1.0)
| Function | Description |
|---|---|
| math_pow(base, exp) | Raise base to exponent power |
| math_floor(f) | Round down to nearest integer |
| math_ceil(f) | Round up to nearest integer |
| math_sin(f) | Sine (radians) |
| math_cos(f) | Cosine (radians) |
| math_random() | Random float in [0.0, 1.0) |
Environment Variables v0.4.0
Read and write environment variables directly from FORGE code.
// Read an environment variable
let home = env_get("HOME")
print(home)
// Set an environment variable
env_set("MY_VAR", "forge_value")
| Function | Description |
|---|---|
| env_get(name) | Get environment variable value (returns empty string if not set) |
| env_set(name, value) | Set environment variable |
Syntax
Variables
let x: i64 = 42 // immutable
var count: i64 = 0 // mutable
let pi = 3.14159 // type inferred
Control Flow
if x > 0 {
print("positive")
} else {
print("non-positive")
}
for i in 0..10 {
print(i)
}
while count < 100 {
count = count + 1
}
Modules
module main {
fn main() -> void {
print("Hello from a module!")
}
}
@parallel β Auto Parallelism
The @parallel annotation tells the FORGE compiler to distribute a loop or function across all available CPU cores automatically. No threads, no mutexes β just add the annotation.
// Parallel sum of 10 million integers
fn parallel_sum(data: []i64) -> i64 {
var total: i64 = 0
@parallel for i in 0..data.len {
total = total + data[i] // auto-reduced
}
return total
}
@gpu β GPU Offload
// Matrix multiply on GPU
@gpu
fn matmul(A: [][]f32, B: [][]f32) -> [][]f32 {
// Compiler generates CUDA/Metal/Vulkan kernel
// Data transferred automatically
}
Memory Regions
FORGE supports region-based memory management β allocate and free blocks of memory in bulk for zero-overhead allocation patterns.
// Region-based allocation
region frame {
let entities: []Entity = alloc(1000)
// Use entities within this frame...
}
// All memory freed when region exits
HTTP Server Builtins
FORGE includes built-in HTTP server capabilities for creating lightweight web services.
fn main() -> void {
http_serve(":8080", handler)
}
fn handler(req: Request) -> Response {
return Response {
status: 200,
body: "Hello from FORGE!",
headers: { "Content-Type": "text/plain" }
}
}
FORGE HTTP server footprint: just 212 KB β 212Γ leaner than Node.js.
SDL2 / Game Engine Builtins
FORGE ships with built-in SDL2 bindings for 2D games and the game engine stdlib with ECS, physics, audio, and math primitives.
module game {
use engine.ecs
use engine.math
use engine.physics
fn main() -> void {
let world = ecs.World.new()
let entity = world.spawn()
world.attach(entity, math.Vec2 { x: 0.0, y: 0.0 })
}
}
Cross-Compilation Targets
FORGE v0.4.0 supports 5 platform targets:
| Flag | Platform |
|---|---|
| --target native | Current machine (default) |
| --target arm64 | ARM64 (Apple Silicon, Raspberry Pi) |
| --target wasm32 | WebAssembly |
| --target wasm-web | WASM + HTML browser harness |
| --target windows | Windows x86_64 |
| --target android | Android / ARM64 |
| --target macos | macOS x86_64 / ARM64 |
forge build main.forge --target arm64
forge build main.forge --target wasm-web
forge build main.forge --target windows
Gallery Examples
FORGE v0.4.0 ships with 26 gallery examples (up from 18 in v0.3) β covering AI, strings, math, parallel, HTTP, games, and more. Try them in the online IDE β
VS Code Extension
The FORGE VS Code extension v0.4.0 provides 31 snippets for syntax highlighting, code completion, and type hints. Install from Marketplace β