Skip to content

GettingStarted

Albert Graef edited this page Aug 22, 2019 · 12 revisions

Getting started with Pure

This page provides some information to help you get up and running quickly.

Introduction

The easiest way to install Pure is from a binary package. Ready-made packages of the interpreter and addons are available on all major platforms, please check the Download page for information.

Compiling Pure from source isn't all that difficult either, once you have all the required tools and libraries installed. Most of these are readily available on Linux and other Unix-like systems.

Getting Help

Head over to the pure-lang Google group and sign up either with your normal email address or your Google/GMail account. You can read messages and post to the pure-lang group either through the web-based interface or by sending mail to pure-lang@googlegroups.com.

Getting Pure

To install Pure from source, you can either go with the released source tarballs, or use the latest development sources in the source code repository, please check the Download page for links to these. The Pure project uses the Git DVCS to manage its source code, so you'll have to install the Git software to get access to the repository.

Depending on the method you choose, either unpack the pure-x.y.tar.gz archive you downloaded (where x.y is the version number):

$ tar xfvz pure-x.y.tar.gz

Or fetch the latest development sources:

$ git clone https://github.com/agraef/pure-lang

The former command will put the source code in the pure-x.y subdirectory of the current directory. The latter gives you a clone of the full Pure source code repository in the pure-lang directory. (Please note that there are no partial checkouts of Git repositories, so you'll have to get the whole shebang.) If you go the latter route, please note the following:

  • Besides the Pure interpreter itself, which can be found in the pure-lang/pure subdirectory, the repository also includes all "official" addon modules which are maintained as part of the Pure project.

  • Once you've cloned the repository, you can update it to the latest revision by just running git pull in the pure-lang directory, please check the Git documentation for details.

  • If you go with the development sources then you should be prepared to live on the bleeding edge, as the latest version in the repository might contain some experimental and/or untested features or not yet compile on all supported systems.

Other Prerequisites

To compile Pure, you'll need the following tools and libraries:

  • GNU C/C++ and the corresponding libraries.

  • GNU make.

  • Flex and Bison. Normally these are only required when compiling from development sources. You'll need Flex 2.5.31 and Bison 2.3 or later.

  • The GNU multiprecision library, or some compatible replacement such as MPIR.

  • The GNU multiprecision floating point library.

  • The GNU readline library, or some compatible replacement such as BSD editline. This isn't a strict requirement, but without it you don't get command line editing in the interactive interpreter. We recommend GNU readline because it's easier to use and has full UTF-8 support, but in some situations BSD editline may be preferable for license reasons or because it's what the operating system provides.

  • LLVM. This is the compiler backend Pure uses for its JIT compiler. You only need the LLVM tarball which contains the LLVM library as well as most of the LLVM toolchain. LLVM versions 2.5 thru 3.5 have all been tested extensively and are known to work with Pure. You can find all LLVM releases here. Note: LLVM 3.6 and later or not supported yet (cf. ticket #6).

All dependencies listed above should be readily available for most Linux and BSD systems, except maybe LLVM for which we give some instructions below. Mac OS X users can find all dependencies including LLVM on MacPorts.

Compiling LLVM

The LLVM installation instructions on llvm.org are somewhat convoluted, but fortunately you only need the LLVM base libraries to install Pure. We recommend the following basic configuration (use ./configure --help to get an explanation of the configuration options; also please check the installation instructions for details):

$ ./configure --enable-optimized --enable-targets=host-only

Then just run the usual:

$ make
$ sudo make install

The last line installs LLVM on your system so that gcc finds it when building Pure.

Compiling Pure

Once you have all the necessary stuff installed, compiling Pure is quite easy. Chdir to the source directory and run the following commands:

$ ./configure --enable-release
$ make

(You can also leave out the --enable-release option to build a version with additional debugging information and code, but this will make the interpreter run substantially slower.)

Note: Depending on your system setup, you may have to add some options to the configure command so that the required headers, libraries and LLVM tools are found. E.g., on OS X, with the dependencies installed from MacPorts, you can build Pure as follows:

$ ./configure --enable-release --prefix=/opt/local CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib --with-tool-prefix=/opt/local/libexec/llvm-3.4/bin
$ make

(This assumes that your MacPorts root is /opt/local. Using /opt/local as the installation prefix allows you to replace an existing Pure installation from MacPorts; otherwise you can also omit the --prefix option in order to use the default /usr/local installation prefix.)

Next, make sure that the interpreter works:

$ make check

If all is well, all checks should pass. If not, please mail the author or the mailing list for help. Note that on MS Windows this step is expected to fail on some math-related tests in test020.pure since some of the math routines are not fully POSIX-compatible; that's nothing to worry about.

If Pure fails all tests, first check that LLVM has been installed properly and that it can be found by the system linker; some systems also require you to run a special utility like ldconfig for that purpose, see below. If your LLVM install looks ok but the tests still fail and the interpreter executable also segfaults immediately at startup, the most likely reason is a miscompiled LLVM. We know of some popular Linux distributions which have shipped such broken packages in the past. Try to compile LLVM yourself, as explained above. If that doesn't help either, your best bet is to get help from the mailing list.

Finally, to install Pure, do:

$ sudo make install

On some systems you'll also have to tell the dynamic linker to update its cache and/or set some environment variable so that the interpreter finds the Pure runtime library. E.g., on Linux this is done as follows:

$ sudo /sbin/ldconfig

More details, including an explanation of various configuration and build options can be found in the installation instructions. Make sure to also check the "System Notes" section in that file for known quirks and workarounds for different platforms.

Install the Online Documentation

This step is required to read the Pure documentation in the interpreter using the help command. If you have a working internet connection and the wget command, simply do the following after installing the interpreter:

$ sudo make install-docs

Instead, you can also download the pure-docs-x.y.tar.gz tarball and install it manually, please check the installation instructions for details. Or you can read the documentation online, see here.

Install Other Optional Bits and Pieces

The Pure tarball contains a number of syntax highlighting files and programming modes for various popular text editors. Most of these aren't installed automatically, but you can grab them in the etc directory in the sources and install them manually. Installation instructions are contained in the language files. (Note that pure-mode.el will be installed automatically during make install if emacs was detected at configure time.)

Install the Add-On Modules

If you got a clone of the source code repository then you might also want to build and install the addon modules. The following shell command can be used to quickly build all modules (this is to be run in the pure-lang directory you got by cloning the repository):

#! /bin/bash
for x in pure-* *-pure; do
  test -f $x/Makefile && make -C $x "$@"
done

If you put this into a shell script (or define it as a shell function) make-pure, say, then you can run the command as make-pure [target ...]. E.g., just make-pure makes all modules, make-pure clean cleans them, etc. To make this work, you must have installed the Pure interpreter beforehand, as discussed above, and you also need to have the dependencies for each module installed, please check the module documentation in the corresponding README files or on the Addons page for details.

NOTE: There are some bootstrapping issues if you install the Pure add-on modules in the manner described above for the very first time. That's because some add-on modules depend on others, so you won't be able to build them before you have built and installed these dependencies.

Therefore, when building Pure and its add-ons for the first time, you should install the modules in the following three stages:

  • First install LLVM. Then build and install pure and pure-gen, in that order.

  • Build and install the following modules in any order: pure-ffi, pure-stldict, pure-audio, pure-faust, pd-pure, pure-midi, pure-xml.

  • Now build and install the remaining add-ons. (E.g., just run the make-pure shell script created earlier.)

A collection of Arch PKGBUILDs to perform such a staged installation can be found at https://bitbucket.org/agraef/pure-pkgbuild. This can be useful even for non-Arch users, since the PKGBUILDs are simple shell scripts showing exactly what to build, how to build it, and in what order.

Install Third-Party Software

For the utmost Pure experience, you may want to install some additional 3rd party software:

  • An LLVM-capable C/C++ compiler such as llvm-gcc, clang or the dragonegg gcc plugin is needed to take advantage of Pure's capability to inline C, C++ and Fortran code. Instructions for this can be found in the installation instructions.

  • Likewise, Pure's interface to Grame's functional signal processing language Faust needs the Faust compiler; please check the the Faust wiki page for details.

  • For scientific applications you may want to get Gnumeric, Octave and Reduce which can be used with the gnumeric-pure, pure-octave and pure-reduce modules. As of Pure 0.56, it's also possible to run Pure as a plugin in GNU TeXmacs, please check the TeXmacs wiki page for details. (Gnumeric support is in limbo, however, because the latest GOffice versions have broken the API that pure-gnumeric was written for. Hopefully this can be fixed some time, but consider this module broken and unsupported right now.)

  • The Tcl/Tk-GTK+ bridge Gnocl provides an easy way to program GTK+ applications in Pure, using Tcl code and/or the Glade GUI builder together with the gnocl module in the pure-tk package.

  • If you're into computer music and multimedia applications, you should get Pd or one of its derivatives. Using the corresponding Pure addon modules, this allows you to run Pure and Faust code in the graphical Pd environment. More details can be found on the Pure Data wiki page.

Most of this software can be found in major Linux distributions. For Debian/Ubuntu we also provide packages for Faust and Gnocl in our Debian OBS Repositories. Likewise, for Arch Linux we have a ready-made Faust package in our Arch OBS Repository, and gnocl can be found in the AUR.

Using Pure

Run Pure interactively as follows:

$ pure
 __ \  |   |  __| _ \    Pure 0.59 (x86_64-unknown-linux-gnu)
 |   | |   | |    __/    Copyright (c) 2008-2014 by Albert Graef
 .__/ \__,_|_|  \___|    (Type 'help' for help, 'help copying'
_|                       for license information.)

Loaded prelude from /usr/local/lib/pure/prelude.pure.

> 6*7;
42

Read the online documentation:

> help

This invokes the Pure language and library documentation in an html browser, w3m by default; you can change this with the PURE_HELP or the BROWSER environment variable. You can also read the manual online here.

Exit the interpreter (you can also just type the end-of-file character at the beginning of a line, i.e., Ctrl-D on Unix):

> quit

The Using Pure page has more information about using the Pure interpreter.

Clone this wiki locally