Val is a research programming language to explore the concepts of mutable value semantics and generic programming for high-level systems programming.
This repository contains the sources of the reference implementation of Val. Please visit our website to get more information about the language itself.
This project is written in Swift and distributed in the form of a package, built with Swift Package Manager. You will need Swift 5.7 or higher to build the compiler from sources.
Note to Windows users: although this project is not Unix-specific, Windows support has been put on hold due to the instability of continuous integration (see hylo-lang#252).
You may compile Val's compiler with the following commands:
swift build -c release
That command will create an executable named valc
in .build/release
.
That's Val compiler!
This project is under active development; expect things to break and APIs to change.
The compiler pipeline is organized as below. Incidentally, early stages of this pipeline are more stable than later ones. (Note: completion percentages are very rough estimations.)
- Parsing (100%)
- Type checking (50%)
- IR lowering (30%)
- IR analysis and transformations (30%)
- Machine code generation (20%)
You can select how deep the compiler should go through the pipeline with the following options:
--emit raw-ast
: Only parse the input files and output an untyped AST as a JSON file.--typecheck
: Run the type checker on the input.--emit raw-ir
: Lower the typed AST into Val IR and output the result in a file.--emit ir
: Run mandatory IR passes and output the result in a file.--emit cpp
: Produce a C++ source file.--emit binary
(default): Produce an executable (currently by compiling transpiled C++ files)- Note: by default, C++ files will be compiled with
Clang
. Use--cc {CXX compiler}
to use another compiler. - Note: You can specify parameters for the CXX compiler to use (e.g.,
--cc-flags O3
).- Note: Don't add an extraneous
-
, please useO3
instead of-O3
. - Note to MSVC users: Don't add an extraneous
/
, please useO1
instead of/O1
. - Note: You can also add more than one such option (e.g.,
--cc-flags O1 --cc-flags g
). - Note: Do not use
--cc-flags
to specify output locations; use-o
instead.
- Note: Don't add an extraneous
- Note to MSVC users: be sure to use Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell.
- Note: by default, C++ files will be compiled with
For example, valc --emit raw-ast -o main.json main.val
will parse main.val
, write the untyped AST in main.json
, and exit the pipeline.
A more detailed description of the current implementation status is available on our roadmap page.
Lightning Talk: An Object Model for Safety and Efficiency by Definition - Dave Abrahams CppNorth 22
Keynote: A Future of Value Semantics and Generic Programming Part 1 - Dave Abrahams - CppNow 2022
Value Semantics: Safety, Independence, Projection, & Future of Programming - Dave Abrahams CppCon 22
Val and Mutable Value Semantics - Dimi Racordon
Val: A Safe Language to Interoperate with C++ - Dimi Racordon - CppCon 2022
We welcome contributions to Val. Please read through CONTRIBUTING.md for details on how to get started.
Val is distributed under the terms of the Apache-2.0 license. See LICENSE for details.