" Gaya is cool "
|> string.trim(_)
|> _ <> "!"
|> string.split(_, " ")Gaya is a scripting language I made for solving AoC problems in 2023. The name comes from my favourite cat.
I wanted to make something that makes me feel pleasure every time I use it. I hope this way I can give pleasure to you too.
It all started when I was trying out Typst. I was writing a document for a hackathon I was organizing and I wanted to try its scripting capabilities to solve the proposed exercises in the document itself.
I could solve all graph processing problems and at the end I thought: "This is a very simple scripting language, and yet it was enough for solving these problems, surely I can write such a language myself". And here we are now.
-
Blazingly Fast (for a tree-walk interpreter): Gaya implements a number of optimizations that make it go brrr. Some of these optimizations are:
- NaN Boxing
- Uses an efficient hash table for the environment
- Hash keys are precomputed in AST nodes
- Resolving identifiers statically
-
Sequences: You can build data processing or algorithmic pipelines using the functions and data structures from the sequence protocol. The first snippet in this readme is an example of that.
-
Pattern matching: Gaya supports a limited form of pattern matching that is good for most purposes. For example:
let xs = (1, 2, 3) in let (x, y, z) = xs in do assert(x == 1). assert(y == 2). assert(z == 3). end.Visit the documentation to learn more about it.
-
Hack pipes: The language has Hack style pipes, which are pipes in which the result of the first expression can be piped into an arbitrary expression, not just function calls. To learn more, read the documentation.
You need to have a C++ and D compiler (GDC specifically) and CMake. You can install them on Debian with the following command:
sudo apt-get install build-essential cmake gdc
Then, you can clone this repository and build the interpreter:
git clone --recurse-submodules https://github.com/aloussase/gaya
cd gaya
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build
sudo cmake --install build
The -DCMAKE_BUILD_TYPE=Release bit is important. Otherwise the language is
much slower.
You can read the language documentation here.
For examples, take a look at the examples directory or at the standard
library under the runtime directory. You can also peek at the tests if you
want, though they may not use the latest features of the language.
Finally, you can take a look at this repo where I'm solving Advent of Code puzzles using Gaya.
Please feel free to open an issue or PR if you think you can make Gaya better! The only prerequisites for contributing is getting familiar with codebase style and using a code formatter that respects the project's configuration.
Areas in which you can help are:
- Open issues or PRs about confusing or uninformative diagnostics
- Open issues or PRs about segfaults (this is C++ after all hehe)
- Open issues or PRs to add something to the standard library
Of course, if something you thought about isn't on that list, feel free to open an issue or PR about is anyway!
- zuiderkwast for their nanbox library.
- martinus for their awesome hash table.
- The Programming Languages discord community for all their help and support.
- Bob Nystrom for his book Crafting Interpreters.
MIT