Cone Language Reference

Hello, Cone

On this page

Every new language begins by saying hello. Here is Cone's: a few lines you can read at a glance.

// A program is a module, and this line names it
mod hello;

// stdio is the standard library's terminal input and output:
// it gives us print, which writes to the terminal
import stdio use *;

// A program begins by running its main function
fn main() {
  // The arrow, <-, is the send operator: it sends the text to print
  print <- "Hello, Cone!\n";
}

It prints:

Hello, Cone!

Try this: change the greeting, or add a second print line, and run it again.

The send operator#

The arrow <- is Cone's send operator. It sends the value on its right to whatever is on its left: here, a string to print, which writes it out. \n ends the line. Sending is useful in a variety of situations, so you will see the arrow many times.

Running it#

Save the program as hello.cone and run it with Cone's build tool, Congo:

congo run hello.cone

Congo compiles the program, links it, and runs it. Or paste it into the playground, which runs it in your browser with nothing installed. A program that grows beyond one file becomes a package, and the last page of the Guide, Growing a program with Congo, shows how to make one, build it and test it.

That's a Cone program, written and run. Next, we give values names and compute with them, the way an ancient Greek once measured the whole Earth.