A blazing-fast, security-focused programming language with a powerful CLI, built from scratch in Go.
Sentra combines the simplicity of Python, the performance of Go, and security features built right into the core. Perfect for security automation, system scripting, and rapid application development.
📚 Full Documentation | 🚀 Quick Start | 📖 Tutorial | 🔧 API Reference
git clone https://github.com/sentra-language/sentra.gitcd sentra && ./install.shsentra binary run:
go build -o sentra ./cmd/sentra
sentra init my-awesome-appcd my-awesome-appsentra run main.snsentra test- Optimized VM: Stack-based architecture with pre-allocated memory
- Fast execution: 14-40 microseconds per operation
- Constant caching: Pre-converted constants for faster access
- Thread-safe collections: Concurrent-safe arrays and maps
- Memory efficient: ~26KB per operation with minimal allocations
- Dynamic typing with runtime type checking
- First-class functions with closures and lambdas
- Arrays and Maps with built-in operations
- Pattern matching for elegant control flow
- Module system with import/export
- Error handling with try-catch-finally
- Iterators for collections
- String interpolation and manipulation
- Logical operators (&&, ||, !)
141+ built-in functions across multiple modules:
- Math: Trigonometry, random numbers, mathematical constants
- String: Manipulation, splitting, joining, pattern matching
- Array: Sorting, filtering, mapping, reduction
- IO: File operations, directory management
- JSON: Encoding and decoding
- Time: Date/time operations
- Regex: Pattern matching
- Security: Cryptography, hashing, threat detection
- Database: Full SQL database support (SQLite, PostgreSQL, MySQL)
- Data Science: NumPy/Pandas-like operations (27 functions)
- Network Infrastructure: Firewall, proxy, IDS, monitoring (44 functions)
- Firewall management (8 functions)
- HTTP/HTTPS proxy (6 functions)
- Reverse proxy with load balancing (5 functions)
- Intrusion Detection System (7 functions)
- Network monitoring (8 functions)
- Packet capture (5 functions)
- Port scanning and discovery (5 functions)
Native database bindings with SQL injection protection:
- SQLite: Pure Go implementation (no CGO required)
- PostgreSQL: Full support with advanced features
- MySQL: Complete MySQL/MariaDB compatibility
- Features:
- Connection pooling
- Prepared statements
- Transaction support
- Parameter binding (SQL injection safe)
- Type conversion between Sentra and SQL types
// Connect to SQLite database
sql_connect("mydb", "sqlite", "data.db")
// Execute queries with parameter binding
sql_execute("mydb", "INSERT INTO users (name, age) VALUES (?, ?)", "Alice", 30)
// Query data
let users = sql_query("mydb", "SELECT * FROM users WHERE age > ?", 25)
for user in users {
log(user["name"] + ": " + str(user["age"]))
}
sql_close("mydb")
- TCP/UDP Sockets: Full client/server implementation
- HTTP Client: GET, POST, PUT, DELETE, custom requests
- HTTP Server: Routing, middleware, static files
- WebSockets: Client and server with full duplex communication
- Firewall Management: Create rules, block/allow IPs, traffic statistics
- HTTP/HTTPS Proxy: Forward proxy with filtering, caching, and logging
- Reverse Proxy: Load balancing (round-robin, least connections)
- Intrusion Detection System (IDS): Threat detection with automated responses
- Network Monitoring: Real-time bandwidth, protocol analysis, flow tracking
- Packet Capture: pcap-style packet capture and analysis
- Port Scanning: Network discovery, service identification, vulnerability scanning
- DNS Operations: All record types (A, AAAA, MX, TXT, NS, CNAME)
Hillock is a high-performance web framework for Sentra, built on Phase 3 Network Infrastructure:
import "hillock_v2.sn" as hillock
hillock.hillock_init()
// Middleware
hillock.hillock_use(hillock.middleware_logger())
hillock.hillock_use(hillock.middleware_cors())
// Routes
hillock.hillock_get("/", fn(req, res) {
res.body = "<h1>Hello, Hillock!</h1>"
})
hillock.hillock_get("/api/users/:id", fn(req, res) {
res.headers["Content-Type"] = "application/json"
res.body = json_encode({"id": req.params.id})
})
hillock.hillock_listen(8080)
Features:
- Express.js-inspired API
- Real TCP server implementation
- Pattern-based routing with parameters
- Middleware chain system
- Built-in network monitoring
- JSON support out of the box
The Sentra CLI is your primary interface for developing, testing, and deploying Sentra applications. It's designed to make your development workflow smooth and enjoyable.
log("Hello, World!")
// Variables
let name = "Sentra"
let version = 1.0
// Functions
fn greet(name) {
return "Hello, " + name + "!"
}
log(greet("World"))
// Arrow functions
let square = fn(x) => x * x
log(square(5)) // 25
// Arrays
let numbers = [1, 2, 3, 4, 5]
let doubled = numbers.map(fn(x) => x * 2)
// Maps
let person = {
"name": "Alice",
"age": 30,
"city": "New York"
}
log(person["name"]) // Alice
// If-else
if age >= 18 {
log("Adult")
} else {
log("Minor")
}
// Loops
for i in [1, 2, 3] {
log(i)
}
while count < 10 {
count = count + 1
}
// Pattern matching
match value {
1 => log("One"),
2 => log("Two"),
_ => log("Other")
}
try {
let result = riskyOperation()
log(result)
} catch error {
log("Error: " + error)
} finally {
cleanup()
}
// HTTP Server with routing
let server = http_server_create("0.0.0.0", 8080)
http_server_route(server["id"], "GET", "/api/status", fn(req) {
return http_response(200, "{\"status\":\"running\"}", {
"Content-Type": "application/json"
})
})
http_server_start(server["id"])
// WebSocket Server
let ws = ws_listen("127.0.0.1", 8765)
let client = ws_server_accept(ws["id"], 5)
ws_server_broadcast(ws["id"], "Welcome everyone!")
// Security scanning
let results = port_scan("192.168.1.1", 1, 1000, "TCP")
let hosts = network_scan("192.168.1.0/24")
// Import built-in modules
import math
import string
import json
// Import with alias
import "http" as web
// Use module functions
let sqrt = math.sqrt(16)
let upper = string.upper("hello")
let data = json.encode({"key": "value"})
- Numbers:
42,3.14 - Strings:
"Hello",'World' - Booleans:
true,false - Null:
null - Arrays:
[1, 2, 3] - Maps:
{"key": "value"} - Functions:
fn(x) => x * 2
- Arithmetic:
+,-,*,/,% - Comparison:
==,!=,<,>,<=,>= - Logical:
&&,||,! - Assignment:
=
let,var,const- Variable declarationsfn- Function declarationif,else- Conditional statementswhile,for- Loopsmatch- Pattern matchingtry,catch,finally,throw- Error handlingimport,export- Module systemreturn- Function returntrue,false,null- Literals
import math
math.PI // 3.14159...
math.E // 2.71828...
math.abs(-5) // 5
math.sqrt(16) // 4
math.pow(2, 8) // 256
math.sin(math.PI) // 0
math.random() // Random [0, 1)
import string
string.upper("hello") // "HELLO"
string.lower("WORLD") // "world"
string.split("a,b,c", ",") // ["a", "b", "c"]
string.join(["a", "b"], "-") // "a-b"
string.contains("hello", "ll") // true
import array
array.push(arr, item)
array.pop(arr)
array.sort(arr)
array.reverse(arr)
array.map(arr, fn)
array.filter(arr, fn)
import io
io.readfile("file.txt")
io.writefile("file.txt", content)
io.exists("file.txt")
io.listdir(".")
io.mkdir("newdir")
import json
let obj = {"name": "John", "age": 30}
let str = json.encode(obj)
let parsed = json.decode(str)
| Operation | Time | Memory | Allocations |
|---|---|---|---|
| Arithmetic | ~37μs | 26KB | 13 |
| Array Creation | ~14μs | 26KB | 13 |
| Map Operations | ~41μs | 26KB | 22 |
Sentra uses a four-stage compilation pipeline:
- Lexer: Tokenizes source code
- Parser: Generates Abstract Syntax Tree (AST)
- Compiler: Transforms AST to bytecode
- VM: Executes bytecode on stack-based virtual machine
- Stack-based architecture
- 70+ opcodes for all operations
- Call frames for function invocation
- Global and local variable scoping
- Closure support with upvalues
- Thread-safe operations
See the examples/ directory for more complex programs:
arrays_and_maps.sn- Collection operationsadvanced_functions.sn- Closures and higher-order functionscontrol_flow.sn- Conditionals and loopsdatabase/simple_blog.sn- Blog system with SQLitedatabase/sqlite_example.sn- SQLite operations demomodules_example.sn- Module system usageerror_handling.sn- Exception handlingalgorithms.sn- Classic algorithms
We love contributions! Here's how to get started:
- Fork & Clone: Fork the repo and clone locally
- Branch: Create a feature branch (
git checkout -b feature/amazing) - Code: Make your changes
- Test: Add tests and ensure all pass
- Commit: Commit with clear message
- Push: Push to your fork
- PR: Open a Pull Request
For Language Developers:
./dev.sh status./dev.sh enable./dev.sh build./dev.sh install./dev.sh test./dev.sh disableReady to code with confidence? Get started with sentra init my-app today! 🚀