import "zlib.h" reads the header (cc -E + a small C declaration parser), links via pkg-config or link "name", and builds .c/.cpp files next to the program. C structs become Dino structs, pointers become pointer types (nil = NULL), T* parameters take variables or lists. Adds dino header, editor completion/hover for C names, docs chapter 13, a raylib example, and tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.4 KiB
2.4 KiB
Dino: learn the language
Dino is a small, fast, modern language. It looks like Go, runs like C, and has no garbage collector, no pointers, and nothing low-level to write. You write plain code; the compiler works out the memory.
These notes teach it from zero. Read them in order, or jump to the cheatsheet when you just need to look something up.
| # | Note | What you learn |
|---|---|---|
| 1 | First steps | Running a program, print, main |
| 2 | Values and types | var, const, numbers, strings |
| 3 | Control flow | if, for, match |
| 4 | Functions | Parameters, results, closures |
| 5 | Lists and maps | Collections |
| 6 | Structs and enums | Your own types, methods |
| 7 | Errors and nil | error, ?, T? |
| 8 | Memory | Copies, shared, weak |
| 9 | Generics and interfaces | Code that works for many types |
| 10 | Files and the standard library | import, os, math, time |
| 11 | Cheatsheet | Everything on one page |
| 12 | A real program | A calculator, split over five files |
| 13 | C and C++ libraries | import "raylib.h", your own C code |
How to read the examples
Every dino block that has a func main is a complete program you can save and run.
The block right after it (marked text) shows what it prints.
```dino
func main() {
print("hello")
}
```
```text
hello
```
The four ideas behind Dino
- Values.
var b = amakes a real copy. Changebandastays the same. There are no hidden aliases, which makes programs easy to reason about. - The compiler infers. You don't write
mut, lifetimes or&. A method that changes its struct is detected automatically; a parameter that is only read is passed without a copy. - Errors are values. Functions return
(value, error)and you pass problems up with?. Missing values areT?and the compiler makes you check fornil. - Sharing is explicit. When you really want one value with several owners, you
write
shared. Everything else has exactly one owner and is freed at the end of its block.