Write less.
Run fast.
comet is a small programming language that reads like Python and compiles to native code through C++.
No semicolons, no type words for numbers, clear error messages. Files end in .cmt.
use basic
struct Player {
string name = "guest"
score = 0
fun hit() {
score += 10
}
}
fun main() {
p = Player("dan")
for (i in 0 to 3) {
p.hit()
}
printl("{p.name} has {p.score} points")
nums = [3, 1, 2]
nums.sort()
printl(nums, nums.sum())
}
dan has 30 points [1, 2, 3] 6
Why comet
Nothing to declare
x = 5 is a number, done. Only text and true/false get a word: string and bool.
Compiled, not interpreted
Your program becomes C++ and then a real executable, built with g++ -O3 and tuned for your CPU. Counters and indexes compile to 64-bit integers, like in C.
Errors that make sense
"'s' is a string, cannot store a number in it" with the line and a caret, not a wall of C++.
Lists, maps, structs
Built in, with the methods you expect: add, sort, join, keys, has…
Strings that work
Put values straight into text with "{name} is {age}", join with +, split, trim, pad.
Windows and Linux
One comet command runs or builds a program. The Windows package brings its own compiler.
Sixty seconds of comet
Variables and text
x = 5
y = 3.5
string name = "comet"
bool ready = true
printl("x is", x, "and y is", y)
printl("hello {name}, {x + y}")
Conditions and loops
if (x > 3 and ready) {
printl("big")
} else {
printl("small")
}
for (i in 0 to 10) { printl(i) }
while (x > 0) { x -= 1 }
Functions
fun add(a, b) {
return a + b
}
fun main() {
printl(add(2, 3))
answer = input("name? ")
printl("hi " + answer)
}
Lists and maps
nums = [3, 1, 2]
nums.add(9)
printl(nums[0], nums.len(), 2 in nums)
ages = {"dan": 17, "bob": 20}
ages["eve"] = 30
for (name in ages) {
printl(name, ages[name])
}
Get going in three steps
1. Get the compiler
Grab the Windows or Linux build, or skip this and use the playground.
2. Write hello.cmt
fun main() { printl("hello") } — every program starts at main.
3. Run it
comet hello.cmt compiles and runs it. comet compile hello.cmt makes hello.exe you can share, and comet make hello.cmt makes it and runs it.