Skip to main content
In this guide, you will write a C△ program, compile it into a native binary using the hypotenuse command, and run it on your machine. By the end, you will have a working development loop and a clear picture of how a C△ source file is structured. If you have not installed the compiler yet, start with the Installation Guide first.

Write Your First Program

Create a new file called hello.ctri and add the following code.
hello.ctri
Save the file. That is all the source code you need for a complete, runnable C△ program.

Compile and Run

1

Save the file

Make sure the file is saved as hello.ctri in your current working directory. C△ source files always use the .ctri extension.
2

Compile to an executable

Run the following command to compile hello.ctri into a native binary.
The -c flag tells the compiler to invoke GCC after code generation and produce a linked executable. If you omit-c, the compiler prints the intermediate C output to stdout instead of producing a binary. The output binary is named hello in the current directory.
3

Run the executable

Execute the binary directly.
You should see the following output in your terminal.

Understanding the Code

Here is what each part of hello.ctri does.
  • using <plstd>; — imports the C△ standard library. Angle-bracket imports search the system PLIBS/ directory that was set up during installation. You can also import individual symbols with using printd from <plstd>; if you want to keep the namespace minimal.
  • int main() — the program entry point, identical in signature to standard C. The compiler expects main to return an int. A return value of 0 signals success to the operating system.
  • printd@lib("Hello, C△!") — a type-aware print function provided by plstd. printd inspects the type of its argument at compile time and emits the appropriate output routine so that you can pass strings, integers, floats, or other types without format strings.
  • Be aware that the compiler will verify whether a library function has been properly globalized or referenced. Check if you used your ”@” properly.

A More Complete Example

The program below introduces three additional features: the string type, the dynam dynamic array, and the len function.
example.ctri
Compile and run this file the same way as before.
You should see the following output.
A few things to note about this example:
  • string is a first-class C△ type. It holds a heap-allocated character sequence and handles duplication and freeing automatically when you reassign or reuse the variable.
  • dynam int scores declares a dynamic array of integers, initialised with an inline list literal. You can grow it at runtime or pass it to any function that accepts an array.
  • len(scores) returns the number of elements in a dynam array (or the byte length of a string). It is provided by plstd and works across collection types.
  • printfs is a formatted print function that uses {variable} interpolation syntax instead of C-style %d/%s format specifiers.
You can control where the compiler writes the output binary using the -o flag: hypotenuse -c hello.ctri -o build/hello. Pass extra GCC flags with -C, for example hypotenuse -c -C "-O2" hello.ctri to enable optimisations.

Next Steps

Language Guide

Explore the full C△ syntax: control flow, functions, structs, lambdas, inline assembly, and the namespace system.

Standard Library

Browse the plstd modules — printd, printfs, string operations, file I/O, and more.

Keywords Reference

A complete list of every C△ keyword and operator with descriptions and usage examples.

CLI Reference

All hypotenuse command-line flags, from compiling and debugging to installing .plib libraries.