The Nile Programming Language

Created on 2020-08-15T00:22:37.752905

Return to the Index

This card pertains to a resource available on the internet.

This card can also be read via Gemini.

Overview

Nile is a language about stream processing.

Nile works with typed stream kernels.

Nile syntax uses unicode to type math symbols directly in to the language.

Gezira: Provides a nearly-complete canvas library which is implemented in 400 lines of Nile.

Typed Stream Kernels

You provide the type of data which enters the stream and the type of data which comes out of the stream.

Then you write the kernel which consumes one and produces the other.

Abstractions

Stream to stream pipelines

Kernels specify their input and output types in their signatures.

Message transmission

Messages "pile up" in the inbox of other stream kernels.

Kernels stall when their input is starved: This means they cannot pull a new item from their mailbox when they need to

Kernels stall when their output is saturated: This means the input on the other side is full.

Self-sends: Kernels can send a message to their own inbox. This is used, for example, when breaking beziers in to smaller segments during line rendering.

Kernel control

Single-threaded runs do a batch of work, cycle between kernels, pushing events incrementally down to the finish.

Multi-threaded runs hand messages between kernels and complete renders in parallel.

Processes

A process is a single instance of a stream kernel.

Each process has its own mailbox.

A process can be moved to different threads.

Vernacular

State: Whether the process is OK, or stalled.

Setup: prepare the kernel for first use.

Tear down: cleans up the kernel when there is no more work to do.

Body: the code run by the stream kernel.

Lock: mutex to protect against modifying processes across threads.

Heap: where variables are kept for a particular kernel

Producer: a process which outputs values.

Consumer: a process which inputs values.

Zip: a stream which merges two typed streams to a new typed stream.

Performance

Spread kernels across multiple CPU threads

SIMD optimize particular stream kernels