The Generic Programming Language
This is the main source code repository for Generic. It contains the interpreter, the bundled standard library, and the documentation.
Documentation
- Language guide - syntax, types, classes, exceptions, modules, the standard library, and the built-in unit-test framework, for people writing generic programs.
- Plugin authoring guide - write native modules (Rust, C, C++, Zig) loaded with a plain
import. API reference:generic-lang-apion docs.rs. - Architecture - internals for contributors: the scanner → compiler → bytecode → VM pipeline, the value/heap/GC model, the exception model, and the load-bearing invariants.
The workspace is three crates: generic-lang (the generic binary), generic-lang-lib (the interpreter as a library), and generic-lang-api (the plugin ABI/authoring API).
Influence
Generic is based on the Lox programming language created by Bob Nystrom for his excellent book Crafting Interpreters.
This implementation is written in Rust and very closely based on clox-rs. The walkthrough of the book alongside clox-rs can be found in the previous repo.
Syntax highlighting
A rudimentary vscode extension exists in the form of generic-lang-vscode.
Building
The interpreter can be built like this:
cargo build --release
Installation
I recommend installing Generic by building from the source code as follows:
# Download the source code
git clone https://github.com/JanEricNitschke/generic-lang
cd generic-lang
# Install 'generic'
cargo install --path .
Or more simply:
cargo install generic-lang
Or install with uv (recommended), pip, or pipx:
# With uv.
uv tool install generic-lang # Install generic globally
# With pip.
pip install generic-lang
# With pipx.
pipx install generic-lang
Now to use generic, in your terminal, run:
generic
Testing
Generic supports two types of testing:
Unit Testing (Built-in)
The language includes built-in unit testing support. Write test functions (starting with test_) and run them with:
generic --test your_file.gen
This will discover and run all test functions in isolation, providing detailed reporting. See the Testing chapter of the language guide for complete documentation.
Integration Testing
A comprehensive integration test suite and driver can be found in test and tool respectively. The driver is written in Dart and taken directly from the book repo of Crafting Interpreters. The suite is an extension of the one that can be found in the same repository.
To run the full integration test suite:
make test
Native plugins
Generic programs can load native modules - shared libraries (.so/.dylib/.dll) - with a normal import:
import "demo";
print(demo.add(19, 23)); # 42
Plugins are written in Rust against the generic-lang-api crate, or in any C-ABI language against the generated crates/generic-lang-api/include/generic.h. Worked examples in Rust, C, C++, and Zig live in plugin-examples/. See the plugin authoring guide.
Benchmark
Benchmarking Generic against the official c and java lox implementations as well as, to a limited degree, python and ruby is also possible. The reference programs for that can be found in benchmark.
The benchmarking setup is driven by hyperfine which has to be installed and added to the path separately. This also holds for ruby and python.
However, the main benchmarking is against the lox implementations. For those runs to be possible the two versions have to be install from the book repo and placed into the (relative) path
{generic-lang}/reference/craftinginterpreters.
Running the benchmark on linux is done via:
make benchmark-ci
To run the benchmarking on windows a jlox.bat with the following content:
@echo off
set "script_dir=%~dp0"
java -cp "%script_dir%\build\java" com.craftinginterpreters.lox.Lox %*
first has to be placed in the craftinginterpreters directory.
The benchmarking is then run via:
make benchmark
Metadata
Release files for generic-lang 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| generic_lang-3.2.0.tar.gz | 283.9 kB | Without provenance | Details |
Built distributions (wheels)
Total release size: 30.2 MB
Release files / generic_lang-3.2.0.tar.gz
| Download URL | generic_lang-3.2.0.tar.gz |
|---|---|
| Size | 283.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0482fc8bee9a0f723c8b5ffe8968870e48b017fa9a27f660fbf3f408939ec55
|
|
BLAKE2b-256 checksum How to use checksums |
28a9c3c748a9fb18973c2a12985b1ea5609c1070ec838a8d707c1f3285f015d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-win_arm64.whl
| Download URL | generic_lang-3.2.0-py3-none-win_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
1f5dc3177c3cb7add891692832490017f20b5c3c048ac05982e1b87379582360
|
|
BLAKE2b-256 checksum How to use checksums |
f826aa0dd0d5d6b0c98eae80bc75f59570601dae4c82d41c5ee4a348fb52e398
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-win_amd64.whl
| Download URL | generic_lang-3.2.0-py3-none-win_amd64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e0a7486cfb2d4b22511b3812438a9122c771cb94092bbab9892f9f6a2a55f6e5
|
|
BLAKE2b-256 checksum How to use checksums |
fcd75680f93483911bfa91d1f86b3d6bd30607332bea013b0b17ed568f0b2cf3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-win32.whl
| Download URL | generic_lang-3.2.0-py3-none-win32.whl |
|---|---|
| Size | 1.4 MB |
| Tags | Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
bead74eb57f0e1265a94cb1acde134ce40dc0dc059497bcf0df4d77e7a395290
|
|
BLAKE2b-256 checksum How to use checksums |
cc5b97dcdaad2be11bbf773715c1076a56aa6803b545b22cefc8f901c455c6c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | generic_lang-3.2.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
526bbace9608f4d07ed04cc422b9cf747ae1fac30ac7b1a8a1845406706959b6
|
|
BLAKE2b-256 checksum How to use checksums |
471e3243dfbe57e696093bb8457d3f9d995f5b18c66777a6d0aab63adf807393
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-musllinux_1_2_i686.whl
| Download URL | generic_lang-3.2.0-py3-none-musllinux_1_2_i686.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux musl 1.2+ x86-32 Python 3 |
|
SHA-256 checksum How to use checksums |
6600839cf7dc654348466a8153677780a42da6e945a21d61ebe4e4be538244fe
|
|
BLAKE2b-256 checksum How to use checksums |
0b1a250e66b53454a66f096cf0633713d62dad4c288e00b003ff9e19ec94b10c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-musllinux_1_2_armv7l.whl
| Download URL | generic_lang-3.2.0-py3-none-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Linux musl 1.2+ ARMv7l Python 3 |
|
SHA-256 checksum How to use checksums |
b67ec48af3fc74389518dddde53ed4a63401e01dbff3369bd3e6eba89e05987c
|
|
BLAKE2b-256 checksum How to use checksums |
1613375371cb0605b4074732fc735fefdc14ff8174c54b7746f0a950382b51f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-musllinux_1_2_aarch64.whl
| Download URL | generic_lang-3.2.0-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
164b4c18cbcbaf1a28e666d34262430e7a9d79a1747d2ac76f62891f8136f91e
|
|
BLAKE2b-256 checksum How to use checksums |
27a6e11c46cdfee80c47075426432d5d56c43ba0ae361236acaafb4dcfeb06cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | generic_lang-3.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
10e7445352f2aea9ea025874ac9c2824826dbd20714e99bae0e576819b45afb9
|
|
BLAKE2b-256 checksum How to use checksums |
068bd682a2d6dd3775cc6ae74041a556d5c254d8cc3a76dee48be759be274b61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
| Download URL | generic_lang-3.2.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Linux glibc 2.17+ IBM System/390x Python 3 |
|
SHA-256 checksum How to use checksums |
14dde7c1bf53ff125511eeec099630687fc98321e07e89b68c55e5fd91a54619
|
|
BLAKE2b-256 checksum How to use checksums |
2c716d4b5aec68a0c8388c84f62457b61741f2f872906a9bb9656b4a4dd279dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | generic_lang-3.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 2.0 MB |
| Tags | Linux glibc 2.17+ PowerPC 64-le Python 3 |
|
SHA-256 checksum How to use checksums |
7d526c675bd9bc4cc0b7f0b0e87f96254ddffe550e833e289845d4c4a824bf21
|
|
BLAKE2b-256 checksum How to use checksums |
7f16810239f212633dff16b179dd5ce31c3f903939a615693baf38409c27ed58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | generic_lang-3.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Linux glibc 2.17+ x86-32 Python 3 |
|
SHA-256 checksum How to use checksums |
55eb4457bec7a1a79c539c77b6325980cd81b50ba174b86d289614b31e90f071
|
|
BLAKE2b-256 checksum How to use checksums |
4e798c5bb070c0de98b3947b55710770ab5bd306cae0b8312de69a090f276ce0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | generic_lang-3.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Linux glibc 2.17+ ARMv7l Python 3 |
|
SHA-256 checksum How to use checksums |
c73fdd8514133a68b89a6a370e7d9d33117d86317920d8525ca7f4d61456e6f7
|
|
BLAKE2b-256 checksum How to use checksums |
97fb6dadb37cc99629d591ce3a9ff931a9933461741d70e9107353cb8d58e6b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | generic_lang-3.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
7774bfea7af025ab5be81f8aa11d9efe8caccdd0eb431e317cc53c61db8fa344
|
|
BLAKE2b-256 checksum How to use checksums |
31f1c65226bf58e33dac048ce5847c34f5c373175acfc6ba58300f7af2c44dca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-macosx_11_0_arm64.whl
| Download URL | generic_lang-3.2.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
224b92851d0d4d27d76337787804a18e065c2bdc62c8b5b87038b215d6731881
|
|
BLAKE2b-256 checksum How to use checksums |
559ad9d5343d750480e0077adca441ad82e9c306a42bfd4542f1fd6ac401af87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-macosx_10_12_x86_64.whl
| Download URL | generic_lang-3.2.0-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c01530cc2f6d0ec146b1dc95e1223b9af5cea632e649e9feeeb2c6fbf719cfeb
|
|
BLAKE2b-256 checksum How to use checksums |
7c52d8546d3bb8e4b6441bd24ac510bccd859bf652da69be5219547080574801
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-android_24_x86_64.whl
| Download URL | generic_lang-3.2.0-py3-none-android_24_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Android API level 24+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
47f747f8eb37d51457a4c8d310ee102f0e17a853c8504f6d67c6e7ea1c75caba
|
|
BLAKE2b-256 checksum How to use checksums |
9f979aa2d06619ea2bd196c35e5b5345bd6d18275d5517be5a274eac2ec169d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / generic_lang-3.2.0-py3-none-android_24_arm64_v8a.whl
| Download URL | generic_lang-3.2.0-py3-none-android_24_arm64_v8a.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Android API level 24+ ARM64 v8a Python 3 |
|
SHA-256 checksum How to use checksums |
36965f80079cc35125ed6ab7c4f3acf87d362fd196ed2f8cc764be5f4b7aafef
|
|
BLAKE2b-256 checksum How to use checksums |
1554baacb99fd6639666d060cb94c1404d5e1ab0de82fe2aa1aed6ed2b1f9579
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Security for generic-lang 3.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.