A modern, high-performance language designed for building everything from system utilities to web applications.
K3 combines the best aspects of modern programming languages with innovative features for maximum productivity and performance.
K3 delivers near-native performance with advanced optimizations and a zero-cost abstraction model.
Enjoy memory safety without garbage collection through K3's innovative ownership system.
Write safe concurrent code with K3's lightweight tasks and message-passing channels.
Expressive static typing with type inference, generics, and pattern matching.
Easily share and reuse code with K3's integrated package manager and dependency resolver.
First-class tooling with integrated formatter, linter, and documentation generator.
Clean, expressive syntax that makes complex tasks simple.
// A simple K3 program
fn main() {
println("Hello, K3 World!");
// Variables and type inference
let name = "K3";
let version = 1.0;
println("Welcome to {} version {}", name, version);
// Optional type annotations
let is_awesome: bool = true;
if is_awesome {
println("K3 is awesome!");
}
}
import net.http
import net.http.router
// A simple HTTP server in K3
fn main() {
// Create a new router
let router = router.new();
// Define routes
router.get("/", handle_home);
router.get("/api/users", handle_users);
router.post("/api/users", create_user);
// Start the server
let server = http.server(router);
println("Server listening on http://localhost:8080");
server.listen(8080);
}
// Route handlers
fn handle_home(req: http.Request, res: http.Response) {
res.html("<h1>Welcome to K3 Web Server</h1>");
}
fn handle_users(req: http.Request, res: http.Response) {
let users = [
{id: 1, name: "Alice"},
{id: 2, name: "Bob"},
{id: 3, name: "Charlie"}
];
res.json(users);
}
fn create_user(req: http.Request, res: http.Response) {
// Parse JSON body
let user = req.json();
// In a real app, you would save to a database
println("Created user: {}", user.name);
res.status(201).json({
success: true,
message: "User created"
});
}
import async
import time
// Concurrent programming in K3
fn main() {
println("Starting concurrent tasks...");
// Create a channel for communication
let (sender, receiver) = async.channel();
// Spawn a task that sends values
async.spawn(|| {
for i in 1..5 {
println("Sending: {}", i);
sender.send(i);
time.sleep(1000); // Sleep for 1 second
}
// Close the channel when done
sender.close();
});
// Spawn another task that processes values
let handle = async.spawn(|| {
// Receive values until the channel is closed
while let Some(value) = receiver.receive() {
println("Received: {}", value);
// Do some processing
let result = value * 2;
println("Processed: {}", result);
}
println("Channel closed, processing complete");
});
// Wait for the processing task to complete
handle.join();
println("All tasks completed");
}
import stellar
// A simple counter app using Stellar UI
fn main() {
// Create a new Stellar app
let app = stellar.app("Counter App");
// Define the app state
let state = {
count: 0
};
// Define the UI
app.view(|state| {
stellar.container([
stellar.h1("Counter: {}", state.count),
stellar.row([
stellar.button("Decrement")
.onClick(|state| { state.count -= 1 }),
stellar.button("Reset")
.onClick(|state| { state.count = 0 })
.style("margin", "0 10px"),
stellar.button("Increment")
.onClick(|state| { state.count += 1 })
.primary()
])
.spacing(10)
.padding(20)
])
.center()
.padding(40)
});
// Run the app
app.run();
}
K3 delivers exceptional performance across a wide range of workloads.
Build beautiful, responsive, and high-performance user interfaces with K3's integrated UI framework.
Stellar UI renders at 60+ FPS even on complex interfaces with thousands of elements.
Automatically adapts to any screen size with built-in responsive layouts.
Over 50 pre-built components with customizable themes and animations.
Intuitive, declarative API that makes UI development a breeze.
Explore fun ASCII games and demos built with K3. These games showcase the power and expressiveness of the language.
Get started with K3 today. Available for Windows, macOS, and Linux.