The vision for this AI-first language is to be fast and deterministic, with first-class citizens such as:
- tensors
- shapes
- gradients
- kernels
Velocity files have a .vl extension.
We're in extremely early development, and the Velocity language is not usable. You're welcome to clone the repo, tweak the main.vl file, and execute cargo run to see some internals.
You can assign numbers, strings, and booleans to identifiers.
let: define an immutable value. e.g.let base = 10mutmodifier: define a mutable value. e.g.let mut x = 0
You can add, subtract, multiply, and divide numbers.
You can print values or expressions.
print("Hello Velocity!")print(x + 3)
We support both single and multi line.
// begin cool code
print("Hello Velocity!") // just wanted to say hi
/*
nothing lasts forever
you knew that, right?
*/
Supported types are:
- i8, i16, i32, i64
- u8, u16, u32, u64
- f32, f64
- string
- bool
- [] (array)
- () (tuple)
let x: i8 = 3
Type declaration is not required; we infer the type when needed. The default numeric type is i64
if is an expression, so it can evaluate to a value or just be used for side effects.
let a = if true { 100 } else { 50 }
if true { print("is true") } else { print("is false") }
Arrays must have all items be of the same type.
Strict immutability is enforced for arrays. Meaning that if you want to add, change, or remove items, you need to declare with mut.
let sizes: i64[] = [0, 7, 12]
// Types are inferred if omitted
// Here, we're inferring an array of `string`s
let groups = ["beginner", "intermediate", "advanced"]
To create a fixed-size array, declare the number of items it will hold, surrounded by brackets, with the type declaration.
let things: string[3] = ["hat", "gloves", "coat"]
// As with dynamic arrays, type is inferred if omitted
// Here, we're declaring it's an array of 4 items, and we infer `i64` for the items
let stuff: [4] = [1, 2, 3, 4]
Tuples can have mixed-type collections. Note that, for this reason, you don't define a type for tuple items.
Strict immutability is enforced for tuples. Meaning that if you want to add, change, or remove items, you need to declare with mut.
let data = (1, "three", false)
To create a fixed-size tuple, declare the number of items it will hold, surrounded by parenthesis.
let things: (3) = ("hat", "gloves", "coat")