Fast
Track.
A comprehensive introduction for those who want to start building, not just reading.
Core Philosophy
Cocotte is designed to be intuitive. It removes the boilerplate associated with low-level languages while retaining their efficiency. In this guide, we will cover everything required to build your first standalone application.
No Experience Required
Environment Setup
Cocotte is a single binary. To install it on a Unix-like system, execute the following command:
curl -fsSL https://cocotte-lang.pages.dev/install.sh | bashWindows Users
Data Storage
In programming, we use **Variables** to store information. Think of them as named slots in the computer's memory.
# Use 'var' to declare a new variable
var username = "Alex"
var score = 100
var isActive = true
# Use 'print' to display data
print "Player: " + username
print "Current Score: " + scoreControl Logic
Logic allows your program to make decisions. We use the if keyword to check conditions.
var health = 20
if health > 50
print "You are in good shape!"
elif health > 0
print "Warning: Low health."
else
print "Game Over."
endIteration
Loops allow you to repeat a block of code multiple times. This is essential for processing lists of data.
# A simple range loop
for i in range(1, 6)
print "Cycle: " + i
end
# Iterating over a list
var inventory = ["Sword", "Shield", "Potion"]
for item in inventory
print "Item: " + item
endAbstractions
Functions (declared with func) allow you to group code into reusable blocks.
func calculate_damage(base, multiplier)
return base * multiplier
end
var finalDamage = calculate_damage(10, 2.5)
print "Total Damage: " + finalDamageObject Orientation
Classes are blueprints for creating complex data structures that bundle both data and functionality.
class Character
func init(name, role)
self.name = name
self.role = role
end
func introduce()
print "I am " + self.name + ", the " + self.role
end
end
var p1 = Character("Eldrin", "Mage")
p1.introduce()Validation Project
Building a Guessing Game
This project combines everything we've learned into a functional CLI game.
module add "math"
var secret = floor(random() * 10) + 1
var guess = 0
print "--- Cocotte Guessing Game ---"
while guess != secret
guess = input("Enter your guess (1-10): ")
guess = abs(guess) # Convert string to number
if guess < secret
print "Higher..."
elif guess > secret
print "Lower..."
else
print "Correct! The number was " + secret
end
endYou've Completed the Fast-Track!
You now have a solid understanding of Cocotte's core mechanics. Where will you go from here?