Q - Equational Programming Language


NOTE: You are looking at an old version of the Q website! Please head over to the new homepage at SourceForge and update your bookmarks now!

That being said, if you're really looking for the old stuff, enjoy your stay. :)


[Homepage][Musikwissenschaft][Musikinformatik]

15 October 2003: Q 4.5 is now available. This release sports a new GGI (general graphics interface) module and some improvements in the debugger.

10 Dec 2003: Q goes SourceForge! As of Dec 2003, Q has now become a SourceForge-hosted project. That means that eventually this website and the download area will migrate to SourceForge, and there will also be CVS access there so that you can always get your hands on the very latest and greatest development sources. Right now neither file releases nor CVS are available yet (I hope to finish this before the end of December), but I have already set up two mailing lists for discussion of Q development and usage. Enjoy!

15 Dec 2003: The SourceForge CVS Repository is now online and file releases for the latest stable versions should soon show up in the Download Area, too!

CONTENTS:    Q    Qpad    Q-Graph    Q-Midi    Q-Audio    Download    Lists    Links

NOTE: The software on this page is free software distributed under the GNU General Public License and can be obtained in the global Download section at the end of this page. The different packages are also listed both on the Freshmeat website and in the FSF Software Directory. Links to the Freshmeat record for each package are given in the "SEE ALSO" sections of the descriptions below. I always announce new releases on Freshmeat as soon as they become available. Thus, if you have registered a Freshmeat account and you'd like to be informed about new releases, just use the "Subscribe to new releases" option on the Freshmeat project pages.


Q

SEE ALSO:    COPYING   README    NEWS    ChangeLog    FAQ    Manual (HTML)    Manual (PDF)    Freshmeat    Download

Q is a modern functional programming language based on term rewriting. It is simple, powerful, extensible, portable, fast and easy to use:

Simple - Programs are just collections of equations which are used to evaluate expressions in a symbolic fashion.

Powerful - Despite its conceptual simplicity, Q is a full-featured functional programming language with a modern syntax, curried function applications, dynamic object-oriented typing, exception handling, POSIX style multithreading, and a comprehensive standard library.

Extensible - Q has a libtool-based C interface which makes it easy to extend the interpreter with your own primitives.

Portable - Q runs on BeOS, FreeBSD, Linux, Mac OS X, Solaris and Windows. Porting to other modern Unix-based platforms should be a piece of cake.

Fast - Well, as an interpreted language Q is certainly not as fast as native machine code, but it has an efficient interpreter which byte-compiles scripts in an eye blink and executes them about as fast as interpreted Lisp or Haskell.

Easy to use - Just throw together some equations, run the interpreter and start to evaluate expressions. Q scripts can be run from the command line or within GNU Emacs. For Windows, a graphical shell for editing and running Q scripts is also available.

Programming in Q means that you specify a system of equations which the interpreter uses as rewrite rules to reduce expressions to normal form. This computational paradigm is very general, in particular it also subsumes the lambda and combinatorial calculi which functional programming is based on. Term rewriting comes from a mathematical field called universal algebra, and is one of cornerstones of modern computer algebra systems. In the 1980s Michael O'Donnell pioneered the use of term rewriting as a programming language, and he also coined the term "equational programming". The Q project started out some 10 years ago as an experiment to show that term rewriting would also provide a feasible basis for a practical programming language. I think that this goal has been achieved.  The Q language is useful for scientific programming and other advanced applications, and also as a sophisticated kind of desktop calculator. It is the only general-purpose programming or scripting language based on general term rewriting I know of (not counting computer algebra systems, which are targeted at a specific audience).

As a practical programming language, Q comes with batteries included: Q's system interface comprises low-level file functions, process and thread handling, Berkeley sockets, regular expression matching, and more. Also included are interfaces to GNU dbm (simple database software), ODBC (the industry standard open database interface), John W. Eaton's GNU Octave (popular open source math software), IBM's Data Explorer (powerful scientific visualization package), GGI (a portable graphics interface) and John Ousterhout's ubiquitous Tcl/Tk (portable user interface toolkit and scripting language).

The base package includes a Q mode for GNU Emacs/XEmacs and a syntax file to enjoy syntax highlighting for the Q language in the advanced KDE editor Kate. The Windows version also provides a graphical application called Qpad for editing and running Q scripts (see below). We also have a plugin which lets you run Q sessions in GNU TeXmacs, the free scientific text editor. To install, extract this q-texmacs.tar.gz tarball into your /usr/share/TeXmacs/plugins directory.

Code samples: To whet your appetite, here are some scripts for your browsing pleasure: hello.q - the infamous "hello world" example; fib.q - Fibonacci function, implemented iteratively; huffman.q - Huffman codes in Q; primes.q - the stream of all prime numbers, using Erathosthenes' sieve; queens2.q - the 8 queens problem, shows how to implement backtracking in Q; dijkstra.q - Dijkstra's shortest path algorithm, implemented with Q-Graph; dgram.q - a simple client/server example showing how to transmit datagrams over a socket; and midi_examp.q - some basic realtime MIDI functions, written using the Q-Midi module. Please note that these are basic examples. More examples can be found in the various packages below.

