This document is the reference manual and design rationale for the Curv core language, which underlies the shape library.
- Ease of use for artists and novice programmers.
The focus is artistic exploration, not software engineering.
No boilerplate: the simple program
cube
is sufficient to construct a cube. - Expressive power for expert programmers. The shape library is written entirely in Curv. Libraries of new shape operations can be written in Curv and distributed over the internet.
- Rendering speed. Curv programs are compiled into efficient GPU code for fast rendering.
- Interoperability with other programming languages. (Future) Two way data interchange with external programs. The shape library can be embedded in other programming languages (like Javascript and Python).
- Safety and security. A Curv program downloaded from the internet can't encrypt all your files or exfiltrate personal information to a server.
- Simple, Elegant, Powerful
- The Curv language is based on a small number of orthogonal concepts that can be combined together with no arbitrary restrictions. This results in a relatively simple language with a lot of expressive power. The core language is small enough to learn in a day.
- Simple Type System
- Curv is a dynamically typed language with 6 value types: symbols, numbers, characters, lists, records, and functions. Everything else is represented using combinations of these primitives. There are no type names or type declarations.
- Pure Functional Language
Curv is a pure functional language.
- Functions are first class values, meaning that they can be bound to variables, passed as function arguments and returned as function results.
- Functions are pure, meaning that the result returned by a function depends only on the argument value, and not on shared mutable state, which doesn't exist in Curv.
- Data structures are immutable values, not mutable objects.
- Expressions do not have side effects.
- There is no I/O: Curv is not a scripting language. The only outcome of a running a program is to compute a value (which is usually a geometric shape).
- Expression Language
- Curv is an expression language, not a statement language. A program is an expression, not a statement list. The body of a function is an expression, not a statement list.
- Functional Programming
- Higher order functions, curried functions, pattern matching, list/record/string comprehensions, tail call optimization.
- Imperative Programming
- Curv has a small imperative subset: assignment statements, compound statements, if statements, while loops, for loops. This allows algorithms to be coded in an imperative style, but statement semantics are tightly restricted so that the expression language still has pure functional semantics.
- Array Programming
- Curv is an array language. Scalar arithmetic operations are generalized to work on Vectors, Matrices, and higher dimensional arrays. This makes geometric algorithms involving linear algebra easier to code, and these operations take advantage of vector hardware on GPUs for fast rendering.
Introduction: Programs
The six types of Values:
- Symbols -- which include Boolean Values
- Numbers -- and Trigonometry
- Characters
- Lists -- which include Strings, Complex Numbers, Vectors, Matrices and Arrays
- Records
- Functions
Basic Syntax:
- Programs
- Expressions
- Definitions (local variables)
- Parametric Shapes
- Statements (imperative style programming)
- Patterns
- File Import
Advanced Topics: