|
FAQ
Frequently asked questions, with answers.
Featured The FAQ
GeneralWhat is Pure?It is an algebraic/functional, general-purpose programming language based on term rewriting. Essentially, your programs are just collections of term rewriting rules which are used to reduce expressions to "normal form". More information about this approach can be found on the Rewriting page. Modern programming languages are getting exceedingly complicated. Pure is an attempt to "go back to the roots" and boil down programming to a model of computation which is as simple as possible, yet expressive and practical enough so that people would want to use it for their everyday programming. The author thinks that term rewriting is a good candidate for achieving that goal, as all computing is essentially rewriting (of symbols on the tape of a Turing machine, for instance), but term rewriting also offers the dimension of hierarchical data structures which simple string rewriting lacks, and most important concepts of functional programming can be added on top of that quite easily. This approach isn't really new, there are quite a few other systems which employ term rewriting as a computational model. But previous attempts to provide a real programming language based on term rewriting have suffered from various limitations or have been too slow or inconvenient for real-life applications. We think that Pure can change this situation. Why Pure?Pure is unique in that it combines general term rewriting with modern-style functional programming in a practical and general-purpose programming language (as opposed to other systems which are mostly used for algebraic modelling). While Pure may look a lot like other modern FPLs such as Haskell and ML on the surface, under the hood it's much different:
Why Not Pure?Obviously I tried to make Pure as useful and pretty as I could, but it's no silver bullet either and there are reasons why you would not want to use it (as well as some counter-arguments why you might want to try it anyway, despite these shortcomings):
Compiling and Installing PureWhen running Pure, I get the error "pure: error while loading shared libraries".On Linux, you have to run ldconfig after installing Pure, so that the dynamic linker finds the runtime library. Usually you have to do this as root, e.g.: sudo ldconfig. Please see man ldconfig for details. If after doing that you still get the same error, then most likely /usr/local/lib (or whereever the library was installed) is not in /etc/ld.so.conf, so you have to add that path to the file and then rerun ldconfig. If you installed Pure in a nonstandard location which you can't (or don't want to) add to /etc/ld.so.conf, you can also set the LD_LIBRARY_PATH environment variable accordingly. Please see man ld.so for details. Compiling Pure on NetBSD.For convenience, you should set the following environment variables in your shell startup script: export C_INCLUDE_PATH=/usr/local/include:/usr/pkg/include export LIBRARY_PATH=/usr/local/lib:/usr/pkg/lib export LD_LIBRARY_PATH=/usr/pkg/lib:/usr/local/lib To compile LLVM and Pure, you'll need updated versions of the following packages: gmake, perl5, flex, bison, readline, gmp, and gsl (Mercurial will be needed, too, if you plan to use the latest sources from the repository). The rest of the compilation process is as described in the INSTALL file, except that you have to use gmake instead of make. Thus: $ ./configure $ gmake # gmake install Remember you must be a root user to install. Also, NetBSD folks recommend not putting stuff in ld.so.conf, so instead put export LD_LIBRARY_PATH=/usr/pkg/lib:/usr/local/lib in your shell startup script, as shown above. Most addons are compiled in the same way, minus the configure step: $ gmake # gmake install Using PureThe interpreter segfaults when I compute something like fact 100000000.That's because stack checks are not enabled by default. To enable them, set the PURE_STACK environment variable to the desired stack size in kilobytes, e.g.: export PURE_STACK=4096 If you now run the interpreter, it should generate an orderly exception instead: > fact n = if n>0 then n*fact(n-1) else 1; > fact 100000000; <stdin>, line 2: unhandled exception 'stack_fault' while evaluating 'fact 100000000' Please note that PURE_STACK is only an advisory limit. Your operating system should provide you with a command (such as ulimit on Linux) to set the actual stack size available to processes. (On Windows, the stack size is hardcoded into the interpreter executable, but there are utilities to change that setting if you need to.) Dict or Stldict?Properties of dict:
Properties of stldict:
Using the Pure Sphinx FrameworkYou can use the Pure sphinx framework to format the Pure documentation in your local copy of the pure-lang repository. This is mainly useful for project members who want to test their documentation before committing to the repositories, and for users who want to get their hands on the latest bits of documentation which might not be online yet. The following notes describe the steps needed to get the necessary software installed, so that you can run Sphinx on the Pure documentation files. The steps should be followed in the indicated order. CommentsThis is a somewhat verbose version of instructions that Albert sent me to help me set up the Pure sphinx framework on my system. 1. In order to be able to refer to a specific directory, I'll assume that you have a directory, ~/Downloads, that you can use for the installation. Obviously you could use another directory. 2. For the same reason, I'll assume that you have set up a local copy of the pure-lang repository in your ~/Downloads directory. I.e., your copy is at ~/Downloads/pure-lang. If you haven't set up a local copy, the repository is available at http://code.google.com/p/pure-lang/source/checkout. 3. The step-by-step instructions that follow were tested on Mint 11 (katya), using python-docutils version 0.7-2 and python-setuptools version 0.6.15-1ubuntu1. Katya is based on Ubuntu 11.04, so the same instructions work there. The instructions should also work with other recent Linux distributions, but might need minor adjustments concerning package names etc. Step-by-Step Installation Instructions1. If you haven't already done so, install the python-setuptools and python-docutils packages using your package manager (synaptic et al). 2. While in the package manager, make sure that you do not have the python-sphinx or python-pygments packages installed. If they are installed already for some reason, please remove those packages. You'll install your own versions of these packages below. 3. cd to ~/Downloads, download the patched Pygments tarball at http://pure-lang.googlecode.com/files/pygments-1.3.1+pure.tar.bz2 and unpack the tarball. This is a Pygments version which has been patched up to provide the necessary support for highlighting Pure code. 4. cd to ~/Downloads/pygments and install the patched Pygments package by executing the following commands: ./setup.py build sudo ./setup.py install 5. cd back to ~/Downloads and download the latest Sphinx from http://sphinx.pocoo.org/latest/ by executing: hg clone https://bitbucket.org/birkenfeld/sphinx 6. cd to ~/Downloads/sphinx and install sphinx by executing the following commands: python setup.py build sudo python setup.py install 7. cd back ~/Downloads and copy the puredomain directory in the pure-lang repository into ~/Downloads by executing the following command: cp -p -r pure-lang/puredomain . 8. cd into ~/Downloads/puredomain and install the Sphinx Pure domain by executing the following commands: python setup.py build sudo python setup.py install 9. cd into ~/Downloads/pure-lang/sphinx and kick the tires. To see if things are working, you can run "make allhtml" to format the docs in your local copy of the pure-lang repository. If you do, the generated html files will be at ~/Downloads/pure-lang/sphinx/build/html. You can run "make" if you want to build the pdf manual in addition to the html files, but this requires a fairly complete TeX installation. You can use texlive from the Ubuntu/Mint package repos for that, but you also need some extra fonts and styles not usually installed by default, specifically: texlive-fonts-extra and texlive-latex-extra. Sphinx also supports a couple of other formats; e.g., it's possible to format the documentation as a Windows html help file or as an ebook. Please check pure-lang/sphinx/Makefile for details. You can also run "make help" to see the available options. 10. To clean up, cd back to ~/Downloads and delete the puredomain, sphinx and pygments directories and the downloaded Pygments tarball. |
I'd like to see a section on 'Why Pure?' given that there are other pure functional languages like Haskell, SML et al. The new section should indicate a little of Pure's hertitage, the benefits of term rewriting as the basis of a language, an indication of what problem spaces Pure would be a good fit for, and a sense of where Pure is heading.
Good idea. That info is in fact in TPPL, but it would make for a good FAQ entry.
It's been near a year since the above comment. I'd also like to see a 'Why Pure?' section, since I was recently referred to the language.
dmbarbour, thanks for reminding me, I've fixed that now. Obviously, I don't visit this page often enough. ;-) I hope that my remarks answer your question, if not then please follow up on the Pure mailing list or in private mail.
Maybe you should quote the INSTALL file and add the required LLVM version:
You only need the llvm-2.x tarball which contains the LLVM library as well as most of the LLVM toolchain. LLVM 2.6 is the latest stable release at the time of this writing. LLVM versions 2.5, 2.6 and 2.7 have all been tested extensively and are known to work with Pure. LLVM 2.3 and 2.4 might still work, too, but you'll probably have to fiddle with the sources. We really recommend using LLVM 2.5 or later, however, because there have been substantial improvements in the LLVM JIT in recent releases. (Also note that there are some x86-64 specific quirks with LLVM 2.3, see the notes on 64 bit support in the SYSTEM NOTES section for details.)
bug.me.not.dude, there are already detailed installation directions on the GettingStarted page in the wiki, is that what you're looking for? If that doesn't tell you what you need, what's the specific question that you'd like to see answered here?
Are you going to use OpenCL to speed up numerical computations? And what do you think about preparing MacRuby?-similar Mac version?
krzysiek: Regarding OpenCL, I don't see why it couldn't be used via Pure's C interface, but there's no special support in Pure for it now to make this more convenient. As Pure itself only provides basic matrix capabilities, it would make most sense to provide this as an add-on library.
Regarding the Mac support, there's a nice OSX port of Pure and most of its modules in MacPorts?. There are no interfaces to OSX-specific frameworks yet, though, simply because noone has worked on that AFAICT. (I don't use OSX myself.)
donmorrison, there are two benchmarks (binarytrees.pure and recursive.pure) in the examples at http://code.google.com/p/pure-lang/source/browse/pure/examples, but noone has taken on the work to write a reasonably complete suite of alioth benchmarks yet.
Comparisons against C backends: No, we didn't do that yet. Running the recursive benchmark against both CPython and Cython might give you an impression of how well recursive function calls perform in each implementation, but for a meaningful comparison more benchmarks are needed. It's also difficult to do a comparison with two variables (language and type of backend). If you want to get an idea of how well LLVM performs against a C backend, it might be more useful to pit Unladen Swallow against Cython.
donmorrison, you raise a lot of interesting questions, but it's really cumbersome to discuss this in the comment section of a wiki page. ;-) If you don't mind subscribing to http://groups.google.com/group/pure-lang, then we can take the discussion there, so that others can chime in.
It would be awesome if you add a bit more about performance (some charts, comparstions between pure, python, ruby etc.)
A8D469A0?: Yes, as you can see this issue was raised before. (Unfortunately, donmorrison deleted his comments, but you can still see my replies above.) I have been working on a lot of other things in the past year, but writing a reasonably complete set of alioth benchmarks in Pure is still on my TODO list for the 1.0 release.
Oh, yeah, you're right, it's much better to work on really needed stuff now. And thank you, Pure is a great language, i had some thoughts on creating something similar to it by myself. Fortunately I found your project and it's awesome! Good luck!
A8D469A0?: Thanks. Are you interested in term rewriting languages? Or LLVM as a backend? In any case, it would be nice to discuss your ideas on the mailing list.