Documentation: Full documentation can be found in the Q language manual (HTML, PDF). The HTML documentation is also available as a tarball. And there is an introductory paper on Q-Midi which includes a brief overview of Q's main features (PDF).


Qpad

SEE ALSO:    License.txt    ReadMe.txt    Download

The Qpad package is a complete binary distribution of the Q programming system for Windows. Besides the Q programming tools it also includes the Qpad application, a Windows frontend for the Q interpreter which provides a script editor and a "log" pane through which you can interact with the interpreter. You can use this application to edit and run Q scripts under Windows.

 


Q-Graph

SEE ALSO:    COPYING    README    NEWS    ChangeLog    Freshmeat    Download

Q-Graph is an add-on library to deal with combinatorial graphs, a data structure consisting of nodes and edges connecting the nodes. Graph theory and algorithms play a major role in countless applications such as network design and optimisation, traffic planning, routing, scheduling and visualization, and so graphs have become one of the cornerstones of applied discrete mathematics and computer science. The package implements a graph data type and the usual operations on graphs. It also contains graphed, a full-featured graph editor (requires Tcl/Tk). A sample implementation of Dijkstra's shortest path algorithm is also included. The entire package is written in Q, and thus it also provides an example of a substantial Q application.

 


Q-Midi

SEE ALSO:    COPYING    README    README-Player    NEWS    ChangeLog    Freshmeat    Download

Yep, Q finally plays music, too! :) More precisely, it can "talk" to MIDI, the "Musical Instrument Digital Interface". MIDI is the standard protocol for controlling synthesizers and other compatible equipment. Want to learn more about MIDI? Jeff Glatt's MIDI Technical Fanatic's Brainwashing Center is a good place to start.

Q-Midi is Q's MIDI module which allows you to write MIDI applications in the Q programming language. Q-Midi runs on top of MidiShare, Grame's excellent  "MIDI operating system" which is GPL'ed software, too. Q-Midi provides access to most basic MidiShare functionality, including realtime processing of MIDI messages and standard MIDI file access. This release of Q-Midi also includes a sample MIDI player/recorder written using Q-Midi (requires Tcl/Tk). The currently supported platforms are Linux, OS X and Windows. The Windows version has been tested on Windows 98 and 2000. An introduction to Q-Midi is now available (PDF, examples).

Also available: Scale 1.1, a Q-Midi software for experimenting with just and microtonal tunings. This program is based on Clarence Barlow's harmonicity theory and implements several new algorithms for the rationalization and visualization of musical scales. Requires a Linux system with Octave, OpenDX and Tcl/Tk (as well as Q-Midi, of course); see the download links below. You can find a description of the algorithms and the software in this report: Musical scale rationalization (PDF).

 


Q-Audio

SEE ALSO:    COPYING    README    NEWS    ChangeLog    Freshmeat    Download

