Complete Technical Reference

Master
Cocotte.

An exhaustive guide to every feature, module, and optimization within the Cocotte ecosystem.

Introduction

Cocotte is a compiled, dynamically-typed language built with Rust. It bridges the gap between the rapid prototyping of scripting languages and the performance profile of native software.

Zero Dependencies

Binaries are statically linked and standalone.

Rust Performance

Engine leverages the safety and speed of Rust.

Multi-Paradigm

Full support for OOP, functional, and procedural code.

Installation

Automated (Recommended)

Shell Install
curl -fsSL https://cocotte-lang.pages.dev/install.sh | bash
sh

Installer Scope

The installer places the cocotte binary in /usr/local/bin and configures executable permissions. You may need sudo if running as a non-root user.

Manual Installation

Download the binary for your platform from the GitHub releases page, rename it to cocotte, make it executable, and move it to a directory in your $PATH.

Manual Setup
chmod +x cocotte
mv cocotte /usr/local/bin/
sh

Environment Variables

Cocotte respects the following environment variables:

VariablePurpose
COCOTTE_PATHCustom directory for looking up .cotmod files.
COCOTTE_DEBUGSet to "true" to force verbose logs on all runs.
COCOTTE_INSTALL_DIRCustom install path for the automated installer.

CLI Reference

cocotte init <name>

Bootstrap a new project with the standard directory structure.

--template <t>: Use a specific boilerplate.
cocotte run [path]

Execute a source file using the tree-walk interpreter. Defaults to src/main.cot.

--release: Run with optimizations.--profile: Generate profile.json.--debug: Enable verbose logging.
cocotte build [path]

AOT compile a project to a native machine binary.

--release: Enable LLVM LTO & symbol stripping.--target <arch>: Cross-compile to specific architecture.--strip: Remove debug symbols.
cocotte test [dir]

Recursive test runner. Executes all *_test.cot files.

--verbose: Show all test results.--filter <pattern>: Run only matching tests.
cocotte exec <task>

Run a custom task defined in the project Charlotfile.

--args <args>: Pass arguments to the task.
cocotte add <module>

Fetch and register a remote or local module into the current project.

--dev: Add as a development dependency.

Project Layout

Cocotte follows a "convention over configuration" approach. A standard project structure ensures compatibility with all CLI tools.

MyProject/
├── Millet.toml # Project configuration & dependencies
├── Charlotfile # Automation scripts & tasks
├── src/
├── main.cot # Application entry point
└── utils.cot # Project modules
├── tests/
└── logic_test.cot # Unit tests
└── modules/ # Downloaded dependencies (Git-ignored)

Syntax: Core

Data Types

Number3.14, 42

64-bit floating point numbers.

String"Hello"

UTF-8 encoded string literals.

Booleantrue, false

Logical values.

Nilnil

The absence of a value.

List[1, 2, 3]

Ordered, dynamic arrays.

Map{"a": 1}

Unordered key-value pairs.

Variables & Scoping

Cocotte uses block-level scoping. Use var for declarations. Re-declaration in the same scope is a compile-time error.

Scoping Rules
var x = 10
{
    var x = 20 # New scope, valid shadowing
    print x    # Prints 20
}
print x        # Prints 10
cocotte

Truthiness

Only false and nil are falsy. Everything else, including 0 and "", is truthy.

Boolean Logic
if 0
    print "Zero is truthy!"
end

if ""
    print "Empty string is truthy!"
end
cocotte

Syntax: Classes & OOP

Cocotte implements a prototype-based class system. The init method serves as the constructor.

Class Inheritance
class Animal
    func init(name)
        self.name = name
    end

    func eat()
        print self.name + " is eating"
    end
end

class Cat < Animal # Inheritance
    func speak()
        print "Meow"
    end
end

var kitty = Cat("Luna")
kitty.eat()
kitty.speak()
cocotte

Error Handling

Cocotte uses a try/catch mechanism for runtime exceptions. You can manually trigger errors using the error keyword.

Exception Safety
try
    var f = open("missing.txt", "r")
catch e
    print "Failed to open file: " + e
end

func validate(n)
    if n < 0
        error "Number must be positive"
    end
end
cocotte

String Methods

.len()number

Returns the number of characters in the string.

"hi".len() # 2
.upper()string

Returns a new string in all uppercase.

"hi".upper() # "HI"
.lower()string

Returns a new string in all lowercase.

"HI".lower() # "hi"
.trim()string

Removes whitespace from both ends.

" x ".trim() # "x"
.split(s)list

Splits the string by a separator into a list.

"a,b".split(",") # ["a", "b"]
.replace(f, t)string

Replaces all instances of 'f' with 't'.

"a-a".replace("-", "+") # "a+a"
.slice(f, t)string

Extracts a substring from index 'f' to 't'.

"abc".slice(0, 2) # "ab"

Global Functions

print(val)nil

Outputs a value to the standard output stream.

print "Hello World"
input(prompt)string

Reads a line of text from standard input.

var name = input("> ")
range(s, e)list

Returns an iterable list of numbers from s to e.

for i in range(1, 5)
type(val)string

Returns a string representing the type of the value.

type(42) # "number"
clock()number

Returns the current system time in seconds since epoch.

var t = clock()
len(val)number

Returns the length of a string, list, or map.

len([1, 2]) # 2

List Methods

.push(v)nil

Appends a value to the end of the list.

l.push(10)
.pop()any

Removes and returns the last element.

l.pop()
.join(s)string

Joins elements into a string using a separator.

[1, 2].join("-") # "1-2"
.map(f)list

Creates a new list by applying 'f' to each element.

l.map(func(x) return x*2 end)
.filter(f)list

Creates a new list with elements that pass 'f'.

l.filter(func(x) return x > 0 end)
.sort()nil

