LULANG PROGRAMMING LANGUAGE

lulang

A small language for numerical computing.

lulang compiles numerical functions to native code. Programs use value semantics, and floating-point expressions may be reassociated. Compiled functions can be called from C or Python.

Interpreter
reference implementation
JIT + LLVM
native code generation
C · Python
generated interfaces
kernel_saxpy.luBOUNDARY ABI
export fn saxpy(a: f64, x: [f64], inout y: [f64], n: i64) {
  for i in 0..n {
    y[i] = a * x[i] + y[i]
  }
}
libkernel_saxpy.a · .dylib/.so · .h · .json
01 / OVERVIEW

Main properties

lulang is intended for small numerical kernels. Its semantics make common numerical optimizations legal without unsafe compiler flags.

01

Numerical semantics

Floating-point operations may be reassociated. Approximate equality is a language operator.

02

Value semantics

Arrays and records are values. A function cannot retain an alias to its caller's data.

03

C interface

lu build --lib creates a library, a C header, and a machine-readable manifest.

02 / USE FROM AN EXISTING PROGRAM

Compile one function.

A lulang library can be added to an existing C or Python program. The application and its data structures do not need to be rewritten.

  1. 01
    Write a functionUse scalar, array, and record types to express the calculation.
  2. 02
    Compile a librarylu build --lib --shared file.lu creates the native library and interface files.
  3. 03
    Call the functionInclude the generated C header, or load the manifest with pylulang.
03 / ONLINE INTERPRETER

Try lulang

Edit the example and press Run. The interpreter runs locally in this page.

EXAMPLESCore subset interpreter
Runs on this device
main.lu
OUTPUTIDLE
Ready. Choose an example or write a kernel.
04 / IMPLEMENTATIONS
REFERENCECFG interpreter
DEVELOPCranelift JIT
SHIPLLVM AOT
ASCENDSelf-hosted compiler