Fix is a programming language with the following features:
- Functional: All functions have no side effect and all values are immutable. This reduces bugs caused by state management failures.
- O(1) update of arrays and structures: Despite the 1st feature, Fix mutates a value if the mutation cannot be observed. For example,
let array1 = array0.set(10, 42);
defines a new arrayarray1
that is almost identical toarray0
but with the 10th element replaced by 42. Ifarray0
will not be referenced later, Fix will update the 10th element ofarray0
and rename it asarray1
. On the other hand, ifarray0
may be used later, Fix createsarray1
by cloningarray0
and setting the 10th element to 42, keeping immutability. - Familier syntax: The syntax of Fix is more similar to languages such as C++ or Rust than to other functional languages such as Haskell. Even if you have never learned a functional language, you will be able to learn Fix quickly.
In another perspective, Fix is a language which uses reference counting to provide garbage collection and interior mutability. To avoid circular reference, all values are semantically immutable and it restricts dynamic recursive definition and forces to use fixed-point combinator instead. To reduce copy cost on "modify" operation of a value, Fix mutates it if the reference counter is one.
You can try Fix in fixlang playground.
(This project is still a WIP and has no practical use yet.)
- Install Rust.
- Install llvm12.0.1. It is recommended to use llvmemv.
- In macOS, llvmenv installs llvm to "~/Library/Application Support/llvmenv/12.0.1", but llvm-sys currently doesn't understand path with a whitespace correctly, so you need to copy/move "12.0.1" directory to another path.
- Set LLVM_SYS_120_PREFIX variable to the directory to which llvm installed.
git clone https://github.com/tttmmmyyyy/fixlang.git && cd fixlang
.cargo install --locked --path .
. Then the compiler commandfix
will be installed to~/.cargo/bin
.
- You can run the source file (with extension ".fix") by
fix run -f {source-files}
. - If you want to build executable binary, run
fix build -f {source-files}.
. - For more details, see
fix help
,fix build --help
orfix run --help
. - Running
fix build
with-g
option generates executable binary with DWARF debugging information. Then you can debug the binary by lldb, gdb or other GUI debuggers such as CodeLLDB.- Note that in VSCode you cannot put a breakpoint in
*.fix
files by default.
- Note that in VSCode you cannot put a breakpoint in
- See document.
- 紹介(日本語):HaskellとRustを足して2で割ったような関数型言語Fixを作っている話