Perlang is a general-purpose programming language aimed at being "concurrently safe, fast and fun". Its current implementation is an interpreter implemented in C#, with some compiler-like characteristics for performing static code analysis.
The aim is to make it a fully compiled language in the long run (either to MSIL or machine code), while still remaining low-barrier and low-entry. You should never have to install a lot of packages/complex tooling to be able to start writing Perlang code; it should always remain just a single command away.
Note that if you are reading this on GitHub, the canonical source of truth for this repo can be found here: https://gitlab.perlang.org/perlang/perlang. For the background on why we went through the hassle of migrating to a self-hosted GitLab instance, see this issue (#423).
The Perlang tools are installed using
perlang-install. It works on all supported platforms
(Linux, macOS and Windows), as long as you have a POSIX compatible shell
available, e.g. bash. Use it like this:
$ curl -sSL https://perlang.org/install | shThe installer will refuse to overwrite an existing installation, if present. If this happens, you can force the install like this:
$ curl -sSL https://perlang.org/install | sh -s -- --forceThe installer will download the latest Perlang build and unpack it in a folder
under ~/.perlang. It will also print some instructions about how to add the
Perlang toolchain to your $PATH.
// hello_world.per
print "Hello World";
Running this will give you the following:
$ perlang hello_world.per
Hello World
The first digit printed is 3, and the first 999 decimals is then printed immediately after.
var digits = 1000;
var i = 1;
var x = 3 * (10 ** (digits + 20));
var pi = x;
while (x > 0) {
x = x * i / ((i + 1) * 4);
pi += (x / (i + 2));
i += 2;
}
print(pi / (10 ** 20));
- https://perlang.org/learn/quickstart/index.html - this page contains more examples and explains the basics of the Perlang REPL, which is a great tool for playing around with the language.
Note: this is not required for writing Perlang programs. These steps are required if you want to make changes to the Perlang code itself.
At the moment, Perlang can only be built on Linux (amd64 is supported,
arm64 might work but is completely untested).
- .NET 10 SDK. This can be downloaded here: https://learn.microsoft.com/en-us/dotnet/core/install/linux
In addition, some other Debian/Ubuntu packages are required for building the system:
$ sudo apt-get install \
clang-14 \
cmake \
make \
rubyThe valgrind package is not required for normal compilation or use, but
some Makefile rules like make valgrind-hello-world-example depends on it.
$ git clone https://gitlab.perlang.org/perlang/perlang.git
$ cd perlang
$ makeYou should now have a perlang executable. Run make run to run it. If you are
brave, make install (currently Linux only) will put binaries in a path under
~/.perlang which you can put in your $PATH so you can easily use it from
anywhere.
Note: this script uses the same folder (~/.perlang/nightly/bin) as the
nightly build installer. Any previous version will be overwritten without
prompting. This means that if you have previously installed a nightly build and
added the folder to your $PATH, the version installed with make install will
now be available in the $PATH instead of the previous nightly version.
- docs/syntax-grammar.md: Specification of the syntax grammar for the Perlang language.
- docs: The source code to the https://perlang.org web site. Built using MkDocs Material.
Install uv and sync the docs dependencies:
$ uv sync --group docs --frozen
$ make docs
$ make docs-serveWhen you make changes to the documentation, run make docs to regenerate them.
The mkdocs serve process started by make docs-serve will
conveniently make your browser auto-reload the changes.
If you want to continuously rebuild documentation, run make docs-autobuild in
a separate terminal window. This does not currently work flawlessly, so the
make docs approach is preferable.
Each commit to the master branch triggers a build that gets published as a set
of .tar.gz files at https://builds.perlang.org (CDN sponsored by
Fastly). Binaries are available for Linux, macOS and
Windows. These builds can be installed using the
perlang-install script mentioned earlier in this
guide.
- The Perlang compiler (everything in the
src/directory except forsrc/stdlib) is licensed under the GNU LGPL (v2.1 only) license. - The Perlang standard library (
src/stdlib) is licensed under the MIT (Expat) license.
Note that programs compiled with the Perlang compiler are not to be considered "derivative works" in a legal sense; you may use any license of your choice for Perlang programs (even though we are of course happy if you choose a free software license for your work).
perlang-install is originally based on rustup-init, which is also licensed under the MIT license. Copyright (c) 2016 The Rust Project Developers.
src/stdlib/src/posix.h includes content from the NetBSD project, licensed under the 3-clause BSD license. Copyright (c) 1980, 1991, 1993 The Regents of the University of California. All rights reserved.
src/stdlib/src/bigint.hpp includes content from
Syed Faheel Ahmad's BigInt library, available at
https://github.com/faheel/BigInt, licensed under the terms of the MIT license.
Copyright (c) 2017 - 2018 Syed Faheel Ahmad.
src/stdlib/src/libtommath includes content from libtommath (https://github.com/libtom/libtommath), licensed under the Unlicense (http://unlicense.org).
src/stdlib/src/tsl includes content from Thibaut Goetghebuer-Planchon's ordered-map library (https://github.com/Tessil/ordered-map), licensed under the terms of the MIT license. Copyright (c) 2017 Thibaut Goetghebuer-Planchon.
src/stdlib/src/fmt includes content from the {fmt}
library, available at https://github.com/fmtlib/fmt, licensed under the MIT
license. Copyright (c) 2012 - present, Victor Zverovich and {fmt}
contributors.
The src/stdlib directory uses Catch2
for unit testing, which is available under the Boost Software License 1.0.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.