Sorts the list in-place (if elements are comparable).

l.sort()

Map Methods

.get(k)any

Returns the value associated with key 'k'.

m.get("id")
.set(k, v)nil

Sets or updates the value for key 'k'.

m.set("id", 1)
.keys()list

Returns a list of all keys in the map.

m.keys()
.values()list

Returns a list of all values in the map.

m.values()
.remove(k)nil

Deletes the key-value pair for 'k'.

m.remove("id")
.clear()nil

Removes all entries from the map.

m.clear()

File I/O

Cocotte provides high-level primitives for interacting with the file system. These operations are synchronous and optimized for developer productivity.

System I/O
# Reading a file
var content = read_file("config.json")

# Writing a file
write_file("logs.txt", "Execution started
")

# Path manipulation
var exists = file_exists("data.db")
if exists
    delete_file("data.db")
end
cocotte

SQLite Integration

Embedded database support for persistent data storage. Uses the standard SQLite engine.

Database Storage
module add "sqlite"

var db = sqlite.open("data.db")

db.execute("CREATE TABLE users (id INT, name TEXT)")
db.execute("INSERT INTO users VALUES (1, 'Alice')")

var rows = db.query("SELECT * FROM users")
for row in rows
    print row.get("name")
end

db.close()
cocotte

JSON Handling

Bidirectional conversion between Cocotte data structures and JSON strings.

Data Serialization
module add "json"

var raw = '{"name": "Cocotte", "version": 1.0}'
var data = json.parse(raw)
print data.get("name")

var encoded = json.stringify({"id": 42})
print encoded
cocotte

Mathematics

math.PInumber

The ratio of a circle's circumference to its diameter.

print math.PI
math.sin(x)number

Returns the sine of 'x' (in radians).

math.sin(math.PI / 2)
math.cos(x)number

Returns the cosine of 'x' (in radians).

math.cos(0)
math.sqrt(x)number

Returns the square root of 'x'.

math.sqrt(16) # 4
math.pow(b, e)number

Returns 'b' to the power of 'e'.

math.pow(2, 3) # 8
math.random()number

Returns a pseudo-random number between 0 and 1.

math.random()

HTTP Client & Server

HTTP Client

Highly optimized networking backed by Rust's reqwest. Bundled with native TLS.

Network Client
module add "http"

# GET Request
var data = http.get("https://api.github.com/zen")
print data

# POST with JSON
var user = {"name": "Cocotte"}
var resp = http.post_json("https://httpbin.org/post", user)
cocotte

HTTP Server

Built-in synchronous TCP server. Extremely lightweight for internal APIs or local tools.

Network Server
module add "http"

http.serve(3000, func(req)
    var method = req.get("method")
    var path = req.get("path")
    
    print "Log: " + method + " " + path
    
    return {
        "status": 200,
        "body": "Hello from Cocotte Server!",
        "headers": {"Content-Type": "text/plain"}
    }
end)
cocotte

GUI: Charlotte

Charlotte is an immediate-mode GUI toolkit powered by egui. It renders hardware-accelerated interfaces with minimal overhead.

GUI Application
module add "charlotte"

var state = {"clicks": 0}

charlotte.window("App", 400, 300, func(ui)
    ui.heading("Click Counter")
    ui.label("Current count: " + state.get("clicks"))
    
    if ui.button("Add +1")
        state.set("clicks", state.get("clicks") + 1)
    end
end)
cocotte

Cross-Platform GUI

Charlotte applications are fully cross-platform and compile to native binaries with no external runtime dependencies.

Testing & Debugging

Built-in Assertions

Use the global assertion suite for robust unit testing.

Unit Testing
# my_test.cot
func add(a, b) return a + b end

assert_eq(add(1, 1), 2)
assert_ne(add(1, 1), 3)
assert(true) # General boolean check
cocotte

Debugging Hooks

The debug_inspect(val) function provides a deep print of any data structure, including class instances.

Inspection
var complex = {"a": [1, 2], "b": {"c": true}}
debug_inspect(complex)
cocotte

Automation: Charlotfile

The Charlotfile allows you to define project-specific tasks and automation scripts using Cocotte syntax. Run tasks with cocotte exec <task>.

Build Automation
# Charlotfile
task "build"
    exec "cocotte build --release"
end

task "clean"
    delete_file("bin/main")
end
cocotte

Config: Millet.toml

The project manifest file defines metadata, dependencies, and compilation targets. It's the central configuration for your Cocotte project.

Project Manifest
[project]
name = "MyProject"
version = "0.1.0"
authors = ["You"]

[dependencies]
http = "latest"
json = "local:./lib/json"

[build]
entry = "src/main.cot"
target = "native"
toml

Cross-Compilation

Cocotte leverages LLVM to enable seamless cross-compilation from a single host machine to various targets, making it easy to distribute your application.

Universal Compilation
# Compile for Windows from Linux
cocotte build --target x86_64-pc-windows-msvc

# Compile for ARM64 Linux
cocotte build --target aarch64-unknown-linux-gnu
sh

Deployment Guide

Since Cocotte compiles to a static, standalone binary with zero dependencies, deployment is as simple as copying the file to your server or packaging it in a minimal Docker container.

Docker (Minimal)
FROM scratch
COPY bin/app /app
ENTRYPOINT ["/app"]
dockerfile

Performance & Profiling

Release Builds

Always use the --release flag for production. This enables LLVM LTO, symbol stripping, and maximum optimizations.

cocotte build --release

Profiling

Run with --profile to generate a profile.json file compatible with Chrome's tracing tool.

cocotte run --profile main.cot

Master the
Complete Language.

Cocotte is built by the community for the community. Contributions are always welcome.

© 2026 Technologies Budgie — Quebec, Canada