A small, minimal, embeddable scripting language.
Klein is meant to fill the same niche as Lua—dead simple and highly embeddable scripting—with some improvements, notably:
- A simple TypeScript-like type system
- Improved ergonomics for iterators, tables and lists
- More built-in functionality for tables and lists
- Less ways of doing the same thing
At a glance, Klein is a statically, structurally typed, interpreted, multi-paradigm scripting language.
Klein can be built from source on any machine that can compile standard C at at least C99:
git clone https://github.com/klein-language/klein.git && cd klein && make installAll customizable flags can be found at the top of the makefile.
The default compiler is clang, but any C compiler can be used by passing it to the CC variable, i.e.:
make install CC=gccKlein is written using only standard C without compiler extensions, so it can be compiled with any C compiler.
The default location for the executable is /usr/bin, which can be set with LOCATION:
make install LOCATION=/home/me/.kleinNote that when changing this option, the location passed will be automatically created if it doesn't exist, but it won't be automatically added to your $PATH.
Klein is designed to be embedded into other languages. In general, any language that can link a static library (.a) or a dynamic library (.so, .dll) can embed Klein.
To use Klein in a C project, copy the klein.a static library and the klein.h definitions in the bindings/c directory into your project, and include klein.a when linking your object files. An example C project embedding klein can be found in tests/c.
You can also build the libraries from source if you'd like:
git clone https://github.com/klein-language/klein.git && cd klein && make c-bindingsThis will do a full clean compilation of the interpreter and place the header file, static library, and dynamic library in bindings/c.
Klein is available through the Rust crate cklein. See the rust bindings for more information.