Argh! Tutorial Part 0
This is a prequel to part 1 of the Argh! tutorial series. As it turns out hacking Argh! code is much more fun, when you are able to actually run it.
So in this part I’ll show you how to get your Argh! interpreter1 up and running.
For the Lazy Folks: JS Argh!
The official Argh! distribution
If the JS Argh! implementation gets to tedious and slow you want an real native Argh! interpreter on your system. The canonical source of Argh! interpreters is the official Argh! distribution, which contains various implementations of the Argh! in different languages, Argh! example code and some programming tools, like Argh! modes for GNU Emacs and Vim and more…
There are various ways of getting the official Argh! distribution:
You can download the latest release:
The releases tend to be rather outdated (which means: extremely outdated, and therefor incomplete) — but the reference Argh! interpreter included in the archive is stable and usable.
You can clone the latest version from the official mercurial repository:
hg clone http://hg.intevation.de/argh/
This is the best way to be always up to date with Argh!.
Finally, if you don’t want to use mercurial, you can download a current snapshot of the repository:
I strongly recommend to go with the current repository, by using method 2 or 3.
Building the reference interpreter
After getting the Argh! distribution one way or the other, you have to build the interpreter. I’ll assume you are using a GNU/Linux system and that you have at least make and gcc installed. On other *nix like systems building should work the same (feel free to report problems. If you are using Windows, you are on your own…
To build the default reference interpreter enter the directory with
the Argh! distribution and type
$ hg clone http://hg.intevation.de/argh/ $ cd argh $ make
that will create a sub directory
bin with the interpreter binaries
aargh. Now you can use the interpreters by calling them
with the Argh! source to interpret:
$ ./bin/argh examples/hello.agh Hello World
Or in case of Aargh! programs:
$ ./bin/aargh examples/pi.agh 3.141592653589793238462643383279
the sub directory
argh contains the various implementations. There
are implementations in various languages, from ADA to rpython…
argh/c contains an implementation in ANSI C, which happens to be the
reference interpreter we just build. The text file
contains a complete list, including authors and licensing
Worth mentioning are especially:
argh/erlangby Bernhard Herzog, written in erlang this was the first and original Aarrgh! interpreter, that is Aargh! with additional support for concurrency in Argh! programs.
argh/goby Sascha Teichmann, written in go this is a complete A(a)r(r)gh! implementation, that is: all dialects are supported and can be selected separately. Especially noteworthy is, that the go implementations are trying hard to optimize the execution of Argh! code and therefore are much faster than the other implementations with some A(a)rgh! programs. This especially true for large, generated Argh! programs.2
More to explore
As mentioned before the Argh! distribution does contain more than
example sub directory contains various Argh!
examples, from the simple Hello World to calculation of Fibonacci
numbers and Pi.
tools sub directory contains utilities for the Argh! hacker:
Vim and Emacs programming modes, where the Emacs mode includes an
complete A(a)rgh! interpreter and debugger. And
which is an BrainFuck to
Aargh! compiler written in Python.
So, now that you have everything you’ll need: Happy Argh! hacking!
Of cause an Argh! compiler would also be an (maybe even better) option — if there were one. There are optimizing interpreters by now, but an real compiler is yet to be written.[return]
Yes, there are ways of automatically generating Argh! programs: There are two BrainFuck to Argh! compilers available by Bernhard Herzog: one included in the Argh! distribution, and one still unreleased (though the release is planed). As there are many high level ways of creating BF programs you can get nearly every thing in Argh! by compiling it to BF and then to Argh! — but be warned: the results will be very big and slow, so better write your Software in Argh! directly…[return]