chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to understand chicken limitations


From: Lassi Kortela
Subject: Re: Trying to understand chicken limitations
Date: Mon, 23 Dec 2019 15:36:32 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

As for S7, I would use Chibi instead: it's more modern and probably faster.

It's a little-known fact that S7's author, Bill Schottstaedt still actively maintains it (https://ccrma.stanford.edu/software/s7/). S7 is the scripting language for three audio/music programs: Snd, Radium, and Common Music. No matter which Scheme implementation you end up using, you may be able to bounce ideas off Bill, or ask him about who you should talk to about Scheme and Max. He is from the academic music community; with luck, he may even know somebody who has already used Scheme with Max. The Snd subversion repository (at SourceForge, linked from that page) has some S7 Scheme code for various audio tasks. You may be able to repurpose it for Max, and with some work also for Scheme implementations other than S7.

S7 is a heavily modified version of TinyScheme, which itself is a heavily modified version of the venerable Mini-Scheme dating all the way back to 1989. Mini-Scheme is an awesome feat of C coding - a Scheme interpreter with proper lexical scope and tail calls in only 2000 lines of C. However, it would be too bare-bones for your needs. TinyScheme may be enough, but S7 would probably be better since it has already been used for music.

TinyScheme should be fully re-entrant so it can be used in a multi-threaded C program. All of the interpreter state is stored in one C struct; you can make as many interpreters as you like and run each one in a different thread. I'm not sure whether or not S7 is re-entrant.

IIRC, TinyScheme (or a slight derivative of it) is the current scripting language of the GIMP image editor.

All of these Schemes start up instantly and due to their simplicity are the easiest to embed into C with no external dependencies. Their internals are easy to modify as needed. But they are also the slowest interpreters available. They don't even have a bytecode compiler; they store your procedures as lists and recurse through the lists each time you call the procedure. Chicken, Chibi-Scheme, etc. have bytecode interpreters that are almost certainly faster if your Scheme code has loops with lots of iterations. However, they are also more complex.

There's a persistent myth among programmers that interpreters are slow. On the contrary, some interpreters are remarkably fast and even the slow ones are good enough for plenty of applications. The simplest interpreters use little RAM, start up instantly and load code instantly; these advantages are more important than run-time speed for lots of programs, but are almost always overlooked.

It may be a good idea to start with S7 or TinyScheme and switch to Chicken once you outgrow it. S7 and TS are both very self-contained and designed to be easily embedded in a C codebase with no dependencies, so they are easy to try; if they don't work for your use case, you won't have wasted a lot of effort. Basic Scheme code is quite portable so you won't have to make many changes if you switch implementations.

Finally, Chicken has the best community of any programming language implementation I've come across, and also has tons of libraries ("eggs") ready to use. It is also well documented. From that standpoint, it's by far the best Scheme for your use case.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]