Orchestrate logic.
Designed for readability.
Heddle is a hybrid-paradigm language designed to orchestrate logic. By combining functional and imperative paradigms, its simple design makes it easy to read, write, and understand. A language for both Engineer and AI agents.
How Heddle Works
Heddle's syntax is designed to be expressive and concise, separating what to do (functional) from how to do it (imperative). It is based on simple declarations, pipes, reactive pattern matching, PRQL, and row-safe error handling.
import "cmp"
import "io"
flow main {
// Pattern matching based on Go function tags
result = "a" | cmp.compare("b") {
less(val) {
val | io.print()
return val
}
equals(val) {
val | io.print()
return val
}
greater(val) {
val | io.print()
return val
}
}
}
package cmp
import (...)
type ComparTag string
const (
Less ComparTag = "less"
Equals ComparTag = "equals"
Greater ComparTag = "greater"
)
func Compare(x any, y any) (interaction.Match[ComparTag, any], error) {
xf, ok1 := convertToFloat(x)
yf, ok2 := convertToFloat(y)
if ok1 && ok2 {
if xf < yf {
return interaction.Match[ComparTag, any]{Tag: Less, Val: xf}, nil
} else if xf > yf {
return interaction.Match[ComparTag, any]{Tag: Greater, Val: xf}, nil
} else {
return interaction.Match[ComparTag, any]{Tag: Equals, Val: xf}, nil
}
}
xs := fmt.Sprintf("%v", x)
ys := fmt.Sprintf("%v", y)
if xs < ys {
return interaction.Match[ComparTag, any]{Tag: Less, Val: xs}, nil
} else if xs > ys {
return interaction.Match[ComparTag, any]{Tag: Greater, Val: xs}, nil
} else {
return interaction.Match[ComparTag, any]{Tag: Equals, Val: xs}, nil
}
}
import "math"
import "io"
import "net/http"
import "company"
// Define a reactive HTTP server resource
http_server = http.server {
host: "localhost",
port: 8080
}
flow main {
// Bind standard HTTP routing as interactive streams
http_server.get(path: "/process") {
ok(request) {
// Process bodies through declarative pipelines
response_data = request.body
| company.to_upper()
response_data | io.print()
return { status: 200, body: response_data }
}
}
// Linear flow piping
"heddle pipeline" | company.to_upper() | io.print()
24.85 | company.round() | io.print()
}
package company
import (
"strings"
"math"
)
func ToUpper(s string) string {
return strings.ToUpper(s)
}
func Round(val float64) float64 {
return math.Round(val)
}
flow main {
users = [
{ id: 1, name: "Alice", active: true },
{ id: 2, name: "Bob", active: false }
]
purchases = [
{ user_id: 1, item: "Laptop", price: 1200.0 },
{ user_id: 2, item: "Phone", price: 800.0 }
]
// Native PRQL-inspired query syntax executing in-memory over Frame columns
active_purchases = (
from users
filter active == true
join purchases [id == user_id]
select { id, name, item, price }
)
active_purchases | io.print()
}
// 1. Declare an isolated error handler
handler log_error (err) {
err | io.print()
}
flow main {
json_string = "invalid json{"
// 2. Safely capture row-level errors without crashing the flow
user_frame = json_string
| json.unmarshal() ? log_error()
| io.print()
}
Clean by design.
Built for robustness.
Heddle enforces Clean Architecture by design, establishing clear boundaries between core business use cases and technical implementation details, creating a Screaming Architecture centered on business logic.
Logical Orchestration
Simplifies code design by decoupling orchestration flow from imperative execution, making pipeline logic clean and easy to maintain.
Columnar Layouts
Organizes data pipeline values in columnar structures internally. Write imperative code while effortlessly modeling and extending custom types.
In-Memory PRQL
Relational queries (joins, filters, projections) directly on variables. Generate new types on the fly with on-demand columnar joins.
Row-Level Failure Isolation
Redirects errors from individual records to specialized traps, acting like a built-in Dead Letter Queue for lines without stopping pipeline execution.
Compiler & VM Architecture
The Heddle framework is built as a complete compiler and virtual machine execution stack written entirely in Go, adhering to Clean Architecture principles.
GoASTParser Interop
The frontend semantic analyzer parses Go companion sources using standard AST libraries. It maps snake_case Heddle instructions to PascalCase Go targets, resolving types before execution.
Columnar Frame Buffers
Data flows through Heddle in columnar `Frame` segments, wrapping `NestedListContainer` elements. Slices and structs transition smoothly to Go representation without duplicate allocations.
Memory Arenas
VM query processing runs within dedicated memory-isolated arenas. Slices and tables are allocated, utilized, and garbage-collected in bulk to minimize GC pauses.
Stack-Based Virtual Machine
A fast, thread-safe virtual machine interprets linearized IR bytecode. It handles concurrent timer tick sequences, background event loops, and HTTP listeners cleanly.
Complete LSP Integration
An official Language Server Protocol implementation exposes real-time syntax checking, hover signatures, inlay parameter types, and semantic highlights to IDE editors.