next up previous contents
Next: 3. How it works Up: QScheme Documentation Previous: 1. Preambule   Contents

Subsections

2. Introduction

2.1 History

I stated to write this Scheme because I wanted to write a midi sequencer for Linux. The idea was to has a embedded language in the sequencer, to write most of the GUI part and to offer the user access to all of the functions of the sequencer.

The first attempt with the sequencer was to use SIOD. SIOD has good interfacing capability with the C language. This was good for my goal. I also decided to use the Tk toolkit for the GUI capability. Nice. I started to code and this worked more or less. The problem I was facing is that SIOD is far to slow. Not practical to let user write sample handling in SIOD. Not even possible to code the entire GUI. To slow.

So I looked at the other Scheme available, searching for fast and easily interfacable scheme. I considered SCM, Bigloo, Gambit, STk, Rscheme, Sick and many other. Some were fast but difficult to embed, some were slow but easy to interface, other were just compiler and I do not want to waste time to compile. Anyway I have not found a fast and embedable scheme at all. That's why I decided to write it.

So the goal is to have a fast scheme, with good interfacing with C and embbedable possibility. My scheme has all this and I'm proud of it. Now, it's not perfect, but good enough for my projects.

I would emphasis: QScheme is really fast. My current benchmark gives factor from 2 to 10 times faster than other scheme interpreters1, and just a little slower than Bigloo, which compiles to C. On most of the bench, it beats perl and other scripting languages from a factor 2 and most of the time runs faster as Java, without waiting for compilation. It's enough for me.

2.2 Goodies

QScheme comes with modules, dynamic library support, foreign function call and foreign variable sharing.

It should be easy to add new types. In fact the string type is already written as a pure extension. New types not only specify how to handle objects but also how to recognize them during parsing (read).

It also should be easy to add new syntaxic construct, because syntax is table driven. As a general design rule, I replaced the maximum number of case by tables. This should lead to better flexibility.

2.3 Limitations

Unfortunately the world is bad and QScheme is not perfect.

My scheme is mostly R5RS compliant. Not all features are currently implemented. The call/cc is not currently implemented (most of the code is here, but not debugged and tested). In replacement, you can use the (catch...) (throw) mechanism which is sufficient is most cases.

QScheme is assumed to compile only with GCC., because it uses some specificity of the GCC compiler (specifically the computed gotos). Sorry, but you can not expect to compile QScheme with an other compiler lacking this possibility.

2.4 Design principle

The only way I founded to raise speed level of scheme is to compile scheme expressions to instructions for a virtual machine. The challenge is to create a virtual machine which is really fast in interpreting code. I choose a Forth like machine, because I wrote some Forth interpreter before and because GCC provides nice features to implement this kind of engine in a very efficient way.

QScheme is fast because it compiles input to some pseudo code and let the virtual machine execute it. The virtual machine is a stack bases engine. It is fast, because it's hopefully well designed and because it uses some GCC specific feature that let interpreter run very fast.

The drawback of QScheme is that it's not as portable as other scheme implementations. In fact it's know to run only on Linux on i386 and Sparc and also on Solaris (2.6) now. But I don't think it would be difficult to port QScheme to other Unices, as long as GCC is available.

Another drawback is that the code generated for the virtual machine pseudo code is relatively large in comparison with other pseudo-code. I think it's acceptable anyway.

2.5 References

The Revised^5 Report on the Algorithmic Language Scheme (R5RS) document can be found online at:

http://www-swiss.ai.mit.edu/~jaffer/Scheme.html

You may also find many interesting article on Scheme at the Scheme repository:

http://www.cs.indiana.edu/scheme-repository/

Another interesting resource is Schemers.org which can be found at:

http://www.schemers.org/


next up previous contents
Next: 3. How it works Up: QScheme Documentation Previous: 1. Preambule   Contents
Daniel Crettol
1999-07-19