Skip to content

kramermt/val

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Val

Val is an open source, general-purpose programming language designed around on the concept of (mutable) value semantics. The language aims to be safe and efficient, yet expressive enough to support multiple programming paradigms and implement concurrent algorithms safely and efficiently.

Value semantics brings several advantages in terms of software correctness, performance, and maintainability. In particular, it upholds local reasoning, allowing programmers (and compilers) to safely focus on confined sections of the program, without worrying about unintended side effects in unrelated components (a.k.a. spooky actions at a distance).

Val is heavily inspired by (and implemented in) Swift and adopts many of its features, including higher-order functions, mutating methods, and relatively powerful support for generic programming (a.k.a. parametric polymorphism).

(Mutable) Value Semantics

A type has value semantics if the value of a variable of this type can only be changed through operations on that variable. A type has mutable value semantics if it supports part-wise, in-place mutation.

// Declares a generic 'Pair' type.
type Pair<T, U> { var fst: T; var snd: U }

// Creates two pairs.
var foo = Pair(fst: 4, snd: 2)
var bar = foo

// Mutates the second pair in-place (i.e., without new allocations).
bar.fst = 8

// Prints 4, not 8, because 'foo' and 'bar' are two independent values.
print(bar.fst)

Documentation

The language guide gives a tour of Val's most salient features, in a progressive fashion. A more formal and authoritative documentation is on the way.

Build Val

Val is distributed in the form of a Swift package, which can be built with [Swift Package Manager](swift package manager).

Clone this repository and simply run swift build -c release to build the project. This command will create an executable .build/release/val. You can run that command with the flag --help to get a summary of its options.

Run the Tests

The test suite expects to get the location of the standard library files in the environment variable VAL_HOME. This environment variable should point to the root of this repository. Then, you can run swift test to execute all tests.

Most of the tests are run on actual Val programs. Those are located in the directory Tests/ValTests/TestCases. Each file is a single program, annotated with comments that instruct the test runner of the expected results.

Releases

No releases published

Packages

No packages published

Languages

  • Swift 99.8%
  • Other 0.2%