Install a stable version of janet from the releases page. Janet is prebuilt for a few systems, but if you want to develop janet, run janet on a non-x86 system, or get the latest, you must build janet from source.
On Windows, the easiest way to install is via the scoop package manager. You will first need to add the janet-lang bucket, and then you can install janet normally.
scoop bucket add janet-lang https://github.com/janet-lang/scoop scoop install janet
Janet is available for installation through the homebrew package
janet. The latest version from git can be installed by adding the
brew install janet
Compiling and Running from Source
If you would like the latest version of Janet, are trying to run Janet on a platform that is not macos or Windows, or would like to help develop Janet, you can build janet from source. Janet only uses Make and batch files to compile on Posix and windows respectively. To configure janet, edit the header file src/conf/janetconf.h before compilation.
macos and Unix-like
On most platforms, use Make to build janet. The resulting binary will be in
cd somewhere/my/projects/janet make make test
After building, run
make install to install the janet binary and libs.
Will install in
/usr/local by default, see the Makefile to customize.
FreeBSD build instructions are the same as the unix-like build instuctions,
but you need
gcc to compile.
cd somewhere/my/projects/janet gmake CC=gcc gmake test CC=gcc
- Install Visual Studio or Visual Studio Build Tools
- Run a Visual Studio Command Prompt (cl.exe and link.exe need to be on the PATH) and cd to the directory with janet.
build_winto compile janet.
build_win testto make sure everything is working.
To install from source, the best way to is use NSIS to generate an installer and run that. You will need NSVC (or the Microsoft Build Tools) to build everything, and NSIS to build the installer. From a Developer Command Prompt, run
build_win all to build, test, and install Janet on your local machine.
To build janet for the web via Emscripten, make sure you
emcc installed and on your path. On a linux or macOS system, use
make emscripten to build
janet.wasm - both are needed to run janet in a browser or in node.
but really serves mainly as a proof of concept. Janet will run slower in a browser.
Building with emscripten on windows is currently unsupported.
Janet also has a build file for Meson, a cross platform build system. This is not currently the main supported build system, but should work on any system that supports meson. Meson also provides much better IDE integration than Make or batch files.
If you want to cut down on the size of the final Janet binary or library, you need to omit features
and build with
-Os. With meson, this can look something like below:
git clone https://github.com/janet-lang/janet.git cd janet meson setup SmallBuild cd SmallBuild meson configure -Dsingle_threaded=true -Dassembler=false -Ddocstrings=false \ -Dreduced_os=true -Dtyped_array=false -Dsourcemaps=false -Dpeg=false \ -Dint_types=false --optimization=s -Ddebug=false ninja # ./janet should be about 40% smaller than the default build as of 2019-10-13
You can also do this with the Makefile by editing
CFLAGS, and uncommenting some lines
Following tradition, a simple Janet program will print "Hello, world!".
(print "Hello, world!")
Put the following code in a file named
hello.janet, and run
The words "Hello, world!" should be printed to the console, and then the program
should immediately exit. You now have a working janet program!
Alternatively, run the program
janet without any arguments to enter a REPL,
or read eval print loop. This is a mode where Janet works like a calculator,
reading some input from the user, evaluating it, and printing out the result, all
in an infinite loop. This is a useful mode for exploring or prototyping in Janet.
This hello world program is about the simplest program one can write, and consists of only
a few pieces of syntax. This first element is the
Like all lisps, all operations in Janet are in prefix notation; the name of the operator is the first value in the tuple, and the arguments passed to it are in the rest of the tuple.
The Core Library
Janet has a built in core library of over 300 functions and macros at the time of writing. For efficient programming in Janet, it is good to be able to make use of many of these functions.
If at any time you want to see short documentation on
a binding, use the
doc macro to view the documentation for it in the REPL.
(doc defn) # -> Prints the documentation for "defn"
To see a list of all global functions in the REPL, type the command
Which will print out every global binding in the janet REPL. You can also browse the Core Library API on the website.