CocoaLang

v1.2.5 - Coco Loco

Mila says "I HATE DOING DOCUMENTATION"

A Language as Sweet as
Hot Cocoa

Simple, elegant, and delightful. Cocoa brings warmth to your code with modern features, GUI support, and a syntax that's easy to love.

hello.choco
// Sweet and simple! ☕
fn greet(name) {
    return "Hello, #{name}!";
}

let message = greet("World");
print message;

// Lambdas are smooth
let double = |x| => { return x * 2; };
print double(21);

// Pattern matching like a boss
match day {
    case 1 => { print "Monday"; }
    case 5 => { print "Friday"; }
    default => { print "Weekend!"; }
}

Features That'll Warm Your Heart

Modern Syntax

Clean, expressive syntax with lambdas, pattern matching, and closures

Rich Standard Library

File I/O, string manipulation, math functions, and array operations built-in

GTK4 GUI Support

Build beautiful desktop applications with native GUI bindings

REPL Mode

Interactive shell for rapid prototyping and experimentation

Pattern Matching

Elegant control flow with match/case statements

Easy to Learn

Beginner-friendly with clear error messages and intuitive design

Everything You Need

  • Lambdas & Closures: First-class functions with beautiful syntax
  • Higher-Order Functions: map, filter, reduce built-in
  • Structs: Define custom data types with named fields
  • Error Handling: try/catch blocks for graceful error recovery
  • Bitwise Operations: Full support for bit manipulation

Build Desktop Apps

Cocoa includes GTK4 bindings for creating native desktop applications with ease!

// Build GUIs with ease! 🎨
gui_init("com.myapp.demo");

let window = gui_window("Cocoa App", 400, 300);
let box = gui_box("vertical", 10);
let button = gui_button("Click me!");
let label = gui_label("Hello Cocoa!");

gui_add(window, box);
gui_add(box, label);
gui_add(box, button);

fn on_click() {
    gui_set_text(label, "Button clicked!");
}

gui_on(button, "clicked", "on_click");
gui_show(window);
gui_run();

Compile to Executables

Turn your Cocoa scripts into standalone executables with the built-in compiler:

# Compile your Cocoa app
choco compile myapp.choco

# Specify output name
choco compile myapp.choco -o myprogram

# Compile without GUI support
choco compile myapp.choco --no-gui

Ready to brew some code?

Get started with Cocoa in seconds. Just compile and run!