Language Overview
This page is the map of the language, not the full reference.
If you are new, read it once to understand the shape of cnegative, then move into the smaller tutorial pages.
The basic idea
cnegative is intentionally explicit.
That means:
- types are written out
- conditions must be
bool - functions return explicitly
- public API is marked explicitly
- ownership rules are visible instead of hidden
The goal is not “fewest keystrokes”. The goal is “small rules, easy to reason about”.
Four rules to remember
- Simple statements end with
; - Non-void functions must
return ...; - Conditions must be
bool - Public declarations use
pfn,pstruct, andpconst
cneg
fn:int main() {
let x:int = 7;
if x > 5 {
return x;
}
return 0;
}no implicit truthiness
if x {} is invalid when x is an int. Write if x > 0 {} instead.
Learn the language in this order
- Functions & Variables
- Types & Control Flow
- Structs & Arrays
- Modules & Constants
- Memory & Results
- Strings & Ownership
- Standard Library Overview
That order is intentional. It moves from “ordinary code” into “systems code”.
Current implemented surface
fn,pfn,struct,pstruct,const, andpconstint,u8,bool,str,void,ptr T,result T, andslice Tbyteas a readable alias foru8- source-level
nullfor pointer values if,while,loop, rangefor, narrowifexpressions,defer, andtryzone { ... }plus explicitzalloc Tfor temporary scoped allocations- arrays with constant sizes,
[value; N]repeat literals, slices, structs, indexing, field access, and qualified module access alloc,addr,deref,free,ok,err,print,println,input,str_copy, andstr_concatmainreturningint,u8,result int,result u8, orvoid- raw backtick strings for multiline text without escape processing
- builtin stdlib modules for math, growable bytes/lines/text storage, text-first child-process IPC, strings, parsing, files, IO, low-level terminal control, environment, paths, time, blocking IPv4 TCP/UDP, process helpers, and an experimental Linux-only
std.x11window path
What to ignore on your first pass
You do not need these right away:
- compiler internals
- LLVM backend details
- experimental
std.x11 - blocking networking APIs
Those are real parts of the project, but they are not the beginner path.
What to read next
If you want to start writing code immediately, go to Quick Start.
If you want the language in the clean learning order, continue with Functions & Variables.