@shd101wyy/yo
v0.0.21
Published
<img src="./Yo_logo.png" width=96 height=96 />
Maintainers
Readme
Yo
Work in Progress :) Not Ready!
A multi-paradigm, general-purpose, compiled programming language. Yo aims to be Simple and Fast (around 0% - 15% slower than C).
The name
Yocomes from the Chinese word柚(yòu), meaningpomelo, a large citrus fruit similar to grapefruit. It's my daughter's nickname.
Features
- First-class types.
- Compile-time evaluation.
- Homoiconicity and metaprogramming (Yo syntax is inspired by the Lisp S expression).
- Closure.
- Algebraic Effects and Handlers (One-shot delimited continuation, Tail-Resumptive. Implicit parameters via
using/given, effect handlers withreturn/escape). - Async/await (Stackless coroutine & Cooperative multi-tasking. Lazy Futures, multi-await, single-threaded concurrency via state machine transformation).
objecttype with Non-atomic Reference Counting and Thread-Local Cycle Collection.- Compile-time Reference Counting with Ownership and Lifetime Analysis.
- Thread-per-core parallelism model (see PARALLELISM.md).
- C interop.
- etc.
Language Design
For the design of the language, please refer to DESIGN.md.
Installation
The Yo language is currently distributed as an npm package:
$ npm install -g @shd101wyy/yo # Install yo compiler globally
$ yarn global add @shd101wyy/yo # Or using yarn
$ pnpm add -g @shd101wyy/yo # Or using pnpm
$ bun install --global @shd101wyy/yo # Or using bunIt exposes the yo command in your terminal.
There is also an alias yo-cli for yo command in case of naming conflicts.
Run yo --help or yo-cli --help to see available commands.
C Compiler Requirement
Yo currently transpiles to C and requires a C compiler to produce machine code. Clang is recommended for the best experience.
Installing Clang
Linux:
# Ubuntu/Debian
$ sudo apt-get update
$ sudo apt-get install clang
# Fedora/RHEL
$ sudo dnf install clang
# Arch Linux
$ sudo pacman -S clangmacOS:
# Clang is included with Xcode Command Line Tools
$ xcode-select --install
# Or install via Homebrew
$ brew install llvmWindows:
# Using Chocolatey
$ choco install llvm
# Using Scoop
$ scoop install llvm
# Or download from https://releases.llvm.org/Alternatively, you can use other C compilers like gcc or zig by specifying the compiler with the --c-compiler flag.
Linux liburing Requirement
On Linux, Yo uses io_uring for async I/O, which requires liburing to be installed.
Installing liburing (Linux)
# Ubuntu/Debian
$ sudo apt-get update
$ sudo apt-get install liburing-dev
# Fedora/RHEL
$ sudo dnf install liburing-devel
# Arch Linux
$ sudo pacman -S liburingCode examples
Check the ./tests and ./std folders for code examples.
Hello World
// main.yo
{ println } :: import "std/fmt";
main :: (fn() -> unit) {
println("Hello, world!");
};
export main;
// $ yo compile main.yo --release -o main
// $ ./mainDevelopment
The Yo compiler is written in TypeScript and uses Bun as the runtime.
Yo is primarily developed on the Steam Deck LCD (Linux). The compiler currently transpiles Yo to C; to produce
machine code you must have a C compiler (for example gcc, clang, zig, cl, etc).
Please install nix and direnv before proceeding.
The dev environment is defined in shell.nix. You can also manually install the dependencies listed in the file.
Setup
$ cd Yo
$ direnv allow . # Run this command to activate the nix shell.
# You only need to run it once.
$ bun install # Install necessary dependencies.Run the following command to watch for changes and build the project:
$ bun run devRun the following command to build the project:
$ bun run buildTest the local yo-cli:
$ bun run src/yo-cli.ts compile src/tests/examples/fixme.yo
# There is also a `yo-cli` script in the project root for testing:
$ ./yo-cli compile src/tests/examples/fixme.yoEditor Support
A VS Code extension is available here that supports basic syntax highlighting. No LSP yet.
Vim / Neovim: a minimal syntax file and a usage README are available in
vscode-extension/syntaxes/. See vscode-extension/syntaxes/README.md for installation steps,ftdetectexamples andhome-managersnippets.