Q-Audio is a digital audio interface for Q. The package contains two modules which together provide the basic functionality needed to write digital audio applications in the Q programming language. The audio module implements a (near-)realtime audio interface on top of Phil Burk's PortAudio library (http://www.portaudio.com), and the sndfile module allows you to access sound files in various formats using Erik de Castro Lopo's libsndfile library (http://www.zip.com.au/~erikd/libsndfile). This package works on FreeBSD, Linux, OS X and Windows. Other UNIX systems supporting the OSS sound driver should work as well, but have not been tested yet.

 


Download

The Q programming system and the various add-on packages are distributed under the GNU General Public License (GPL). The relevant items can be downloaded by clicking on the appropriate links below. Both source and various binary packages are provided. All binary packages are for the x86 architecture. Please see the RELNOTES file for further information and installation instructions, and also note the requirements for each package; additional information about required third-party software can be found below. For your convenience, we also provide Linux RPMs for the GGI and MidiShare libraries required by some packages, since these libraries are only distributed as source tarballs at this time. Please note that GGI is distributed under a BSD style license by the GGI project, while MidiShare is GPL'ed software distributed by Grame.

Q sources and binary packages
Package
Source
Binaries
Notes
Q 4.5 q-4.5.tar.gz

Windows extras:
Qpad-4.5.zip
q-win32-extra.zip
RedHat 9 q-4.5-1.i386.rpm
q-4.5-1-tk8.4.i386.rpm
q-4.5-1.src.rpm
q-4.5-1-tk8.4.src.rpm
Requires (optionally)
GGI, Octave, ODBC, OpenDX, Tcl/Tk

The *tk8.4* RPMs for RedHat
and Mandrake Linux are linked against Tcl/Tk 8.4 instead of the stock Tcl/Tk 8.3.

GGI RPMs are available for download below.

The Qpad package for Windows is also provided with German localization.
SuSE 8.1 q-4.5-1.i386.rpm q-4.5-1.src.rpm
SuSE 8.2 q-4.5-1.i386.rpm q-4.5-1.src.rpm
Mandrake 9.1 q-4.5-1.i586.rpm
q-4.5-1-tk8.4.i586.rpm
q-4.5-1.src.rpm
q-4.5-1-tk8.4.src.rpm
FreeBSD 5.1 / port
q-4.5.tbz q.shar
Windows
Qpad-4.5.msi
Qpad-4.5DE.msi (German)

Q-Graph 1.2 graph-1.2.tar.gz RedHat 9 graph-1.2-1.i386.rpm graph-1.2-1.src.rpm Requires (optionally) Tcl/Tk

Tcl/Tk 8.4  and BWidget are required for the graphed graph editor.
SuSE 8.1 graph-1.2-1.i386.rpm graph-1.2-1.src.rpm
SuSE 8.2 graph-1.2-1.i386.rpm graph-1.2-1.src.rpm
Mandrake 9.1 graph-1.2-1.i586.rpm graph-1.2-1.src.rpm
FreeBSD 5.1 / port q-graph-1.2.tbz q-graph.shar
Windows
Graph-1.2.msi

Q-Audio 1.1
q-audio-1.1.tar.gz
RedHat 9 q-audio-1.1-1.i386.rpm
q-audio-1.1-1.src.rpm Requires Libsndfile
SuSE 8.1 q-audio-1.1-1.i386.rpm q-audio-1.1-1.src.rpm
SuSE 8.2 q-audio-1.1-1.i386.rpm q-audio-1.1-1.src.rpm
Mandrake 9.1 q-audio-1.1-1.i586.rpm q-audio-1.1-1.src.rpm
FreeBSD 5.1 / port q-audio-1.1.tbz
q-audio.shar
Windows Q-Audio-1.1.msi

Q-Midi 1.11
q-midi-1.11.tar.gz
RedHat 9 q-midi-1.11-1.i386.rpm q-midi-1.11-1.src.rpm Requires MidiShare, Tcl/Tk

MidiShare RPMs are available for download below. This package is not available for FreeBSD.
SuSE 8.1 q-midi-1.11-1.i386.rpm q-midi-1.11-1.src.rpm
SuSE 8.2 q-midi-1.11-1.i386.rpm q-midi-1.11-1.src.rpm
Mandrake 9.1 q-midi-1.11-1.i586.rpm q-midi-1.11-1.src.rpm
Windows Q-Midi-1.11.msi
GGI RPMs for Linux (required for the ggi module)
GII 0.8.3/
GGI 2.0.3
www.ggi-project.org/
releases/

RedHat 9
libgii-0.8.3-1.i386.rpm
libggi-2.0.3-1.i386.rpm
libgii-0.8.3-1.src.rpm
libggi-2.0.3-1.src.rpm
Built from the GII 0.8.3/GGI 2.0.3 sources available from www.ggi-project.org

libgii is required by libggi and must be installed first.
SuSE 8.1
libgii-0.8.3-1.i386.rpm
libggi-2.0.3-1.i386.rpm
libgii-0.8.3-1.src.rpm
libggi-2.0.3-1.src.rpm
SuSE 8.2
libgii-0.8.3-1.i386.rpm
libggi-2.0.3-1.i386.rpm
libgii-0.8.3-1.src.rpm
libggi-2.0.3-1.src.rpm
Mandrake 9.1
libgii-0.8.3-1.i586.rpm
libggi-2.0.3-1.i586.rpm
libgii-0.8.3-1.src.rpm
libggi-2.0.3-1.src.rpm
MidiShare sources and RPMs for Linux (required for Q-Midi)
MidiShare 1.86
midishare-linux.tar.gz

SuSE diffs:
midishare-linux-suse.diff
RedHat 9 midishare-1.86-1.i386.rpm
midishare-1.86-1.src.rpm Built from CVS 08-14-03

The *athlon* RPM for SuSE Linux is for the Athlon kernel.

The original sources are available from
www.grame.fr/MidiShare
SuSE 8.1 midishare-1.86-1.i386.rpm midishare-1.86-1.src.rpm
SuSE 8.2 midishare-1.86-1.i386.rpm
midishare-1.86-1-athlon.i386.rpm
midishare-1.86-1.src.rpm
Mandrake 9.1 midishare-1.86-1.i586.rpm midishare-1.86-1.src.rpm

Optional Software

Some of the packages above may require additional third-party software. Links to download these items are provided below.



Mailing Lists

Two mailman-managed mailing lists are available on the SourceForge project website:

More detailed information about the mailing lists and a web-based interface to subscribe to the lists can be found by following the links above.
 


Links

Here are some links to related work:

Links to software which also uses term rewriting as an underlying computational model. If you have anything to add to this list please let me know.



Albert Graef (ag@muwiinfa.geschichte.uni-mainz.de)
Department of Music-Informatics
Johannes Gutenberg-University Mainz
Germany