Documentation

A quick tour of Neo.

Start with the bracket model, then follow the same rules through vectors, uncertainty, programs, native compilation, and the Neo interpreter.

01

Three bracket types

Neo makes the difference between typed data, mixed data, and executable code visible.

[ ]Homogeneous dataTyped vectors and matrices.
( )Heterogeneous dataDictionaries, mixed values, and stored code.
{ }ExecutionCalls, functions, control flow, and blocks.
neo
[1 2 3 4]                    ; homogeneous data

(name:"Neo" version:3)       ; dictionary data

{+ 1 2}                       ; executable call
02

The same function works on scalars and vectors

Define the operation once. A scalar call returns a scalar. A vector call lifts the same function across the data.

neo
{def square (x)
  {* x x}}

{square 5}
{square [1 2 3 4]}

{+ [1 2 3] 10}
output25 [1 4 9 16] [11 12 13]
Ordinary vector work needs no second API.

Arithmetic, comparisons, functions, and control flow participate in the same model.

03

Unknown and error are ordinary values

? represents unknown or missing data. ! represents a runtime error value. Both can appear inside normal vectors.

neo
{var readings [21.4 ? 22.8 23.1]}

{missing? ?}
{missing? 42}
{mean readings}
outputT F 22.4333333333

Statistics such as mean, variance, sd, min, and max operate on known entries.

04

Three-way control flow

A Neo condition may be true, false, or unknown. A vector condition selects a branch for each element.

neo
{if [T F ?]
  [10 20 30]
  [1 2 3]
  [100 200 300]}
output[10 2 300]
05

Element-wise or Cartesian

Normal vector operations are element-wise. The @ spread operator requests every combination.

neo
{+ [1 2 3] [10 20 30]}
; [11 22 33]

{+ @[1 2] @[10 20 30]}
; [[11 21 31] [12 22 32]]
06

Strings use vector-style operations

Concatenation, push, and pop work on strings. Compiled programs can read user arguments with args.

neo
{& "Neo" " language"}
{push "Ne" "o"}
{pop "Neo"}

{print {args}}
output"Neo language" "Neo" "Ne"
PowerShell
neo show-args.neo -o show-args.exe
.\show-args.exe alpha beta
output("alpha" "beta")
07

Code can remain data

Store executable vectors inside (), transform the data, and cross into execution explicitly with {run}.

neo
{var pipeline
  ({print "read"}
   {print "transform"}
   {print "write"})}

{run pipeline}

{set pipeline
  {& pipeline ({print "complete"})}}
08

Numerical computing is built in

Statisticsmean variance sd min max
Matricesmatmul transpose outer identity trace
AIrelu sigmoid softmax mse cross-entropy
Complexcomplex re im conj abs arg
Quaternionsquat-normalize quat-inv quat-rotate
Datafilter reduce sort find JSON dictionaries
neo
{var z (3 4i)}
{abs z}

{* 2 1i}
{/ 2i 2}

{def layer (input weights bias)
  {relu {+ {matmul input weights} bias}}}
output5 2i 1i
09

Compile a Neo program

The Windows installer includes Neo, its runtime headers, and examples.

PowerShell
neo --version
neo --doctor
neo hello.neo -o hello.exe
.\hello.exe
outputhello world! from Neo
10

Build and run the interpreter written in Neo

The interpreter source lives at Neo-interpreter-written-in-Neo/src/interpreter.neo. Compile it with the native Neo compiler, then open the REPL.

PowerShell
neo .\Neo-interpreter-written-in-Neo\src\interpreter.neo -o .\Neo-interpreter-written-in-Neo\interpreter.exe

.\Neo-interpreter-written-in-Neo\interpreter.exe
outputNeo REPL. Type :quit to exit. >

Run a file first and the REPL continues with the same persistent environment:

PowerShell
.\Neo-interpreter-written-in-Neo\interpreter.exe .\program.neo
Read about the interpreter →
11

Where to go next