Scheme with C++

I’ve been looking around for a way to embed Scheme in C++ and so I’ve been doing some research. The following is what I’ve read from the docs and keep in mind I haven’t done much coding in them other than compiling some example programs.

First I looked at GNU Guile. I had high expectations, but the more I read about it the less interested I became. It’s just too bloated and too slow, not to mention that it has terrible support on Windows with the only option being Cygwin.

Next I looked at was Chibi Scheme which looked wonderful; small, simple, and portable. The only problem was that it was too lightweight and not fast enough. I’ll recommend using Chibi for lightweight scripting similar to Lua.

Moving on to compiled Schemes, I looked at Chicken, Gambit, and Bigloo. All three of these are interesting in that they compile to C code, which obviously implies easy interop with C/C++

Chicken, like Guile, was disappointing. It looked great for writing Scheme programs, but failed to deliver on embedding inside C, although it did have a nice FFI. I may be wrong on this, but I don’t believe Chicken has good support for Unicode, well at least not as good as the others. Also, it seemed to perform the worst on benchmarks of the 3 compiled Schemes.

Gambit on the other hand, looks great for embedding inside C++. In fact, it’s the only implementation that mentioned C++ in the documentation – the others were entirely C based. Windows is fully supported, although MSVC lacks some GCC optimizations and so MinGW seems to be the best choice. Unfortunately, it has two flaws: 1) it lacks native threads 2) the GC is stop-the-world. These are not huge problems as it supports green threads and the GC can be configured to block less, although these are not ideal solutions.

And finally, Bigloo which seems to solve Gambit’s problems: it uses incremental Boehm GC and it has support for native (POSIX) threads. Well, at least that’s how it appears – the docs are less clear than Gambit’s. Sadly, the FFI is much less nice than Gambit’s and Windows support isn’t stellar – it’s MinGW with some pthread emulation. Oh well, I’d rather play favorites with Linux.

Well, that’s it. I also looked at some other Lisps like Racket and CLisp which were too large, but otherwise good. 

In conclusion, Chibi for lightweight scripting, Gambit for the average embedding in C++, and Bigloo for when you need high performance real-time embedded Scheme. Oh, and Chicken otherwise, although honestly a full-blown Lisp makes it seem unnecessary.



This entry was posted in Uncategorized and tagged . Bookmark the permalink.

2 Responses to Scheme with C++

  1. johnking0099 says:

    Good doc.

  2. concerned reader says:

    > it has terrible support on Windows with the only option being Cygwin

    According to the Chibi Scheme page, it also requires cygwin. Or am I missing something here?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s